How to Configure LaTeX for Visual Studio Code

iterative technique in C++

Writing LaTeX using Visual Studio Code with LaTeX Workshop extension, MikTex, and Strawberry Pearl on Windows

17 Feb 2025

latexvscode

About

LaTeX is a powerful typesetting system, especially useful for creating documents that require high-quality formatting, such as academic papers, research articles, theses, books, and technical documents.

In this post, I will show you how to write and build LaTeX using VS Code with LateX Workshop extension, MikTeX, and Strawberry Pearl on Windows.

Instructions

  1. Download and install Strawberry pearl from: https://strawberryperl.com/
  2. Download and install MikTex from: https://miktex.org/
  3. Install LaTeX Workshop VS Code extension: https://marketplace.visualstudio.com/items?itemName=James-Yu.latex-workshop
  4. Configure LaTeX recipes by opening User Settings JSON with Shift + Ctrl + P and select Preferences: Open User Settings (JSON) and edit the following entries then save it.
{
  "latex-workshop.latex.tools": [
    {
      "name": "latexmk",
      "command": "latexmk",
      "args": [
        "-xelatex",
        "-synctex=1",
        "-interaction=nonstopmode",
        "-file-line-error",
        "-outdir=%OUTDIR%",
        "%DOC%"
      ],
      "env": {}
    },
    {
      "name": "xelatex",
      "command": "xelatex",
      "args": [
        "-synctex=1",
        "-interaction=nonstopmode",
        "-file-line-error",
        "%DOC%"
      ],
      "env": {}
    },
    {
      "name": "pdflatex",
      "command": "pdflatex",
      "args": [
        "-synctex=1",
        "-interaction=nonstopmode",
        "-file-line-error",
        "%DOC%"
      ],
      "env": {}
    },
    {
      "name": "bibtex",
      "command": "bibtex",
      "args": ["%DOCFILE%"],
      "env": {}
    }
  ],
  "latex-workshop.latex.recipes": [
    {
      "name": "XeLaTeX",
      "tools": ["xelatex"]
    },
    {
      "name": "pdfLaTeX",
      "tools": ["pdflatex"]
    },
    {
      "name": "latexmk",
      "tools": ["latexmk"]
    },
    {
      "name": "pdflatex ➞ bibtex ➞ pdflatex`×2",
      "tools": ["pdflatex", "bibtex", "pdflatex", "pdflatex"]
    },
    {
      "name": "xelatex ➞ bibtex ➞ xelatex`×2",
      "tools": ["xelatex", "bibtex", "xelatex", "xelatex"]
    }
  ],
  "latex-workshop.latex.recipe.default": "latexmk",
  "latex-workshop.formatting.latex": "latexindent"
}

That's it! You can now write in LaTeX and compile with using Ctrl + Alt + B that uses the default recipe (latexmk) or you can use other recipes from the TEX tab in the side bar.

Result:

Result