Dennis Yi Tenen Ø about books notes projects publications service talks teaching

Pandoc with Xelatex

A few notes after spending a some time battling with Pandoc, YAML, and the Xelatex typesetting engine:

  1. Theoretically it is easier to specify fontsize in the YAML block instead of in the command line. You don’t have to retype it each time and you can better version control your attributes.

  2. For book projects, where your YAML headers are reused, separate the YAML block into its own file. Then pass both sources to concatenate. Something like pandoc -s metadata.yaml chapter1.md -o chapter1.pdf.

  3. Use the --latex-engine=xelatex option to work with languages other than English. Make sure your tex editor supports the UTF-8 encoding.

  4. However, when you use the Xelatex engine, the YAML attribute to change default fonts switches from fontfamily: to mainfont:. Doh! It was in the docs. man pandoc for more.

  5. When specifying the main font, put the font name in quotations like so: mainfont: "Day Roman".

  6. You can find the LATEX font names in the excellent Latex Font Catalog. Use the full name as shown above.

  7. Long pandoc incantations are slightly tedious to type out. Use a shell script to automate. You can find the one I use here. Note that it expects you to pass a few arguments (everything is in the comments).

  8. If none of this makes sense to you, read this first.

Hopefully these notes can save you a few moments of frustration.

made w/ vim + markdown + jekyll + tachyons + github pages CC BY-SA 2024