Reputation: 2050
I have a template, which defines all the typesetting recommendations for thesis, but it uses xelatex for compilation. I want to continue using VS Code with Latex Workshops, question is how to change compiler to xelatex from pdflatex. The last one cause next error log:
C:\Users\User\AppData\Local\Programs\MiKTeX 2.9\tex/latex/fontspec\fontspec.sty:45: Fatal Package fontspec Error: The
fontspec package requires either XeTeX or
(fontspec) LuaTeX.
(fontspec)
(fontspec) You must change your typesetting engine to,
(fontspec) e.g., "xelatex" or "lualatex"instead of
(fontspec) "latex" or "pdflatex".
Upvotes: 72
Views: 57683
Reputation: 5991
I am a bit late in the party, but if someone still needs to set xelatex
from VS Code LaTeX extension, you are in the right place. Add the following configuration to your VS Code settings.json
, and voila!
"latex-workshop.latex.recipe.default": "latexmk (xelatex)",
Upvotes: 7
Reputation: 1041
Use magic comments
add the following line to the beginning of your document.
% !TEX program = xelatex
To enable magic comments, change the setting forceRecipeUsage
to false
.
Upvotes: 61
Reputation: 561
I kept getting errors with the other solutions, apparently because I was using backend=biber
in my latex code. The following configuration assumes a current MiKTeX setup (including biber) and fixes those problems (also, this does not rely on latexmk). The config uses some inspiration from that of TeXworks.
Inside latex-workshop.latex.tools
{
"name": "xelatex",
"command": "xetex",
"args": [
"-undump=xelatex",
"%DOC%.tex"
],
"env": {}
},
{
"name": "biber",
"command": "biber",
"args": [
"%DOC%"
],
"env": {}
}
Then inside latex-workshop.latex.recipes
add the recipe:
{
"name": "xelatex ➞ biber ➞ xelatex x 2x",
"tools": [
"xelatex",
"biber",
"xelatex",
"xelatex"
]
}
Happy texing!
Upvotes: 0
Reputation: 2050
The simplest solution found in issues here, but in more common formulation:
Copying the content, simply go to Preferences → Extensions → LaTeX (meaning LaTeX is LaTeX workshops), find gear-wheel button with name Manage
, then find in the list link to settings.json
under any tag, open and type next:
"latex-workshop.latex.tools": [{
"name": "latexmk",
"command": "latexmk",
"args": [
"-xelatex",
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
}],
Reloading the VSCode may be needed.
Also setting.json
file could be found in C:\Users\*\AppData\Roaming\Code\User\settings.json
.
Upvotes: 86