Wandmalfarbe / pandoc-latex-template

A pandoc LaTeX template to convert markdown files to PDF or LaTeX.
BSD 3-Clause "New" or "Revised" License
6.22k stars 968 forks source link

Title and section heading fonts #161

Closed microraptor closed 4 years ago

microraptor commented 4 years ago

Changing the font with Xelatex and the "mainfont" variable in the metadata works only for the body font, the title and section headings are turned into "LM Sans", which is a default font I guess. Even when setting "Source Sans Pro" using "mainfont", "LM Sans" is used except for the body text. The same issues occurs also when I replace sourcesanspro with a different font package in the template without setting anything in the metadata and using pdflatex as an engine. What makes "Source Sans Pro" so special that it is the only font I can use for the title and headings and is this a common issue or just me?

Here are some examples I tried without success with multiple different sans and serif fonts like "EB Garamond" and Roboto:

mainfont: "Source Serif Pro"

mainfont: "Source Sans Pro"

mainfont: "SourceSerifPro-Regular"
mainfontoptions: "Scale=1.0"

mainfont: "Source Serif Pro"
header-includes: |
    \usepackage{sourceserifpro}

And switching \usepackage[default]{sourcesanspro} with \usepackage[default]{sourceserifpro} on both counts in the template.

This is the only way to set the title font, but only works with sourcesanspro, so its not helpful at all:

mainfont: "Source Sans Pro"
header-includes: |
    \usepackage{sourcesanspro}

I am running Ubuntu 18.04 and with texlive-fonts-recommended texlive-fonts-extra installed and the relevant Latex font packages installed.

ecto commented 4 years ago

i got this working by setting sansfont for the headings

microraptor commented 4 years ago

Thank you, it works when you pair mainfont and sansfont.

To summarize the behavior: When using this template with --pdf-engine xelatex the body font can be set with the mainfont metadata variable and the heading font with sansfont. For monofont sections like the code blocks the font can be changed with monofont. Presumably it works similar with mathfont. Setting only mainfont will reset the heading font to the default "LM Sans" and setting only sansfont seems to have no effect.

See https://pandoc.org/MANUAL.html#variables-for-latex