rpdflatexquarto

Header and footer in quarto qmd to pdf


Anyone a suggestion how to set the header and footer of a #quarto .qmd #rstats pdf? I tried this, but no footer shows:

---
title: "Untitled"
format: 
  pdf:
    include-in-header: 
      text: 
        \usepackage{fancyhdr}
---
\fancyfoot[L]{Footer text}
# Chapter ONE
text
\newpage
# Chapter TWO

Can I use fancyhdr? If yes, how? If not, what then? Thanks!


Solution

  • Yes, It is possible to use fancyhdr (see the answer by @Julian).

    But also keep in mind that, Quarto uses KOMA-Script classes (scrartcl by default) and KOMA-Script suggests using scrlayer-scrpage latex package for handling header and footers instead of fancyhdr. See the manual chapter 05, p. 253.

    ---
    title: "Untitled"
    format: 
      pdf:
        include-in-header: 
          text: |
            \usepackage{scrlayer-scrpage}
            \rohead{Header text}
            \lofoot{Footer text}
    ---
    
    # Chapter ONE
    
    text
    
    \newpage
    
    # Chapter TWO
    

    You may also want to go through this question and the corresponding answer on Tex StackExchange.