Skip to main content
v2026.11,858 entries · CC-BY 4.0
LAC HealthMedical Supply Distributor100,000+ medical supplies. 48-hour critical dispatch.Ships from 8 regional U.S. hubs. Net-30 terms for verified institutional accounts.Shop lac.us CodeCASRAIlac.us

How to Compile LaTeX: Online, Locally, and with latexmk

Compile LaTeX to PDF online in Overleaf or locally with latexmk, with an engine table for images, fonts and pstricks.

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.gz from mirror.ctan.org/systems/texlive/tlnet/, unpack it and run perl ./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

  1. Open the project and press Recompile to build the PDF in the preview pane.
  2. 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.
  3. 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).

  1. Open a terminal in the folder containing your .tex file.
  2. Run latexmk -pdf main.tex to generate a PDF using pdflatex. Replace main.tex with your file name.
  3. For XeLaTeX use latexmk -xelatex main.tex (it produces the PDF indirectly through an xdv file). For LuaLaTeX use latexmk -lualatex main.tex.
  4. To keep rebuilding while you write, run latexmk -pdf -pvc main.tex. The manual describes -pvc as continuous preview mode: compile the document, run a file previewer, then regularly check for changed source files and recompile as needed.
  5. 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)

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about How to Compile LaTeX: Online, Locally, and with latexmk

Ask your first 2 questions free below. Subscribers get 150 a day for $29 a month.

An AI assistant specialized in research administration. It cites the sources behind every answer, labels web answers and says when it can't answer.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays free to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →