2

I have some documents in markdown that I'm trying to convert to PDF using the default latex-engine, pdflatex. This is on a CentOS 7.9.

In the markdown minimal example file, I have a yaml header which is as follows

---
title: First Last
fontfamily: sans
...

Heading
=======

For converting, I'm using

pandoc --latex-engine=pdflatex README.md -o README.pdf

The above command works without producing any errors, however, the resulting PDF has the default serif font used by Pandoc's LaTeX (Latin Modern). I'm in no way able to change from Latin Modern Roman to Computer Modern Sans Serif. I'm a bit confused as to what settings I need in the yaml header to get the desired results.

Any help would be highly appreciated

5
  • You seem to have some terminology confusion between sans serif and serif fonts. en.wikipedia.org/wiki/Sans-serif Can you please correct that in your question statement? As it stands it is very hard to understand what you intend. Actual sans serif fonts are \sffamily, not \rmfamily in LaTeX. But I am not sure what the configuration for Pandoc should be. Commented Jun 29, 2021 at 2:16
  • By saying fontfamily: sans you're telling it to set the text in sans serif. I imagine if you take that line out, you'll get the desired results.
    – Don Hosek
    Commented Jun 29, 2021 at 3:17
  • You don't need to specify the latex engine flag: pdflatex is the default, just as you say...
    – jarnowicz
    Commented Jun 29, 2021 at 3:35
  • Sorry, if I was confusing. I'm trying to achieve the below font in my PDFs. tug.org/FontCatalogue/computermodernsansserif Commented Jun 29, 2021 at 3:43
  • By saying fontfamily: sans you are asking Pandoc to load sans.sty to setup the fontfamily, but that package does not exist, afaik. In fact, I don't know why it does not throw an error.
    – jarnowicz
    Commented Jun 29, 2021 at 4:56

1 Answer 1

1

The default template for Pandoc's interface through fontfamily requires a sty file to load the relevant font information from fd files (as in, say, mathpazo.sty, for instance: so you type fontfamily: mathpazo); and the default engine is already pdflatex, so you don't need to specify it as a flag in the CLI command. So, to achieve your results you may simply say

---
title: First Last
header-includes: \renewcommand*\familydefault{\sfdefault} 
...

Heading
=======

Use \renewcommand* as above to keep Roman available elsewhere, or \let\rmdefault\sfdefault instead of \renewcommand*\familydefault{\sfdefault} if you want to override completely the Roman font.

And for converting,

pandoc README.md -o README.pdf

Beware we are not setting up Computer Modern Sans Serif strictly, but the Latin Modern Sans Serif variant, which is the default for Pandoc. You may see the differences in another page of the Catalog

You may profit from retrieving the template for LaTeX output by typing pandoc -D latex and studying the output.

5
  • 1
    Thank you! That worked beautifully Commented Jun 30, 2021 at 0:09
  • 1
    tip of the day: click the tick for the best answer, if many: you earn trust and we earn reputation (that's the way this site works: I did not design it).
    – jarnowicz
    Commented Jun 30, 2021 at 16:50
  • @jarnosz: if I follow your suggestion and set header-includes: \let\rmdefault\sfdefault\familydefault{\sfdefault} I then have an error ! LaTeX Error: Missing \begin{document}.
    – Antonello
    Commented Feb 29 at 11:08
  • I see; perhaps I did not state the instructions clearly.
    – jarnowicz
    Commented Mar 1 at 22:06
  • try again now...
    – jarnowicz
    Commented Mar 1 at 22:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .