How do I quickly compile LaTeX in vscode workshop without having to go to the TeX tab everytime?

I know the CTRL + ALT + B hotkey but I can't select the recipe I want.

4 Answers 4


I. LaTeX Workshop way

Go to user settings (UI) tab and search for recipe:, you will be able to see a section called Latex-workshop > Latex > Recipe: Default.

Change first to last used, then compile whatever recipe you need on the TeX menu, after that every compile you make using CTRL + ALT + B will be LuaLaTex.

II. Code Runner way

I prefer this way because I like to use the mouse for compiling.

The Code Runner extension allows people to compile a lot of file extension by using the right click menu, so here's how to use it with LaTeX:

  1. First, download Code Runner from vscode extension tab.

  2. Next, on the same page, click the little gear on the right of the uninstall button.

  3. Then, click Edit in settings.json under Executor Map by File Extension

  4. After that, add the following line before .vb or whatever comes first:

".tex": "cd $dir && latexmk -lualatex -interaction=nonstopmode -synctex=1 $fileName"

That's going to give you the exactly same thing as clicking the LuaLaTex button on the TeX menu.

You can change to -xetex or whatever you need.

In the end, the config should look like this:

"code-runner.executorMapByFileExtension": {
        ".tex": "cd $dir && latexmk -lualatex -shell-escape -interaction=nonstopmode -synctex=1 $fileName",
        ".vb": "cd $dir && vbc /nologo $fileName && $dir$fileNameWithoutExt",
        ".vbs": "cscript //Nologo",
        ".scala": "scala",
        ".jl": "julia",
        ".cr": "crystal",

Now whenever you right click a LaTeX file you should be able to use the Run Code option.


If your recipe uses LuaLaTeX, you could also install the LaTeX Previewer extension alongside Workshop.

It has a keyboard shortcut Ctrl+Shift+L to preview and also re-complies on save when the preview window is open.


Ctrl+K Ctrl+S opens the Preferences: Open Keyboard Shortcuts menu in VSCode/Codium.

Search for 'latex build' and you can keybind to the "Build with recipe" menu, where up/down arrow keys can select between all build recipes you have enabled.

You can also make a keybind to "Save without building" from the same Keyboard Shortcuts menu.


LaTeX Workshop supports Magic comments. I find them very convenient, paired with "AutoBuild on save" (look for latex-workshop.latex.autoBuild.run in Settings) (at least for documents which do not take too long to process).

Have a look at When and why should I use % !TEX TS-program and % !TEX encoding? and https://github.com/James-Yu/LaTeX-Workshop/wiki/Compile#magic-comments

Compared to LaTeX Workshop "recipes" I think that they might be more simple, but also they are portable to people that do not use VSCode.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .