Configuring TinyTeX and VSCode (LaTeX Workshop)

coding
latex
vscode
diary
Author

Guest_1013

Published

2026-05-31

Intro

Several days ago, I got to know that there’s a thing called TinyTeX, which is a lightweight LaTeX distribution. So I just uninstalled previous install of TeXLive and started on it.

Uninstalling TeXLive

There’s an uninstall script under [your_texlive_location]/[year]/tlpkg/installer, named uninst.bat. Simply double-click it would delete everything except for some empty folders; you can manually delete them after the script finishes its job.

Installing TinyTeX

Installing

Personally I don’t like package managers on Windows, which don’t let me choose where to install; I don’t have RStudio installed either. Fortunately, there are pre-built binary installers on GitHub.

For lightweight purpose, I downloaded the installer without any number attached to its name, which should have a balanced amount of packages. However, I still needs to install a lot of packages afterwards. (There are a large amount of packages pre-installed tho)

After downloading the .exe file, put it in your designated place to install, the double-click it. After a while there should be a TinyTeX folder here.

Environmental Variable (Path)

The binary folder is not automatically added to the Path variable. To do so, manually open the env vars editor, find the Path variable, and add your_tinytex_folder/bin/windows. After restarting every terminal, you should be able to use tools like tlmgr, which will be very important.

VSCode

General Settings

An extension named “LaTeX Workshop” is commonly used. There’s no need to change setting.json. Just configure it as something like this:

"latex-workshop.latex.tools": [
    {
        "name": "pdflatex",
        "command": "pdflatex",
        "args": [
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "%DOC%"
        ]
    },

    {
        "name": "xelatex",
        "command": "xelatex",
        "args": [
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "%DOC%"
        ]
    },

    {
        "name": "bibtex",
        "command": "bibtex",
        "args": [
            "%DOCFILE%"
        ]
    }
],

"latex-workshop.latex.recipes": [
    {
        "name": "xelatex",
        "tools": [
            "xelatex"
        ]
    },
    
    {
        "name": "pdflatex",
        "tools": [
            "pdflatex"
        ]
    },
    
    {
        "name": "xe->bib->xe->xe",
        "tools": [
            "xelatex",
            "bibtex",
            "xelatex",
            "xelatex"
        ]
    },

    {
        "name": "pdflatex -> bibtex -> pdflatex*2",
        "tools": [
            "pdflatex",
            "bibtex",
            "pdflatex",
            "pdflatex"
        ]
    }
],

"latex-workshop.latex.autoBuild.run": "onFileChange",
"latex-workshop.synctex.afterBuild.enabled": true,

It’s copied from somewhere online, and is probably not the best. You can definitely choose a better one.

Problem of Not Able to View PDF Files in VSCode

Just update VSCode to the latest version. LaTeX Workshop is only compatible with a rather new version of VSCode.

The version I used was 6 months before the latest, and there’s no “check for update” option. So I just downloaded the newest installer from the official site and installed it without uninstalling the older one. Fortunately, my personal settings are preserved and it’s perfectly fine to open or preview PDF files.

Installing packages

After setting it up, I tried to compile a file I wrote; however, errors occurred that ssome files are missing. General solution is to use tlmgr search --global --file "/ctex.sty", then tlmgr install [package_name] (the folder name before the searched file in the output of the search command; for example, ctex as in texmf-dist/tex/latex/ctex/ctex.sty).

There is a more convenient option tho, which is to just install collection-latexrecommended and collection-fontsrecommended.

LaTeX test for Quarto

Isolated formula: \hat{H} \Psi = E \Psi

Inline formula: \hat{H} = \hat{p}^2 / 2m + m \omega^2 \hat{x}^2/2.