Search code examples
pdflatexsizetitlequarto

How to change the title size in a Quarto PDF document


I tried to change the size of the title of a Quarto PDF document (scrartcl class) without success.

This is what I tried. Per the KOMA-script documentation section 3.6 (page 58), and as mentioned here, the commands for modifying the appearance of several elements are \setkomafont, \addtokomafont, and \usekomafont. However, section 3.7 (page 68) states:

Note that for the main title, \huge will be used after the font switching element title. So you cannot change the size of the main title using \setkomafont or \addtokomafont.

Based on the scrartcl class code, I created a patch in the preamble to change the title size (from \huge to \small to see the effect easily):

\usepackage{xpatch}
\makeatletter
  \xpatchcmd{\maketitle}{\usekomafont{title}{\huge \@title \par}}{\usekomafont{title}{\small \@title \par}}
\makeatother

Here is the problem: the patch did not work with a Quarto PDF document when added through the include-in-header option. However, this approach worked perfectly on a basic .tex file compiled through RStudio.

Something is happening inside Quarto's processing that is preventing to get the wanted effect and I have not figured it out yet. I would appreciate any help in getting the change I need either by using this approach or a better one.

Thanks,

Hector

MWE's

Quarto file

---
title: "The Title"
author: "Author"
pdf-engine: xelatex
format:
  pdf: 
    keep-tex: true
    documentclass: scrartcl
    include-in-header:
      text: |
        \usepackage{xpatch}
        \makeatletter
        \xpatchcmd{\maketitle}{\usekomafont{title}{\@title \par}}{\usekomafont{title}{\small \@title \par}}
        \makeatother
        
        \setkomafont{author}{\small}
---

## Quarto

Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see <https://quarto.org>.

Output: Quarto output pdf screenshot

LaTeX file

\documentclass[titlepage]{scrartcl}

\usepackage{xpatch}
\makeatletter
  \xpatchcmd{\maketitle}{\usekomafont{title}{\huge \@title \par}}{\usekomafont{title}{\small \@title \par}}
\makeatother

\setkomafont{author}{\small}

\title{The Title}
\authorss{Author}

\begin{document}

\maketitle

\end{document}

Output: LaTeX output pdf screenshot

Software used

  • OS: macOS (Ventura 13.5.1)
  • R v4.3.1
  • RStudio v13.5.1 (via Homebrew)
  • Quarto v1.3.450 (via Homebrew)
  • TinyTeX package v0.46
  • Document Class: scrartcl 2023/07/07 v3.41 KOMA-Script document class (article)

Solution

  • Just add the latex command for different font size before the title text.

    ---
    title: \small The Title
    author: "Author"
    pdf-engine: xelatex
    format:
      pdf: 
        keep-tex: true
        documentclass: scrartcl
        include-in-header:
          text: |
            \setkomafont{author}{\small}
    ---
    
    ## Quarto
    
    Quarto enables you to weave together content and executable code
    

    smaller title text in quarto pdf output