Stage 1 · Foundations 3 / 48 ≈ 15 min read

Install LaTeX on Windows: TeX Live, MiKTeX and Your Editor

Windows is the platform where LaTeX installs go wrong most often: two distributions, a PATH variable, an editor that only calls a program you may not actually have installed. This lesson walks the whole thing in the order that works — distribution, engine, editor, verification — and then fixes the failures that stop people on the first evening.

    What an install actually puts on your machine

    A LaTeX "installation" on Windows is four things, and each one fails separately. There is a folder of executables (pdflatex.exe, xelatex.exe, latexmk.exe, the package manager), a tree of package files (thousands of .sty and .cls files plus font metrics), a set of generated format files that cache the macro definitions for speed, and a registry entry or environment variable that tells Windows where the executables are.

    The first three are what the installer writes. The fourth is the one that silently goes missing: your editor can be perfectly configured and still report pdflatex is not recognized because no PATH entry points at the binary folder. Roughly half of the "LaTeX does not work on my laptop" reports are that single problem.

    The order of operations matters more than the order of installation. Install the distribution first, open a brand-new terminal and run pdflatex --version, and only then install an editor. People usually do it the other way round — they find a nice-looking editor, install it, press Build and get a wall of red — and then debug the editor, which was never the broken part.

    Everything in this lesson assumes a normal Windows 10 or 11 desktop with local admin rights. On a locked-down university or corporate machine where you cannot install software, skip to Overleaf: the compile happens on someone else's server and there is nothing to install at all.

    TeX Live and MiKTeX compared on the four axes that decide which one to install on Windows TeX Live one frozen snapshot per year Release model 2025 stays 2025 all year Packages scheme chosen at install; add the rest explicitly tlmgr install tikz Lookup dynamic tree scan, mktexlsr Updating tlmgr update --self --all Reproducible same year, same output Overleaf and journals assume this one MiKTeX rolling release, Windows-first Release model updated whenever you click Packages fetched during the compile: Ask me first / Always / Never initexmf --update-fndb Lookup file name database must be refreshed after manual adds No admin needed single-user install Reproducible your co-author lacks a package The one-line rule Pick TeX Live for anything that other people also compile. Pick a single-user MiKTeX when you cannot install software system-wide. Never keep both binary folders on PATH.
    TeX Live and MiKTeX are the same TeX engine wrapped in two opposite package policies: a frozen annual snapshot you update deliberately, or a rolling install that fetches packages while it compiles.

    TeX Live: the safe default

    TeX Live is the distribution LaTeX itself recommends, and it is the one Overleaf, most journals and almost every online answer are assuming. You download install-tl-windows.exe from the TUG download page or a CTAN mirror. Run it as administrator, and either take the graphical installer or use the text one; the GUI is easier because the important choices are checkboxes.

    Three choices decide whether your evening goes well. The installation scheme: scheme-full grabs every package on the server (several gigabytes on disk, but you will never again be missing a .sty five minutes before a deadline) while scheme-small or scheme-medium is a much lighter start you extend later with tlmgr install. The installation directory: the default C:\texlive\2025 is correct, and you should leave it. The PATH and file-association options: tick Add programs to PATH; untick the extension associations if you already have a PDF viewer you like.

    Two Windows-specific rules are worth more than every other configuration option. Do not install into a path containing spaces or non-ASCII letters — so not C:\Program Files\..., and not under a user profile named Étienne. And do not put your documents on OneDrive or the Desktop while compiling: the file watcher and the antivirus can hold test.pdf open at the moment the engine tries to rewrite it, which produces I can't write on file errors that have nothing to do with your source.

    TeX Live is released once a year and then frozen. That is a feature: a project that compiles in March still compiles in November, and a reviewer can reproduce it. The cost is that a new year means a new directory (C:\texlive\2026) next to the old one, and if both are on your PATH you will get package-version mismatches that look like random corruption. Manage updates with tlmgr --gui or tlmgr update --self --all inside the current year, and remove old years' PATH entries when you migrate.

    \varepsilon \epsilon \qquad \varphi \phi \qquad \Gamma \gamma
    \varepsilon \epsilon \qquad \varphi \phi \qquad \Gamma \gamma

    MiKTeX: Windows-native, and a different package policy

    MiKTeX is the other distribution, written with Windows conventions in mind. It offers a Basic MiKTeX installer (a few hundred megabytes) and a full one, and a clear choice between install for current user only, which lands in %LOCALAPPDATA%\Programs\MiKTeX and needs no administrator rights, and install for all users, which lands in C:\Program Files\MiKTeX and does.

    Its signature behaviour is on-the-fly package installation. When the engine meets \usepackage{tikz} and does not have it, MiKTeX asks Windows to fetch it, sometimes showing a small dialog mid-compile. The policy lives in the MiKTeX Console under Settings → General → Missing packages, with three values: Ask me first, Always install and Never install. On your own machine Ask me first is the right setting; Always quietly produces documents that only you can build.

    MiKTeX keeps its own file-name database, so files you copy into a tree by hand are invisible until you tell it. After any manual package addition, run MiKTeX Console → Maintenance → Refresh file name database or initexmf --update-fndb. Forgetting this step is why a package "clearly installed in the right folder" still reports not found under MiKTeX and works fine under TeX Live, where the lookup is dynamic.

    MiKTeX is a rolling release, so you always have the newest packages and no guarantee of the previous month's behaviour. Both distributions install cleanly on the same disk, but you should keep only one of their binary folders on your PATH. Two engines from two trees reading format files from the other tree is the classic cause of !pdfTeX error: ... cannot open format file and of a document that breaks after you touch nothing.

    \mathbb{R}^{n} \setminus \{0\} \ne \varnothing
    \mathbb{R}^{n} \setminus \{0\} \ne \varnothing
    The symbols above come from amssymb. Under MiKTeX you will be prompted for it the first time; under TeX Live you would run tlmgr install amssymb — except it is already in every scheme.

    Pick the engine and the text encoding before your first file

    Both distributions give you pdflatex, xelatex and lualatex. Start with pdflatex: it is the fastest, it is what journals and university templates expect, and its PDF output has selectable, searchable text out of the box.

    Under pdflatex the file on disk is read as UTF-8 by default — that has been true since the LaTeX kernel release of April 2018, so a modern install needs no \usepackage[utf8]{inputenc} line. What you do need is the output half: \usepackage[T1]{fontenc} plus a scalable font such as lmodern. Without T1, accented letters are assembled from two pieces, which is why they cannot be copied out of the PDF and are not hyphenated correctly.

    Save your files as UTF-8 without BOM. This is a genuine Windows trap: older Notepad wrote a byte-order mark, and those three invisible bytes sit before \documentclass and produce an error pointing at the first line of the file, which is the last place you would look. VS Code shows the encoding in the status bar and can save without a BOM; Notepad++ has an explicit Encoding → UTF-8 (without BOM) menu.

    Switch to xelatex the moment you need a font that is installed on Windows, because that is the fontspec layer and it is not optional: \setmainfont{Georgia} only works under XeLaTeX or LuaLaTeX. If you load fontspec and compile with pdflatex you get an unusually clear fatal message — The fontspec package requires either XeTeX or LuaTeX — and the fix is to change the engine in your editor's build command, not to edit the source.

    \operatorname{arg\,min}_{\theta} \; J(\theta)
    \operatorname{arg\,min}_{\theta} \; J(\theta)

    Choose an editor last, and only after the terminal works

    TeXstudio is the friendliest first editor: LaTeX-specific buttons, a wizard that points at whichever distribution it finds, Build & View on F5, and SyncTeX forward search into its internal PDF viewer. It is a good choice if you never want to open a settings file.

    VS Code with the LaTeX Workshop extension is the choice if you already live in VS Code: real multi-file search, git integration, PDF preview in an editor tab, and a build-on-save hook. It has the weakest error presentation of the three by default, so turn on latex-workshop.latex.tools flags -file-line-error and -interaction=nonstopmode — without them the extension cannot map a log line back to your source. The listing below is a working minimal configuration; the same latexmk call in settings.json is what I would put in a repository so that CI agrees with your editor.

    A third option is very Windows-specific and very good: compile from your editor and view the result in SumatraPDF. It is a tiny fast viewer that watches the PDF, never locks it, and supports inverse search (Ctrl-click in the PDF jumps to the source line). Since it closes and reopens the file without holding it, the file is locked class of Windows build failures disappears.

    Overleaf requires no Windows install whatsoever. That makes it the right answer for a managed machine, a short course, or a collaboration — and the wrong answer if your institution's template needs a class file you cannot upload, or your document is long enough to hit the free tier's compile-time limit.

    {
      "latex-workshop.latex.autoBuild.run": "onSave",
      "latex-workshop.latex.outDir": "%DIR%/build",
      "latex-workshop.view.pdf.viewer": "tab",
      "latex-workshop.synctex.afterBuild.enabled": true,
      "latex-workshop.latex.tools": [
        {
          "command": "latexmk",
          "args": [
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "-pdf",
            "-outdir=%OUTDIR%",
            "%DOC%"
          ],
          "name": "latexmk (PDF)"
        }
      ],
      "latex-workshop.latex.recipes": [
        { "name": "latexmk (PDF)", "tools": ["latexmk (PDF)"] }
      ]
    }

    Prove the install works, in this order

    Do not judge the install by the editor. Judge it by a terminal session, because that is the shortest chain of things that can be broken. Open a new command prompt (an old one keeps the environment it started with), run the version and lookup checks below, then compile a real file.

    where pdflatex answers the PATH question. pdflatex --version answers "does the executable run". kpsewhich article.cls and kpsewhich amsmath.sty answer the question nobody thinks to ask: can the engine find its package tree? A corrupted or half-installed tree fails at that step long before it fails in your document.

    Then compile test.tex with latexmk -pdf -interaction=nonstopmode -synctex=1 test.tex. Success means a PDF that opens, a test.log whose first ! line is absent, and a test.synctex.gz that lets your editor jump from source to page.

    Keep that file in a folder whose full path is short, plain ASCII and outside any cloud-synced directory. If it compiles there and fails in your real project, you have a path or a package problem, not an installation problem — and the second half of this page tells you which.

    Two separate lookups on Windows: PATH finds pdflatex.exe, and the TeX file database finds package and class files Lookup 1 — windows finds the program (path environment variable) cmd / PowerShell latexmk -pdf test.tex a new window, or the old PATH PATH C:\texlive\2025\ bin\windows\ the executables pdflatex.exe xelatex.exe latexmk.exe tlmgr.exe where pdflatex prints the path above: the install is registered empty result = "'pdflatex' is not recognized" — a PATH problem, not LaTeX Lookup 2 — the engine finds the package files (kpsewhich / kpathsea) \usepackage{amsmath} → amsmath.sty searched in this order, first hit wins: 1 · working dir folder of your .tex — why a sent .cls just works 2 · TEXINPUTS extra paths an editor or a project sets 3 · TEXMFHOME C:\Users\you\texmf your private tree 4 · TEXMFDIST C:\texlive\2025\texmf-dist everything installed Two failures that look identical in an editor Lookup 1 fails: nothing runs, you get a shell message about a command. Lookup 2 fails: the run starts and then reports ! LaTeX Error: File `something.sty' not found. — prove it with kpsewhich something.sty (MiKTeX: refresh the FNDB)
    Windows finds the executable through PATH and finds package files through a completely different lookup; a failure in one looks identical to a failure in the other until you check both.
    \documentclass[12pt,a4paper]{article}
    \usepackage[T1]{fontenc}          % hyphenation + selectable text in the PDF
    \usepackage[margin=2.5cm]{geometry}
    \usepackage{amsmath,amssymb}
    \usepackage{iftex}                % lets the file adapt to the engine you used
    
    \ifxeorlualatex
      \usepackage{fontspec}           % system fonts: needs XeLaTeX or LuaLaTeX
      \setmainfont{Georgia}
    \else
      \usepackage{lmodern}            % Latin Modern under pdfLaTeX
    \fi
    
    \title{Installation check}
    \author{A. Student}
    \date{\today}
    
    \begin{document}
    \maketitle
    
    If this page compiles, the engine, the encoding layer and the font
    metrics are all wired up correctly.
    
    \[
      \int_{-\infty}^{\infty} e^{-x^{2}}\,dx = \sqrt{\pi},
      \qquad
      \mathbb{R} \setminus \mathbb{Q} \ne \varnothing .
    \]
    
    Accented input must survive a round trip: the Greek letter
    $\varepsilon$ and the set $\mathbb{R}^{n}$ above both come from
    installed font metric files, not from your editor.
    
    \end{document}

    The five Windows failures, and what each one means

    'pdflatex' is not recognized as an internal or external command means PATH. Fix: confirm the binary folder exists (C:\texlive\year\bin\windows, or %LOCALAPPDATA%\Programs\MiKTeX\miktex\bin\x64 for a single-user MiKTeX), add it through System → About → Advanced system settings → Environment Variables → Path, then close every terminal and restart VS Code completely — the integrated terminal inherits the environment of the VS Code process, so re-opening a tab is not enough.

    ! LaTeX Error: File `somenice.sty' not found. means a missing package, not a broken install. Under TeX Live: tlmgr search --global --file "/somenice.sty" to learn which package owns it, then tlmgr install that package name. Under MiKTeX: install it from the Console's package list and refresh the file name database. If the file genuinely exists in a folder you created, the lookup paths are the problem — see the diagram above.

    ! I can't write on file `test.pdf'. means something else holds the output: an open viewer, antivirus, or a read-only cloud-synced folder. Close the PDF, move the project to a plain local folder such as D:\projects\, and exclude the folder from real-time scanning if it is a large thesis.

    !pdfTeX error: pdflatex (file ...): Font ... not found or cannot open format file almost always means two distributions are mixed. Look at where pdflatex output for a surprise, keep one binary folder on PATH, and re-run the format generation: fmtutil-sys --all under TeX Live, or Refresh font map files plus a console repair under MiKTeX.

    Builds fine in TeXstudio, fails in VS Code (or vice versa) is a path problem inside one editor's task, not a LaTeX problem. Set the full executable path — C:\texlive\2025\bin\windows\latexmk.exe — in that editor's compiler command, and check whether one of them is running as administrator while the distribution was installed per-user. An elevated process sees a different user profile, and a per-user MiKTeX simply is not there for it.

    Lesson cheat sheet

    One key line of code from each section — jump to it or copy it straight from here.

    Section Key code
    \varepsilon \epsilon \qquad \varphi \phi \qquad \Gamma \gamma
    \mathbb{R}^{n} \setminus \{0\} \ne \varnothing
    \operatorname{arg\,min}_{\theta} \; J(\theta)
    \documentclass[12pt,a4paper]{article}

    Common mistakes

    • Installing an editor and expecting LaTeX to come with it. TeXstudio, VS Code and Overleaf-local wrappers are front-ends; the distribution provides the engine.
    • Installing TeX Live into C:\Program Files or under a user profile with an accent or a space in it, then debugging phantom errors for a day.
    • Running pdflatex --version in a terminal that was already open before the install finished, concluding "it is not on my PATH", and editing the PATH a second time.
    • Leaving both TeX Live and MiKTeX on PATH so that the engine in one tree reads format files from the other.
    • Keeping "Always install missing packages on the fly" switched on for a shared project, so the document only compiles on the machine that first built it.
    • Compiling inside a OneDrive or Desktop folder while sync is running, then treating the locked-PDF error as a bug in LaTeX.
    • Adding fontspec to a pdflatex document to "fix the fonts" instead of switching the build to XeLaTeX.

    Questions about this lesson

    Do I need to install LaTeX if I use Overleaf?
    No. Overleaf runs the compiler on its own servers, so a browser is the whole install. You still need a local distribution when the document is large, when the template needs a file you cannot upload, when you want your own fonts, or when you want offline work. Plenty of people do their first month entirely in Overleaf and install nothing.
    Should I install TeX Live or MiKTeX on Windows?
    TeX Live, unless you specifically want MiKTeX behaviour. TeX Live is a frozen yearly snapshot, which is what journals, university templates and online answers assume, and its full scheme means you never meet a missing package. MiKTeX is nicer on a machine without admin rights and its on-the-fly installs are pleasant for one-off documents, but a document that depends on packages fetched during a compile is not reproducible elsewhere.
    Why does VS Code say pdflatex not found when it works in Command Prompt?
    Because VS Code's integrated terminal inherited the environment from the VS Code process, which was started before you changed PATH. Close VS Code entirely and reopen it. If it still fails, give the extension the absolute path to latexmk.exe in the tool definition rather than relying on PATH.
    How much disk space does a LaTeX install need on Windows?
    TeX Live with the full scheme is several gigabytes once the packages, fonts and documentation are on disk, and the download is a similar order. A smaller scheme starts at a fraction of that and grows as you install packages. MiKTeX's basic installer is deliberately modest and pulls the rest on demand. If disk space is the constraint, take a smaller TeX Live scheme and learn tlmgr install.
    Can I install both TeX Live and MiKTeX on the same computer?
    Yes, and uninstallers aside, you should keep only one of their binary folders in PATH. Both installers let you uncheck "add to PATH", so install one as primary and reach for the other only from an explicitly quoted full path.
    Do I need administrator rights to install LaTeX on Windows?
    TeX Live can be installed into a folder you own, but the standard flow wants admin rights to write the install directory and the system PATH. A single-user MiKTeX install writes only into your AppData folder and needs no admin rights, which makes it the usual answer on locked-down institutional machines.

    Live playground: edit the LaTeX, see it render

    The preview updates as you type — break it on purpose to see how errors look.

    KaTeX error
    Try an example

    Keep reading

    Three ways into the same idea: the notation itself, the lesson that teaches it, and an article that applies it.