Skip to main content

首页 / Posts

LaTeX: Downloading and Configuring VS Code

A complete guide to installing TeX Live and configuring LaTeX in VS Code, covering Windows, macOS, and Linux. It explains TeX Live and MacTeX downloads, mirror acceleration, Windows PATH repair with tlmgr, LaTeX Workshop setup, XeLaTeX Chinese output, SyncTeX preview, settings.json configuration, and verification steps.

Rosetears·
··1108 words·6 mins

Download and Install TeX Live
#

If your network is not ideal, you can use the Quark Netdisk resource I uploaded:

1
2
3
4
我用夸克网盘给你分享了「tex live」,点击链接或复制整段内容,打开「夸克APP」即可获取。
/~33653905Lk~:/
链接:https://pan.quark.cn/s/936429147d2c?pwd=P8dX
提取码:P8dX

Method 1: Download the Installer
#

Visit the TeX Live website. The installers for each platform are:

  • Windows: install-tl-windows.exe (network installer)
  • Linux: install-tl-unx.tar.gz (extract it and run the install-tl script)
  • macOS: MacTeX-year.pkg (the full MacTeX distribution)

Method 2: Download the ISO Image
#

Official ISO download page: https://tug.org/texlive/acquire-iso.html. Click download from a nearby CTAN mirror, then download texlive.iso.

Mirrors
#

The following are some CTAN mirrors in China. Open the mirror, click systemsTeX Live; Source/ corresponds to Method 1, and Images/ corresponds to Method 2:


(2) Run the Installer on Windows
#

Whether you use the network installer or ISO image, the Windows steps are similar.

  1. Start the installer:
    • ISO/image: after downloading, double-click the ISO or mount it as a virtual drive. Find install-tl-windows.bat in the root directory.
    • Network installer: run the downloaded install-tl-windows.exe.
    • Important: right-click the installer and choose Run as administrator so it can modify the system PATH environment variable.
  2. Change mirror source (optional but recommended):
    • If you run the .bat full installer with the Perl/Tk interface, a temporary command window and UI loader will appear first. Wait for the main interface.
    • In the .exe interface, choose a mirror in the screen shown below. Click a mirror under Asia → China, or choose TUNA if unsure.

image.png

  1. Configure installation options:
    • Install path: the default is C:\texlive\2025. If C drive space is tight, change it to another drive such as D:\texlive\2025. Avoid Chinese characters or spaces in the path.

image.png

  • Front-end component: TeXworks is installed by default. If you plan to use VS Code, uncheck TeXworks front end.
  • PATH: newer Windows installers add TeX Live’s bin directory to the system PATH by default. Make sure this option is checked. If you forgot it, run tlmgr path add later as described below.
  1. Custom installation (advanced):
    • If you are unfamiliar with the installer, do not casually change advanced settings under “Directories” or “Options.”
    • To save disk space, click “Customize” under “Selections” and keep only “Chinese” and “US and UK English” under the Languages tab.

image.png

  1. Start installation by clicking Install. The process downloads many packages from the mirror and may take 30 minutes to several hours depending on network and disk speed.

(3) Verify Installation
#

Windows (PowerShell)
#

1
2
3
4
5
6
7
8
# 1) Check XeLaTeX engine version
xelatex -v

# 2) Check TeX Live manager version
tlmgr --version

# 3) Confirm PATH points to the current year's bin directory
where xelatex

image.png

  • Change or repair PATH TeX Live provides the tlmgr path subcommand to add or remove system executable path mappings. Example:
1
2
3
tlmgr path add
# To undo:
tlmgr path remove

This subcommand follows the tlmgr manual.

  • Rollback package versions tlmgr keeps one backup by default. You can use:
1
2
3
4
# Roll back all packages to the latest backup
tlmgr restore --all
# Or for one package:
tlmgr restore <pkg> <revision>

macOS / Linux (bash)
#

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# 1) Engine version
xelatex -v

# 2) Manager version
tlmgr --version

# 3) Confirm PATH if the command is not found
which xelatex
# If PATH is wrong, use:
tlmgr path add

(4) Manually Configure Windows Environment Variables
#

Warning

Note: if VS Code cannot preview PDFs or compilation fails, the cause is often an incorrectly configured environment variable. Check and add it manually as follows.

  1. Open environment-variable settings: right-click This PC, choose Properties > Advanced system settings > Environment Variables, then find Path under System variables and edit it.

Windows environment variable location

  1. Verify and add the path: check whether the list already contains the TeX Live install path.
    • If missing or wrong: click New and enter the correct path.
    • Path requirement: it must point exactly to the bin\windows directory.
    • Example: D:\texlive\2024\bin\windows, adjusted to your actual drive and version.

Edit environment variable


Using LaTeX in VS Code
#

Installing TeX Live only provides the underlying engine and packages. We still need a modern editor to write .tex files. VS Code plus the LaTeX Workshop extension is one of the most efficient combinations.

Install VS Code and LaTeX Workshop
#

  1. Download VS Code:
  2. Install the LaTeX Workshop extension from the Extensions view in VS Code.

Tip: after installation, the TEX icon appears in the left sidebar only after you open or create a .tex file.

image.png

Key Configuration (settings.json)
#

For the best experience, especially Chinese support and a clean project directory, configure LaTeX Workshop.

Open settings.json in either of these ways:

  1. UI: File → Preferences → Settings, then click the “Open settings.json” icon in the upper right.
  2. Command Palette: press Ctrl+Shift+P on Windows/Linux or Cmd+Shift+P on macOS, then choose Preferences: Open User Settings (JSON).

image.png

Recommended XeLaTeX-based configuration: append or merge the configuration below into settings.json.

Configuration file
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{
  "latex-workshop.view.pdf.viewer": "tab",
  "latex-workshop.view.pdf.internal.synctex.keybinding": "double-click",
  "latex-workshop.synctex.afterBuild.enabled": true,
  "latex-workshop.view.pdf.zoom": "page-width",
  "latex-workshop.view.pdf.scrollMode": 0,
  "latex-workshop.view.pdf.spreadMode": 0,
  "latex-workshop.latex.outDir": "%DIR%/build",
  "latex-workshop.latex.recipes": [
    {
      "name": "XeLaTeX",
      "tools": ["xelatex"]
    }
  ],
  "latex-workshop.latex.tools": [
    {
      "name": "xelatex",
      "command": "xelatex",
      "args": [
        "-synctex=1",
        "-interaction=nonstopmode",
        "-file-line-error",
        "-output-directory=%OUTDIR%",
        "%DOC%"
      ]
    }
  ]
}

After saving the settings, open a .tex file and build it from the LaTeX Workshop panel.

image.png

Minimal Chinese Test File
#

Create a file such as main.tex:

1
2
3
4
\documentclass{ctexart}
\begin{document}
你好,LaTeX!
\end{document}

Build with XeLaTeX. If the PDF opens in a VS Code tab and Chinese text displays correctly, the basic setup is complete.

SyncTeX Preview
#

With the configuration above, double-click the PDF preview to jump back to the corresponding source position. After a build, the preview can also jump to the current source position automatically.

Common Problems
#

  • If xelatex is not recognized, check PATH and run tlmgr path add.
  • If Chinese text is missing, use XeLaTeX and a ctex class or package.
  • If the PDF does not preview, check whether LaTeX Workshop is installed and whether the build output directory is correct.
  • If formatting tools fail, install or update latexindent and its dependencies.

Final Notes
#

The simplest reliable route is: install TeX Live or MacTeX, confirm xelatex and tlmgr work in the terminal, install LaTeX Workshop in VS Code, then configure a XeLaTeX recipe. Once this loop works, writing and previewing LaTeX in VS Code becomes much smoother.

Related

[Installation] Install R, RStudio, and RTools

··625 words·3 mins
This article explains how to download and install R, RTools, and RStudio, including choosing a suitable CRAN mirror, configuring the correct installation path, and setting environment variables so you can set up an R development environment easily.

OriginPro: Beyond Traditional Box Plots, How to Draw a Beautiful Raincloud Plot

··1136 words·6 mins
Want to draw a more informative Raincloud Plot in OriginPro? This tutorial explains two methods, using the Template Center or building the plot manually. It covers data requirements, half-violin plus point cloud plus box plot overlays, styling parameters, axes and grids, statistical-summary settings, and export tips, helping non-programmers create publication-ready charts while avoiding misleading mean-only displays.

Moments

··2833 words·14 mins
Moments # 2026-06-28T01:33:00+08:00 # The site has moved from Typecho to Hugo, which should make future maintenance easier. I hope it can go farther. 2026-05-07T20:36:37+08:00 # Early summer clears after rain, and I am twenty-one this year. Looking back, the road behind me has been bright and dim in turns, and all of it has made me who I am today; looking ahead, there are mountains and waters waiting for a future journey. May the steady fire in my heart not be extinguished by the noise of the crowd; may there be clear light in my eyes, so I can still see the beauty of the world. When the wind comes, may I stand; when the rain falls, may I sing; may gain and loss not startle me, and may arrival and departure be met with calm.

DocuTranslate: A Practical Open-Source Multi-Format Document Translator

··922 words·5 mins
DocuTranslate is an open-source document translation tool that can be deployed locally. It supports PDF, DOCX, XLSX, EPUB, SRT/ASS, and other formats, preserves layout with high fidelity, and supports targeted JSONPath translation plus automatic glossary generation. This article explains workflow choices and practical parameter settings, with notes on MinerU and docling parsing, so you can handle batch translation faster.