pdflatex
Compile LaTeX documents into PDF format
TLDR
Compile a PDF document
Compile a PDF document specifying an output directory
Compile a PDF document, exiting on each error
SYNOPSIS
pdflatex [options] file
PARAMETERS
-output-directory=dir
Write all output files (PDF, log, aux, etc.) to the specified dir.
-jobname=name
Use name for the base name of output files instead of the input file's name.
-interaction=mode
Set the interaction mode (e.g., batchmode, nonstopmode, scrollmode, errorstopmode) which controls how the program handles errors and user input.
-halt-on-error
Exit with an error code immediately upon encountering the first error during compilation.
-file-line-error
Print error messages in the format filename:linenumber:error_description, making it easier to locate issues.
-shell-escape
Enable the \write18{...} primitive, allowing LaTeX to execute arbitrary shell commands. Use with extreme caution due to security implications.
-version
Print the pdflatex version information and exit.
-help
Display a help message with command-line options and exit.
DESCRIPTION
pdflatex is the primary program for typesetting TeX and LaTeX source files directly into the Portable Document Format (PDF). It is an integral part of modern TeX distributions like TeX Live and MiKTeX, offering a streamlined workflow compared to the traditional DVI-to-PS-to-PDF toolchain (e.g., latex -> dvips -> ps2pdf).
It processes .tex files, resolves cross-references, generates tables of contents, and incorporates figures and other elements, ultimately producing a .pdf output file. One of its key advantages is the direct embedding of fonts and graphics, leading to highly portable and visually consistent documents across different platforms.
While pdflatex is powerful, it often requires multiple compilation passes to resolve all internal references correctly. It also handles image formats like PNG and JPG natively, but traditionally requires PostScript images (EPS) to be converted (e.g., using epstopdf) before inclusion. Its direct PDF output capabilities make it the preferred choice for most modern LaTeX document production.
CAVEATS
Multiple Passes: For documents with cross-references, bibliographies, or tables of contents, pdflatex often requires multiple compilation passes (e.g., 2-3 times) to resolve all internal references correctly.
Image Formats: While pdflatex natively supports raster images (PNG, JPG) and vector images (PDF), it does not directly embed PostScript (EPS) files. These typically need conversion to PDF first, often using utilities like epstopdf.
Security (-shell-escape): Enabling -shell-escape (or -enable-write18) allows arbitrary commands to be executed on your system via \write18{...} in the TeX source. This poses a significant security risk if compiling untrusted documents. It should be used with extreme caution and only for trusted sources.
TYPICAL COMPILATION WORKFLOW
To compile a document named mydoc.tex, you typically run: pdflatex mydoc.tex.
After the first run, .aux, .log, and potentially .toc, .lof, .lot files are generated. To resolve all internal references (like table of contents, citations, cross-references), it's often necessary to run pdflatex mydoc.tex at least one or two more times.
For documents with bibliographies, you might run bibtex mydoc between pdflatex runs.
Many users employ build tools like latexmk or arara to automate these multiple passes and tool invocations, streamlining the compilation process.
HISTORY
pdflatex emerged as a significant evolution of the original latex engine (which primarily produced DVI output) to directly generate PDF files. This development was driven by the increasing prevalence of PDF as a universal document exchange format and the desire for a simpler, integrated workflow.
It became a standard component of modern TeX distributions, significantly simplifying the process of creating high-quality PDF documents from LaTeX source. By directly producing PDF, it eliminated the need for separate DVI-to-PostScript and PostScript-to-PDF conversion steps, making it the de-facto standard for LaTeX compilation in many contemporary setups.