I was trying for two hours to simply change the font family to a Sans Serif font, but whatever I try it will always end up with serifs…
My setup is a Mac with Pandoc installed. I want to use markdown files to create PDFs. Within the file I setup a YAML block with my desired options. However I can not find a font installed which is Sans Serif.
I use this:
---
title: bla
fontfamily: merriweather
---
However this never works out, I get merriweather with serif font. If I try to set 'merriweathersans' it will throw the error message: "merriweathersans.sty" not installed. However with sudo tlmgr install merriweathersans I can not find this package to install anyway.
And all other Sans Serif packages I try always end in total disaster (like fontfamily: arev; this will end in a 'LaTeX Error: This NFSS system isn't set up properly.'
Best Answer
You need to specify
fontfamilyoptions: sfdefault
in your YAML header.If you were using LaTeX directly, you would have to write this line:
The part in square brackets is the package option, which you have to specify to get sans-serif text as the default. This is the case for most sans-serif font packages (look on the LaTeX Font Catalogue).
Note that the package options are not the same for every package. You can look on the Font Catalogue linked above or you can read the package documentation using the command
texdoc merriweather
in the terminal (for example).Alternative: Use system fonts with
xelatex
The above answer assumes you (or your editor) use
pdflatex
to compile to PDF. Then you have to select one of LaTeX's font packages with the proper options.If you can use
xelatex
to compile, then you can use any font installed on your system (including True-Type and Open-Type fonts that come with a TeXLive installation), without worrying about packages. Then in your YAML header you can just write this:To convert the document, now you must specify the non-default engine on the command line. You can probably set this in your editor's configuration somewhere.
If you were using
xelatex
directly (as Pandoc is now doing behind the scenes), you would include these commands:See Pandoc's documentation (
man pandoc
) for more information.