6.2 Pandoc options for LaTeX output

If you are using the default Pandoc template for LaTeX output, there are several options that you may set to adjust the appearance of the PDF output document. We list a few example options below, and you may see https://pandoc.org/MANUAL.html#variables-for-latex for a full list.

documentclass: book
  - twocolumn
  - landscape
papersize: a5
linestretch: 1.5
fontsize: 12pt
links-as-notes: true

The meanings of these options should be clear if you have some knowledge about LaTeX. The documentclass option sets the document class, e.g., article, book, and report, etc. The classoption is a list of options to be passed to the document class, e.g., you can create a two-column document with the twocolumn option,9 or the landscape layout with the landscape option (the default is the portrait layout). The papersize option sets the paper size, e.g., a4, paper, or a5. The linestretch option sets the line spacing. The fontsize option sets the font size, e.g., 10pt, 11pt, or 12pt. The links-as-notes option turns links in text to footnotes, which is useful when the PDF is printed on paper, because readers will not be able to click the links on paper but can see the URLs in footnotes.

Changing fonts can be a little trickier. It depends on which LaTeX engine you are using. If you are using pdflatex, which is usually the default engine for most LaTeX-based output formats, you may use the fontfamily option to select a LaTeX font package to be loaded in your document to change the font, e.g.,

fontfamily: accanthis
    latex_engine: pdflatex

Then the document will use the font Accanthis. You may see https://tug.org/FontCatalogue/ for a list of many other LaTeX font packages. If your LaTeX distribution is TinyTeX and the required font packages have not been installed, they should be automatically installed when the document is compiled (see Section 1.2).

If you use the LaTeX engine xelatex or lualatex, you will be able to select fonts that are available on your local computer, and do not have to install additional LaTeX packages. YAML options like mainfont, sansfont, and monofont can be used to specify the main font, sans serif font, and typewriter font, respectively, e.g.,

mainfont: Arial
    latex_engine: xelatex

You can also use some of those LaTeX options when you generate Beamer slides, because a Beamer document is a LaTeX document, too. In addition, Pandoc has provided a few more options for Beamer slides, which can be found at https://pandoc.org/MANUAL.html#variables-for-beamer-slides. For example, you can specify the author affiliation via the institute option:

output: beamer_presentation
institute: "University of Hackers"

  1. This option changes the layout of the whole document, but if you want to switch back to the one-column mode from a certain point, you may insert a command \onecolumn at that point. If you want to continue the two-column mode, insert \twocolumn.↩︎