Latex-Workshop GitHub: https://github.com/James-Yu/LaTeX-Workshop/wiki/Install#usage

Configure LateX Workshop by Paul Wintz: https://paulwintz.com/latex-in-vscode/

Integrating Overleaf with VS Code: https://www.youtube.com/watch?v=SaMRCYbsAek

Build the document

You can define several compiling toolchains to build LaTeX projects using LaTeX recipes and then call the command Build with recipe to choose the appropriate toolchain for actually building the project. Alternatively, you can directly select the appropriate recipe from the TeX badge .

Below are some commonly used examples:

"latex-workshop.latex.recipes": [
  {
    "name": "latexmk",
    "tools": [
      "latexmk"
    ]
  },
  {
    "name": "pdflatex -> bibtex -> pdflatex * 2",
    "tools": [
      "pdflatex",
      "bibtex",
      "pdflatex",
      "pdflatex"
    ]
  }
]
  • The first one simply relies on the latexmk command. This is the default recipe to use when building a project.

  • The second one run the following sequence of commands pdflatex → bibtex → pdflatex → pdflatex.

  • Many of my projects use xelatex instead of pdflatex to support Unicode characters and OpenType fonts. The recipe is similar to the second one, but it uses xelatex instead of pdflatex.

You can change the default recipe by setting the latex-workshop.latex.recipe.default. Recipes are referred to by their names as defined in latex-workshop.latex.recipes. Note there are two special values:

  • "first": Use the first recipe defined in latex-workshop.latex.recipes.
  • "lastUsed": Use the last used recipe by the command *LaTeX Workshop:

    Build with recipe*. This is useful when you have multiple recipes defined and you want to use the last one you used without having to select it again.

// set the default recipe to the last used one
"latex-workshop.latex.recipe.default": "lastUsed"

View PDF

  • Forward/Direct synctex (source to pdf) can either be activated by selecting ‘Navigate, select, and edit’ > ‘SyncTeX from cursor’ in the side bar, or by the shortcut cmd+option+j (on Mac).

      // enable 
      "latex-workshop.synctex.afterBuild.enabled": true
    

    The setting syncs PDF with cursor position after compiling., defaults to false.

  • Backward/Reverse synctex (pdf to source) is activated by pointing at the relevant element of the pdf preview. When using the internal viewer, the default keybinding to point at an element in the pdf preview is cmd+click. It can be changed to double-click using the setting latex-workshop.view.pdf.internal.synctex.keybinding.

    "latex-workshop.view.pdf.internal.synctex.keybinding": "double-click"
    

Output Directory

By default, LaTeX builds with LaTeX Workshop puts output files in the directory containing your .tex file. This quickly creates a cluttered mess, due to the numerous auxiliary files generated by the LaTeX build process. To avoid clutter and allow for build files to be quickly deleted, change the out directory. I use the following setting:

"latex-workshop.latex.outDir": "%DIR%/out_dir",

After changing "latex-workshop.latex.outDir", LaTeX Workshop’s "Clean up auxiliary files" command no longer deletes auxiliary files unless you also change this setting:

"latex-workshop.latex.clean.subfolder.enabled": true,

(Note: The “Clean up auxiliary files” command misses some file types, so for a full clean you should just delete all of the files in the folder manually.)


Overleaf Integration

Overleaf Workshop Extension: https://github.com/iamhyc/overleaf-workshop

Log in with Cookies

Highlight features:

  • Sync with Overleaf Cloud

    User cursor indicator will show your position.

  • Chat with Collaborators (copy line reference)

Caveats:

  • Do not use the Overleaf Workshop “Open Projects Locally” feature. Using a local version leads to major issues, including edit conflicts and data loss. See this GitHub issue.