Configuring a LaTeX Development Environment on Windows with TeX Live 2024 and VS Code

Prerequisites and Installation Overview

To establish a robust LaTeX typesetting environment on Windows 10, the following components are required:

  • Operating System: Windows 10 or later
  • Distribution: TeX Live 2024
  • Editor: Visual Studio Code with the LaTeX Workshop extension
  • PDF Viewer: SumatraPDF (recommended for forward and reverse search capabilities)

Before proceeding, it is beneficial to understand the distinction between TeX distributions, editors, and macro packages. While multiple editors exist, this guide focuses on the combination of TeX Live and VS Code for a modern workflow.

Installing TeX Live 2024

Download the TeX Live 2024 ISO image from a trusted CTAN mirror. Once downloaded, locate the install-tl-advanced.bat script within the mounted ISO or extracted folder. Right-click the file and select "Run as administrator" to launch the installation wizard.

For users who prefer portability, select the Portable setup option during the configuration stage. This allows the entire distribution to be moved to different machines without reinstallation. To optimize disk usage, choose the Custom scheme instead of the full installation. It is advisable to select the "medium" scheme first, then switch to "custom" to retain a solid base of packages while excluding unnecessary language files.

After the installation completes (typically taking around 30 minutes), verify the setup. Navigate to the installation directory, for example, C:\texlive\2024, and execute tl-tray-menu.exe. From the system tray icon, open the Command Prompt and run:

tex --version

If the portable option was selected, manually add the binary directory to the system PATH environment variable. For the path mentioned above, add C:\texlive\2024\bin\windows to the PATH. Verify this by opening a standard Windows Command Prompt (Win+R, type cmd) and running tex --version again.

Managing Versions and Updates

Multiple versions of TeX Live can coexist on the same system without conflict. However, only one version can be active in the system PATH at a time. To switch versions, update the PATH variable to point to the desired version's bin directory.

Regarding updates, it is generally recommended to perform a fresh installation for major yearly releases rather than upgrading in place, especially on Windows. For managing individual packages within an installation, use the tlmgr utility.

Package Management with tlmgr

The TeX Live Manager (tlmgr) handles package installlation and updates. Access it via the TeX Live tray menu by selecting "Package Manager".

Troubleshooting Permissions: If the manager reports that the installation directory is not writable, ensure the application is run with administrator privileges. Close the manager, right-click tl-tray-menu.exe, and choose "Run as administrator".

Updating the Manager: If installation options appear grayed out, update tlmgr itself before attempting to install new packages.

Configuring Visual Studio Code

Install the LaTeX Workshop extension from the VS Code marketplace. Configuration is managed through the settings.json file. Workspace settings override user settings, allowing project-specific configurations.

Defining Compilation Recipes

Open the Command Palette (Ctrl+Shift+P) and select "Preferences: Open Settings (JSON)". Modify the workspace settings to define custom compilation tools and recipes. The following configuration supports XeLaTeX for Chinese content and includes a chain for bibliography processing.

{
  "latex-workshop.latex.recipes": [
    {
      "name": "XeLaTeX Engine",
      "tools": [ "xelatex_engine" ]
    },
    {
      "name": "PDFLaTeX Engine",
      "tools": [ "pdflatex_engine" ]
    },
    {
      "name": "XeLaTeX + BibTeX Chain",
      "tools": [
        "xelatex_engine",
        "bibtex_tool",
        "xelatex_engine",
        "xelatex_engine"
      ]
    },
    {
      "name": "Latexmk Auto",
      "tools": [ "latexmk_tool" ]
    }
  ],
  "latex-workshop.latex.tools": [
    {
      "name": "latexmk_tool",
      "command": "latexmk",
      "args": [
        "-synctex=1",
        "-interaction=nonstopmode",
        "-file-line-error",
        "-pdf",
        "-outdir=%OUTDIR%",
        "%DOC%"
      ],
      "env": {}
    },
    {
      "name": "xelatex_engine",
      "command": "xelatex",
      "args": [
        "-synctex=1",
        "-interaction=nonstopmode",
        "-file-line-error",
        "%DOC%"
      ],
      "env": {}
    },
    {
      "name": "pdflatex_engine",
      "command": "pdflatex",
      "args": [
        "-synctex=1",
        "-interaction=nonstopmode",
        "-file-line-error",
        "%DOC%"
      ],
      "env": {}
    },
    {
      "name": "bibtex_tool",
      "command": "bibtex",
      "args": [ "%DOCFILE%" ],
      "env": {}
    }
  ]
}

Verification Test

Create a new file named main.tex and input the following content to verify the environment:

\documentclass{ctexart}
\begin{document}
\section{Environment Check}
Compilation successful. 
\end{document}

Use Ctrl+Alt+B to build the project. For Chinese documents, ensure the XeLaTeX recipe is selected.

Integrating SumatraPDF

For optimal forward and reverse search functionality, configure an external PDF veiwer. Download the portable version of SumatraPDF and extract it to a known location, such as C:\Program Files\SumatraPDF.

Update settings.json to enable external viewing and SyncTeX support:

{
  "latex-workshop.view.pdf.viewer": "external",
  "latex-workshop.view.pdf.external.viewer.command": "C:\\Program Files\\SumatraPDF\\SumatraPDF.exe",
  "latex-workshop.view.pdf.external.viewer.args": [ "%PDF%" ],
  "latex-workshop.view.pdf.external.synctex.command": "C:\\Program Files\\SumatraPDF\\SumatraPDF.exe",
  "latex-workshop.view.pdf.external.synctex.args": [
    "-forward-search",
    "%TEX%",
    "%LINE%",
    "-reuse-instance",
    "-inverse-search",
    "code \"C:\\Users\\%USERNAME%\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\out\\cli.js\" -r -g \"%f:%l\"",
    "%PDF%"
  ]
}

Reverse Search Configuration: Inside SumatraPDF, navigate to Settings > Options. In the "Inverse search command-line" field, enter the command used in the synctex.args above (specifically the part invoking code with the CLI path).

Usage:

  • Forward Search: Place the cursor in the TeX file and press Ctrl+Alt+J to jump to the corresponding location in the PDF.
  • Reverse Search: Double-click any line in the SumatraPDF window to jump back to the source TeX file in VS Code.

Essential Keyboard Shortcuts

Action Shortcut
Open Keyboard Shortcuts Ctrl+K, Ctrl+S
Show LaTeX Panel Ctrl+Alt+X
Build Project Ctrl+Alt+B
Clean Auxiliary Files Ctrl+Alt+C
SyncTeX (Forward) Ctrl+Alt+J
View PDF Ctrl+Alt+V

Common LaTeX Formatting Tips

Mathematical Symbols

For exponential functions, use \exp(x) rather than e^{x} for standard notation in physics and mathematics. To position limits directly above or below summation symbols in display mode, use the \limits command:

  • Standard: \sum_{k=1}^n
  • Force Limits: \sum\limits_{k=1}^n

For optimization operators like argmin/argmax, combine \mathop with limits:

\mathop{\arg\min}\limits_{\theta} L(\theta)

Text Styling

Use \textbf{} for bold text in normal mode. In math mode, \mathbf{} works for Latin letters and numbers, while \boldsymbol{} (requires amsmath) supports Greek letters and complex symbols.

Handling References

If citations or cross-references appear as question marks after the first compilation, multiple build runs are required. A typical sequence for documents with bibliographies is: XeLaTeX → BibTeX → XeLaTeX → XeLaTeX. This ensures all auxiliary files (.aux, .bbl, .out) are correctly generated and linked.

Tags: Latex tex-live-2024 VSCode latex-workshop windows-10

Posted on Wed, 08 Jul 2026 17:29:03 +0000 by ofi