Reputation: 93
When RMarkdown .rmd
documents are knitted as PDF, the text body as well as the title, subtitle and headings are rendered in the same LaTeX standard font.
When rendering a Quarto .qmd
document as PDF, the font for the text body remains the same, but the title, subtitle and headings are rendered in a different font, without serifs.
To achieve consistency between the outputs of older R Markdown documents and newer Quarto documents, I would like to change the font for the title, subtitle and headings back to the normal font. How can I achieve this?
I tried using fontfamily:
in the YAML header, but this did not find the fonts I wanted. I had some success by using \setkomafont{section}{\normalfont}
in include-in-header:
, as this did change the font, but only for h1 headings, not for h2 nor for the title or subtitle. It also removed all other formatting for h1 (e.g. fontsize, bold, etc.), which is not what I want.
Upvotes: 9
Views: 6106
Reputation: 22659
If the font used in the body is known, then you can set the font used in title and headings with sansfont: ...
. It's wise to also set mainfont
to make sure they are the same.
The default font used is Latin Modern Roman
, so adding this to the YAML frontmatter should do it:
---
mainfont: Latin Modern Roman
sansfont: Latin Modern Roman
---
Upvotes: 9
Reputation: 20047
Using this answer from Tex StackExchange we can do this in quarto easily.
---
title: "Fonts"
subtitle: "Changing fonts of title, subtitle back to normal font"
author: "None"
format:
pdf:
include-in-header:
text: |
\addtokomafont{disposition}{\rmfamily}
---
## Quarto
Quarto enables you to weave together content and executable code into a
finished document. To learn more about Quarto see <https://quarto.org>.
## Running Code
When you click the **Render** button a document will be generated that includes
both content and the output of embedded code.
And of course, check the section 3.6 - Text Markup of KOMA-Script manual, which provides a very detailed list of elements (like author
, chapter
, title
, subtitle
, date
, etc.) for whose such changes can be done.
Upvotes: 11