2

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!

shafee
  • 15,566
  • 3
  • 19
  • 47
MartineJ
  • 591
  • 5
  • 16

2 Answers2

5

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.

shafee
  • 15,566
  • 3
  • 19
  • 47
2

You are not that far away from the solution. If you want to use fancyhdr, this could work (note that you need to add text: | in order to have multiple lines of latex code):

---
format: 
  pdf:
    include-in-header: 
      text: |
        \usepackage{fancyhdr}
        \pagestyle{fancy}
        \fancyhead[C]{Header text}
        \fancyfoot[L]{Footer text}
---

# Chapter ONE

text
\newpage

# Chapter TWO

enter image description here

Julian
  • 6,586
  • 2
  • 9
  • 33