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.

  1. documentclass: book
  2. classoption:
  3. - twocolumn
  4. - landscape
  5. papersize: a5
  6. linestretch: 1.5
  7. fontsize: 12pt
  8. 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.,

  1. fontfamily: accanthis
  2. output:
  3. pdf_document:
  4. 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.,

  1. mainfont: Arial
  2. output:
  3. pdf_document:
  4. 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:

  1. ---
  2. output: beamer_presentation
  3. institute: "University of Hackers"
  4. ---

  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.↩︎