LaTeX Windows Environment Setup Guide (TeX Live + VS Code)
For writing academic papers, course assignments, or technical documents, compiling LaTeX locally is more stable and controllable than relying on online services — and works offline. This guide’s goal: quickly set up a local LaTeX compilation environment on a new machine, using VS Code to edit, compile, and preview PDFs. It uses TeX Live (minimal scheme-small) + VS Code LaTeX Workshop, with pdflatex as the default engine (the standard engine for pure-English / math-formula documents; use bibtex for bibliographies). Download size is about 400 MB (full version ~5 GB).
0. Overview
| Component | Purpose |
|---|---|
| TeX Live | LaTeX distribution (pdflatex, xelatex, latexmk, bibtex, etc.) |
| scheme-small | Minimal installation scheme |
| VS Code | Editor |
| LaTeX Workshop | VS Code extension |
Which engine to choose: use pdflatex for pure-English / math-formula documents (including the
acmarttemplate from ACM / ASPLOS); use xelatex when you need Chinese or system fonts (fontspec) — see “Appendix A”.
1. Download the TeX Live installer
# Create directory and download
$dir = "$env:USERPROFILE\texlive-install"
New-Item -ItemType Directory -Force $dir | Out-Null
curl.exe -L -o "$dir\install-tl.zip" `
"https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet/install-tl.zip"
# Extract
Expand-Archive -Path "$dir\install-tl.zip" -DestinationPath "$dir\installer" -ForceAfter extracting, remember the installer directory name (something like install-tl-2026xxxx) — you’ll need it later.
2. Write the install config file (non-interactive)
Create a texlive.profile file inside the installer directory with the following content:
selected_scheme scheme-small
TEXDIR C:/Users/<your-username>/texlive/2026
TEXMFCONFIG ~/.texlive2026/texmf-config
TEXMFHOME ~/texmf
TEXMFLOCAL C:/Users/<your-username>/texlive/texmf-local
TEXMFSYSCONFIG C:/Users/<your-username>/texlive/2026/texmf-config
TEXMFSYSVAR C:/Users/<your-username>/texlive/2026/texmf-var
TEXMFVAR ~/.texlive2026/texmf-var
instopt_adjustpath 1
instopt_adjustrepo 1
tlpdbopt_autobackup 1
tlpdbopt_install_docfiles 0
tlpdbopt_install_srcfiles 0Key notes:
- Replace
<your-username>with your actual username.scheme-small= minimal scheme (English/formulas). For Chinese, change toscheme-full, or install extra packages after the fact (see “Appendix A”).tlpdbopt_install_docfiles 0andsrcfiles 0= skip docs and sources to save disk space (~1 GB saved).instopt_adjustpath 1= add to system PATH automatically. In practice the PATH may not take effect immediately (no reboot / terminal refresh yet), so this guide consistently calls the compilers by absolute path — the most reliable approach.
3. Run the install (download from mirror)
Run in PowerShell (note: the --% stop-parsing token prevents PowerShell 5.1 from mangling &&):
$dir = "$env:USERPROFILE\texlive-install\installer\install-tl-20XXXXXX" # replace with the actual directory name
cmd /c --% "cd /d $dir && install-tl-windows.bat --profile texlive.profile --repository https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet/ --no-interaction"Note: the string after
--%must be the literal absolute path (you cannot use the$dirvariable), for example:cmd /c --% "cd /d C:\Users\MLTZ\texlive-install\installer\install-tl-20260814 && install-tl-windows.bat --profile texlive.profile --repository https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet/ --no-interaction"
Installation takes about 3–5 minutes (Tsinghua mirror, 400 MB). When finished you’ll see “Welcome to TeX Live!”.
4. Install VS Code and the extension
- Download and install VS Code: https://code.visualstudio.com/
- Install the LaTeX Workshop extension with one command:
code --install-extension James-Yu.latex-workshop(Or open VS Code → Extensions Ctrl+Shift+X → search LaTeX Workshop → install)
5. Configure the VS Code build chain
Open the VS Code settings file (Ctrl+Shift+P → type Preferences: Open User Settings (JSON)) and add the following (keep your existing settings):
{
// —— LaTeX configuration ——
// Output build artifacts to the build/ subdirectory, keeping only sources in the root
"latex-workshop.latex.outDir": "%DIR%/build",
"latex-workshop.latex.clean.subfolder.enabled": true,
"latex-workshop.latex.recipes": [
{
"name": "pdflatex ➞ bibtex ➞ pdflatex×2",
"tools": ["pdflatex", "bibtex", "pdflatex", "pdflatex"]
},
{
"name": "pdflatex only",
"tools": ["pdflatex"]
}
],
"latex-workshop.latex.tools": [
{
"name": "pdflatex",
"command": "C:/Users/<your-username>/texlive/2026/bin/windows/pdflatex.exe",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-output-directory=%OUTDIR%",
"%DOC%"
]
},
{
"name": "bibtex",
"command": "C:/Users/<your-username>/texlive/2026/bin/windows/bibtex.exe",
"args": ["%OUTDIR%/%DOCFILE%"]
}
]
}Why absolute paths: even if the system PATH hasn’t refreshed (no reboot yet), VS Code can still find the compiler directly — stable and reliable. Two key points about outDir: ① you must set
latex-workshop.latex.outDir, and ② write-output-directory=%OUTDIR%in pdflatex’s args and%OUTDIR%/%DOCFILE%in bibtex’s args — setting the outDir variable alone without using these placeholders will leave bibtex unable to find the.auxfile. When you need Chinese, swap the pdflatex above for xelatex (change the command path toxelatex.exe) — see “Appendix A”.
6. Verify compilation
Create test.tex:
\documentclass{article}
\usepackage{amsmath, amssymb}
\usepackage{hyperref}
\title{A Minimal Compile Test}
\author{Test}
\date{\today}
\begin{document}
\maketitle
\section{Math}
Inline: $E = mc^2$. Display:
\[
\int_{0}^{\infty} e^{-x^2}\, dx = \frac{\sqrt{\pi}}{2}.
\]
\section{Reference}
See \url{https://tug.org/texlive/}.
\end{document}Verify from the command line (confirm the toolchain itself works):
cd C:\path\to\your\project
C:\Users\<your-username>\texlive\2026\bin\windows\pdflatex.exe -interaction=nonstopmode test.texIf it succeeds, test.pdf is generated.
Verify inside VS Code:
- Open
test.tex - Press
Ctrl+Alt+B(or click the ▶ on the right) → choose the pdflatex only recipe - Press
Ctrl+Alt+Vto preview the PDF
7. Compiling ACM papers (the acmart template)
Submitting to ACM conferences (ASPLOS, MICRO, etc.) uses the acmart document class, which needs an extra package — and TeX Live 2026 removed three old packages that acmart depends on, so you must add them back manually, otherwise it keeps failing with File ... .sty not found.
7.1 Install acmart and its dependencies
$tlmgr = "C:\Users\<your-username>\texlive\2026\bin\windows\tlmgr.bat"
& $tlmgr install acmart
# acmart doesn't pull in all its dependencies automatically — install whichever are missing (these were needed in practice):
& $tlmgr install totpages environ setspace framed zref hyperxmp libertine inconsolata newtx pifont comment algorithm2e multirow ifoddpage relsize endfloat tocbibind7.2 Manually install the three packages TL2026 removed (key gotcha)
manyfoot / nccfoots (both part of ncctools) and balance (part of preprint) were removed in TeX Live 2026 and cannot be installed via tlmgr. Download the sources (.dtx + .ins) from CTAN, generate the .sty files with latex, and place them in texmf-local:
$tl = "C:\Users\<your-username>\texlive\2026\bin\windows"
# 1) ncctools (produces manyfoot.sty and nccfoots.sty)
$work = "$env:TEMP\ncctools-build"; New-Item -ItemType Directory -Force $work | Out-Null
$src = "https://mirrors.ctan.org/macros/latex/contrib/ncctools/source/"
foreach ($f in @("manyfoot.dtx","nccfoots.dtx","ncctools.ins")) {
Invoke-WebRequest -Uri ($src + $f) -OutFile "$work\$f" -UseBasicParsing
}
Push-Location $work; & "$tl\latex.exe" -interaction=nonstopmode ncctools.ins; Pop-Location
Copy-Item "$work\manyfoot.sty","$work\nccfoots.sty" "C:\Users\<your-username>\texlive\texmf-local\tex\latex\ncctools\" -Force
# 2) preprint (produces balance.sty)
$work = "$env:TEMP\balance-build"; New-Item -ItemType Directory -Force $work | Out-Null
$src = "https://mirrors.ctan.org/macros/latex/contrib/preprint/"
foreach ($f in @("balance.dtx","balance.ins")) {
Invoke-WebRequest -Uri ($src + $f) -OutFile "$work\$f" -UseBasicParsing
}
Push-Location $work; & "$tl\latex.exe" -interaction=nonstopmode balance.ins; Pop-Location
Copy-Item "$work\balance.sty" "C:\Users\<your-username>\texlive\texmf-local\tex\latex\balance\" -Force
# 3) Refresh the filename database
& "$tl\texhash.exe"After installing, verify it’s found with
& "$tl\kpsewhich.exe" balance.sty.
7.3 Compile acmart with pdflatex (not xelatex)
acmart is designed for pdflatex by default; using xelatex fails with a LibertinusMath-Regular font not found error. With a bibliography (the template uses \bibliographystyle{plain} + \bibliography{references}), the build chain is:
pdflatex -output-directory=build main.tex
bibtex build/main
pdflatex -output-directory=build main.tex
pdflatex -output-directory=build main.tex8. One-command compilation (latexmk) and output directory
To avoid typing multiple commands by hand, use latexmk. Place a .latexmkrc in your project root:
$pdf_mode = 1; # use pdflatex
$pdflatex = 'C:/Users/<your-username>/texlive/2026/bin/windows/pdflatex.exe -synctex=1 -interaction=nonstopmode -file-line-error %O %S';
$bibtex = 'C:/Users/<your-username>/texlive/2026/bin/windows/bibtex.exe %O %B';
$out_dir = 'build'; # all artifacts go to build/, leaving only sources in the rootThen:
latexmk main.tex # compile (automatically runs multiple passes + bibtex)
latexmk -c # clean auxiliary files (keep the PDF)
latexmk -C # clean all artifacts (including the PDF)9. Daily use cheat sheet
| Action | Shortcut / command |
|---|---|
| Compile | Ctrl+Alt+B (VS Code) or latexmk main.tex on the command line |
| Preview PDF | Ctrl+Alt+V |
| Jump from PDF back to source | Ctrl+click text in the preview window (requires -synctex=1) |
| Clean auxiliary files | latexmk -c |
| Update packages | tlmgr update --self --all |
Appendix A: If you need Chinese support (switch to xelatex)
The minimal scheme doesn’t include Chinese font packages — install them separately (~50 MB):
C:\Users\<your-username>\texlive\2026\bin\windows\tlmgr.bat install ctex xecjk fontspec fandolThen use in your document:
\documentclass{article}
\usepackage{ctex}
\begin{document}
你好,世界!
\end{document}Switch the engine to xelatex (in VS Code, change pdflatex.exe to xelatex.exe, or run xelatex xxx.tex on the command line).
Appendix B: Troubleshooting notes
cmd /c "... && ..."fails under PowerShell 5.1 → use the--%stop-parsing token to pass arguments verbatim (see step 3).- Garbled Chinese error messages → this is a GBK encoding display issue that doesn’t affect actual execution; use
[System.Text.Encoding]::GetEncoding(936)to decode and view them correctly. - VS Code can’t find the compiler → write the absolute path in
command(see step 5); no reboot needed. .batfile: “‘xxx’ is not recognized as an internal or external command” → usually the working directory didn’t change; make sure to usecd /d <absolute-path> &&to switch within the same cmd process.- acmart keeps failing with
File ... .sty not found→ missing dependencies plus the three packages TL2026 removed (manyfoot/nccfoots/balance); install them per “Section 7”. - acmart fails with
LibertinusMath-Regularnot found under xelatex → switch to pdflatex (acmart’s default engine). - outDir is set but bibtex can’t find
.aux→ bibtex’s args should use%OUTDIR%/%DOCFILE%, and pdflatex should pass-output-directory=%OUTDIR%. - bibtex reports
I found no \citation commands→ the text has no\cite{}yet; this is normal and doesn’t prevent the PDF from being produced. It goes away once you add citations.