Search code examples
pdflatexpandocquarto

Change Title/Headings Font in Quarto PDF Output


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.


Solution

  • 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.
    

    Using the default fonts for title/heading in quarto pdf document


    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.