Skip to content

Instantly share code, notes, and snippets.

@Querela
Created May 7, 2020 11:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Querela/2da0ac0975ce5d84a948ab734485acec to your computer and use it in GitHub Desktop.
Save Querela/2da0ac0975ce5d84a948ab734485acec to your computer and use it in GitHub Desktop.
VSCode LatexWorkshop on WSL with MikTex for XeLaTeX

VSCode remote in WSL

  • with Latex Workshop
  • compiling XeLaTeX using MikTex

MikTex installation:

  • /mnt/c/miktex-portable/texmfs

Fonts in Windows

  • for use in WSL, but with MikTex on Windows, it is not really required :-/
  • see file: ~/.config/fontconfig/fonts.conf
  • check with fc-list | grep your-font-name
  • fc-cache -f -v, sudo texhash, ....
// VSCode extension settings
{
"latex-workshop.view.pdf.viewer": "tab",
"latex-workshop.latex.autoBuild.run": "never",
"latex-workshop.latex.recipes": [
// include default ones (auto-suggestion in editor) to keep them in the recipes list
{
"name": "latexmk 🔃",
"tools": [
"latexmk"
]
},
{
// custom
// see tools section below
"name": "XeLaTeX+MakeIndex+BibTeX",
"tools": [
"miktex_texify_xelatex_all"
]
},
{
// custom
// see tools section below
"name": "latexmk (xelatex)",
"tools": [
"xelatexmk"
]
},
{
"name": "latexmk (latexmkrc)",
"tools": [
"latexmk_rconly"
]
},
{
"name": "latexmk (lualatex)",
"tools": [
"lualatexmk"
]
},
{
"name": "pdflatex ➞ bibtex ➞ pdflatex × 2",
"tools": [
"pdflatex",
"bibtex",
"pdflatex",
"pdflatex"
]
},
{
// custom
"name": "xelatex ➞ bibtex ➞ xelatex × 2",
"tools": [
"xelatex",
"bibtex",
"xelatex",
"xelatex"
]
},
{
"name": "Compile Rnw files",
"tools": [
"rnw2tex",
"latexmk"
]
}
],
"latex-workshop.latex.tools": [
{
// default
"name": "latexmk",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"-outdir=%OUTDIR%",
"%DOC%"
],
"env": {}
},
{
// custum (did not really work for me)
// https://tex.stackexchange.com/questions/478865/vs-code-latex-workshop-custom-recipes-file-location
// https://stackoverflow.com/questions/56109128/enable-xelatex-in-latex-workshops-for-visual-studio-code
"name": "xelatexmk",
"command": "latexmk",
"args": [
"-xelatex",
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
},
{
// custom (uses MikTex)
// https://github.com/James-Yu/LaTeX-Workshop/wiki/Compile#latex-recipes
"name": "miktex_texify_xelatex_all",
"command": "texify.exe",
"args": [
"--pdf",
"--engine=xetex",
"--synctex=1",
"--tex-option=\"-interaction=nonstopmode\"",
"--tex-option=\"-file-line-error\"",
"--clean",
// note how I only use the filename, as VSCode remote in WSL keeps using "/" in the path!
"%DOCFILE_EXT%"
// "%DOC_EXT_W32%"
// $(wslpath -w ...)
],
"env": {
"TEXMFHOME": "/mnt/c/miktex-portable/texmfs",
// $PATH is required, TEXMFHOME?
"PATH": "/mnt/c/miktex-portable/texmfs/install/miktex/bin/x64/:${PATH}"
}
},
{
// continue with defaults
"name": "lualatexmk",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-lualatex",
"-outdir=%OUTDIR%",
"%DOC%"
],
"env": {}
},
{
"name": "latexmk_rconly",
"command": "latexmk",
"args": [
"%DOC%"
],
"env": {}
},
{
"name": "pdflatex",
"command": "pdflatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
],
"env": {}
},
{
// is that correct?
"name": "xelatex",
"command": "xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
],
"env": {}
},
{
"name": "bibtex",
"command": "bibtex",
"args": [
"%DOCFILE%"
],
"env": {}
},
{
"name": "rnw2tex",
"command": "Rscript",
"args": [
"-e",
"knitr::opts_knit$set(concordance = TRUE); knitr::knit('%DOCFILE_EXT%')"
],
"env": {}
}
]
}
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<dir>/mnt/c/Windows/Fonts</dir>
</fontconfig>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment