Written and maintained by CASRAI Editorial Board
Last updated
To compile LaTeX, pick an engine (pdfLaTeX, XeLaTeX or LuaLaTeX), then either press Recompile in an online editor such as Overleaf or run latexmk on your own machine. Both routes turn a .tex source file into a PDF; the engine you choose decides which image formats, fonts and scripts the document can use. This guide is for researchers who have a manuscript, thesis or poster in LaTeX and need to produce a PDF reliably.
What compiling LaTeX is used for in research
LaTeX source is plain text. Compiling runs a TeX engine over that text (and the packages, images and bibliography files it references) to produce the typeset output, normally a PDF. Researchers compile LaTeX to build journal submissions, theses, conference papers and slides. Related how-tos on this site: Elsevier LaTeX template, slides in LaTeX and the microtype package.
Choose a LaTeX engine before you compile
The engine is the single setting most likely to decide whether a document compiles. The table below follows Overleaf’s documentation on selecting a compiler (read 2026-11-08).
| Engine | Images | Fonts and text | Notes |
|---|---|---|---|
| pdfLaTeX (Overleaf default) | .png, .jpg, .pdf; converts .eps to .pdf during compilation, which can lengthen compile time | Standard choice for Latin-script documents | May not handle pstricks well on Overleaf |
| LaTeX | Only .eps and .ps images with includegraphics |
Not stated | Use it only if all your images are .eps |
| XeLaTeX | .png, .jpg, .pdf, .eps | Robust UTF-8; TrueType and OpenType fonts | Supports pstricks; recommended for non-Latin scripts with polyglossia |
| LuaLaTeX | Same image support as XeLaTeX | Same UTF-8 and font support as XeLaTeX | No pstricks; can be extended by embedding Lua code |
If you do not need a specific feature in the table, the default engine is the sensible starting point. Journal templates sometimes assume a particular engine, so check the template’s instructions first.
Install or access (official sources)
Compile online
An online editor compiles on a server, so nothing needs installing. Overleaf is the one documented here; see what Overleaf is and collaborative LaTeX alternatives to Overleaf for other options. Overleaf lets you set the compiler and the TeX Live version per project (steps below).
Compile locally with TeX Live or MacTeX
The TeX Users Group quick-install page (tug.org/texlive/quickinstall.html, read 2026-11-08) gives these routes:
- macOS: MacTeX, the native installer, contains all of TeX Live. See MacTeX.
- Windows: follow the “TeX Live on Windows” page linked from the quick-install page. MiKTeX is a separate distribution.
- Unix/Linux: download
install-tl-unx.tar.gzfrommirror.ctan.org/systems/texlive/tlnet/, unpack it and runperl ./install-tl --no-interaction(omit the flag to choose options interactively). The install may take hours. Afterwards, prepend the TeX Live binary directory to your PATH, for example/usr/local/texlive/2026/bin/x86_64-linux.
The default installation is everything and needs more than 7 GB. --scheme=small corresponds to BasicTeX (more than 600 MB). --paper=letter changes the default paper size from A4. You also need a text editor; TeXstudio is one.
Step by step: compile a LaTeX document
Online in Overleaf
- Open the project and press Recompile to build the PDF in the preview pane.
- To change the engine, open the gear icon in the editor (or the File menu) to reach the menu, then choose Compiler in the sidebar and pick one from the Compiler dropdown.
- To change the TeX Live version, use the same menu and the TeX Live version dropdown. The choice applies to the current project only. Overleaf generally recommends the most recent version and states that legacy versions are not recommended for new projects.
Locally with latexmk
latexmk automates the build: according to its CTAN page it “issues the appropriate sequence of commands” to generate the document, so cross-references and bibliographies settle without you counting runs by hand. The options below are from the latexmk manual (version 4.88, 9 March 2026, read 2026-11-08).
- Open a terminal in the folder containing your
.texfile. - Run
latexmk -pdf main.texto generate a PDF using pdflatex. Replacemain.texwith your file name. - For XeLaTeX use
latexmk -xelatex main.tex(it produces the PDF indirectly through an xdv file). For LuaLaTeX uselatexmk -lualatex main.tex. - To keep rebuilding while you write, run
latexmk -pdf -pvc main.tex. The manual describes-pvcas continuous preview mode: compile the document, run a file previewer, then regularly check for changed source files and recompile as needed. - To start from a clean state, run
latexmk -C, which removes all regeneratable files generated by latex and bibtex or biber, plus the dvi, postscript and pdf files.
Adding -silent runs with options that reduce diagnostics, such as latex -interaction=batchmode, which is useful in scripts but hides detail when you are debugging.
Output and how to read it
A successful compile produces a PDF next to your source file (or in the preview pane in Overleaf). Check the PDF itself for missing images, unresolved references shown as question marks, and wrong fonts. Bibliography and cross-reference problems are covered in adding citations and a bibliography in Overleaf and LaTeX bibliography styles explained. If you used -silent, rerun without it for fuller diagnostics.
Troubleshooting
| Symptom | Likely cause and fix (from the documentation above) |
|---|---|
| Images fail to load | The engine does not support the image format. pdfLaTeX takes .png, .jpg and .pdf; the plain LaTeX engine only .eps and .ps. Switch the compiler or convert the images. |
| Non-Latin text or a system font will not work | Use XeLaTeX or LuaLaTeX, which support UTF-8 and TrueType/OpenType fonts. |
| A pstricks drawing fails | pstricks may not work well with pdfLaTeX on Overleaf and is not supported by LuaLaTeX; XeLaTeX supports it. |
| Compilation of .eps figures is slow | pdfLaTeX converts .eps to .pdf during compilation, which can lengthen compile time. Converting the figures to .pdf once avoids the repeated conversion. |
latexmk or pdflatex not found after a Unix install |
The TeX Live binary directory is not on your PATH; prepend it as shown in the install section. |
| Output looks stale after an edit or a failed build | Run latexmk -C to remove generated files and build again. |
| An old project behaves differently from a new one | The project may use a different TeX Live version; check the TeX Live version setting in Overleaf. |
Free alternatives: online or local
| Route | What the sources say |
|---|---|
| Overleaf (online) | Compiler and TeX Live version selectable per project; pdfLaTeX is the default. |
| TeX Live (local, all platforms) | Full default install is more than 7 GB; --scheme=small is a smaller scheme. |
| MacTeX (macOS) | Native installer that contains all of TeX Live. |
| BasicTeX (macOS) | Corresponds to --scheme=small, more than 600 MB. |
| latexmk (any local install) | Automates the build sequence; continuous preview with -pvc. |
Pricing and account terms change; check each provider’s own page.
FAQ
How do I compile LaTeX to PDF?
Online, press Recompile in Overleaf. Locally, run latexmk -pdf yourfile.tex, which builds the PDF with pdflatex.
Can I compile LaTeX online without installing anything?
Yes. Overleaf compiles on its servers and lets you choose the compiler and TeX Live version per project. Whether another online compiler requires a login is set by that service, so check its own site.
How do I compile LaTeX on a Mac?
Install MacTeX, which the TeX Users Group recommends for macOS and which contains all of TeX Live, then run latexmk -pdf yourfile.tex in Terminal or use an editor such as TeXstudio.
Which compiler should I use?
pdfLaTeX for most Latin-script documents with png, jpg or pdf images; XeLaTeX or LuaLaTeX for UTF-8 text, non-Latin scripts and system fonts; the plain LaTeX engine only when every image is .eps.
How do I keep the PDF updated while I write?
Run latexmk -pdf -pvc yourfile.tex for continuous preview, or use Overleaf’s recompile.
Sources (read 2026-11-08)
- Overleaf documentation, Selecting a TeX Live version and LaTeX compiler.
- latexmk manual, version 4.88, 9 March 2026: latexmk.pdf; CTAN package page ctan.org/pkg/latexmk.
- TeX Users Group, TeX Live quick install.







