I am struggling with building the basic pdf document for my thesis in markdown. It worked well, until I tried to add a header with \usepackage{fancyhdr}. Then it returns the error
! Undefined control sequence.
<argument> \undefinedpagestyle
I also realized there is no folder saying fancyhdr in the main miktex folder.
Here's my yaml header:
---
output:
bookdown::pdf_document2:
toc: true
toc_depth: 3
number_section: true
header-includes:
- \usepackage{float}
- \usepackage{fancyhdr}
- \usepackage[margins=raggedright]{floatrow}
- \usepackage{placeins}
- \usepackage{chngcntr}
- \counterwithin{figure}{section}
- \counterwithin{table}{section}
- \usepackage[german]{babel}
fontsize: 11pt
linestretch: 1.5
lang: de-DE
geometry: margin=2.5cm
link-citations: true
---
Here's, how I use the pagestyle in the code:
``` {r setup, include=FALSE}
library(knitr)
library(tidyverse)
opts_chunk$set(echo=FALSE)
```
\pagebreak
\pagenumbering{Roman}
\newpage
\listoffigures
\newpage
\listoftables
\newpage
\section*{Abkürzungsverzeichnis}
\pagebreak
\pagenumbering{arabic}
\pagestyle{fancy}
\fancyhead[LO,LE]{\leftmark}
\fancyfoot[CO,CE]{\thepage}
\renewcommand{\footrulewidth}{\headrulewidth}
I am quite confused about this error because my friend's file looks exactly the same regarding the fancyhdr region. He doesn't get any error.
Please help!