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.
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityI. 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:
First, download Code Runner from vscode extension tab.
Next, on the same page, click the little gear on the right of the uninstall button.
Then, click Edit in settings.json
under Executor Map by File Extension
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.