To produce a PDF, specify an output file with a .pdf
extension:
pandoc test.txt -o test.pdf
By default, pandoc will use LaTeX to create the PDF, which requires
that a LaTeX engine be installed (see --pdf-engine below).
Alternatively, pandoc can use ConTeXt, roff ms, or HTML as an
intermediate format. To do this, specify an output file with a
.pdf extension, as before, but add the
--pdf-engine option or -t context,
-t html, or -t ms to the command line. The
tool used to generate the PDF from the intermediate format may be
specified using --pdf-engine.
You can control the PDF style using variables, depending on the
intermediate format used: see variables for LaTeX,
variables for
ConTeXt, variables for
wkhtmltopdf, variables for ms. When
HTML is used as an intermediate format, the output can be styled using
--css.
To debug the PDF creation, it can be useful to look at the
intermediate representation: instead of -o test.pdf, use
for example -s -o test.tex to output the generated LaTeX.
You can then test it with pdflatex test.tex.
When using LaTeX, the following packages need to be available (they
are included with all recent versions of TeX Live): amsfonts, amsmath, lm, unicode-math,
iftex, listings (if the
--listings option is used), fancyvrb, longtable, booktabs, multirow (if the
document contains a table with cells that cross multiple rows), graphicx (if the
document contains images), bookmark, xcolor, soul, geometry (with the
geometry variable set), setspace (with
linestretch), and babel (with
lang). If CJKmainfont is set, xeCJK is needed if
xelatex is used, else luatexja is needed
if lualatex is used. framed is required
if code is highlighted in a scheme that use a colored background. The
use of xelatex or lualatex as the PDF engine
requires fontspec.
lualatex uses selnolig and lua-ul.
xelatex uses bidi (with the
dir variable set). If the mathspec variable is
set, xelatex will use mathspec instead
of unicode-math.
The csquotes
package will be used for typography if the
csquotes variable or metadata field is set to a true value.
The natbib, biblatex, bibtex, and biber packages can
optionally be used for citation
rendering. If math with \cancel, \bcancel,
or \xcancel is used, the cancel package is
needed. The following packages will be used to improve output quality if
present, but pandoc does not require them to be present: upquote (for
straight quotes in verbatim environments), microtype (for
better spacing adjustments), parskip (for better
inter-paragraph spaces), xurl (for better line
breaks in URLs), and footnotehyper
or footnote (to
allow footnotes in tables).