1
votes

A question about fancyhdr in R Markdown knitting to pdf. Can anyone help me to fix the header for the appendix? I have numbered sections in the document, and the fancyhead for pages with the numbered sections is oke. But for the unnumbered appendix, it keeps showing the last numbered section, where I just want the title of the current unnumbered appendix to be shown. Code example below. Thanks!

---
title: "Example"
output:
  pdf_document:
    number_sections: true
header-includes:
   - \usepackage{fancyhdr}
   - \pagestyle{fancy}
---
\newpage
# Chapter
\newpage
# Appendix {-}
1

1 Answers

1
votes

You can adjust the header like this:

---
title: "Example"
output:
  pdf_document:
    number_sections: true
header-includes:
   - \usepackage{fancyhdr}
   - \pagestyle{fancy}
---
\newpage
# Chapter
\newpage
# Appendix {-}
\markboth{something here}{something there}