0

I was looking for a way to include a header in a rmarkdown PDF report. Someone suggested using fancyhdr so I included the suggested code into my .tex document (first three lines):

\usepackage{fancyhdr}
\pagestyle{fancy}
\rhead{\includegraphics[width = .05\textwidth]{Logo.png}}
\newenvironment{cols}[1][]{}{}
\newenvironment{col}[1]{\begin{minipage}{#1}\ignorespaces}{%
\end{minipage}
\ifhmode\unskip\fi
\aftergroup\useignorespacesandallpars}
\def\useignorespacesandallpars#1\ignorespaces\fi{%
#1\fi\ignorespacesandallpars}
\makeatletter
\def\ignorespacesandallpars{%
  \@ifnextchar\par
    {\expandafter\ignorespacesandallpars\@gobble}%
    {}%
}
\makeatother
\definecolor{rubblue}{RGB}{0,53,96}
\definecolor{rubgreen}{RGB}{141,174,16}

Before the download worked very well but after including these lines I get this error: Error in yaml::yaml.load(..., eval.expr = TRUE) : Parser error: while parsing a block mapping at line 5, column 5 did not find expected key at line 9, column 5 Ruft auf: ... tryCatch -> tryCatchList -> tryCatchOne ->

I think it's related to the \usepackage in the .tex document- is it possible rmarkdown can't find the fancyhdr packages and if yes how is it solved? I have TinyTex installed via tinytex. This is my .rmd's header:

---
title: "Title"
author: ""
output: 
  pdf_document:
    keep_tex: true
    includes:
      in_header: preamble.tex
urlcolor: rubblue
params:
  
  plotSAMP: "NULL"
  plotApps: "NULL"
  
#mainfont: SourceSansPro

  


---
Ninke
  • 247
  • 1
  • 12
  • I can not reproduce your error. It worked in my [rocker/verse:4.0.2](https://hub.docker.com/r/rocker/verse/) docker container. Please try to reproduce your error inside this environment. – danlooo Oct 01 '21 at 14:33
  • Yeah, I probably just didn't properly understand how LaTeX and R work together since I kinda got thrown into using it without much preparation. Thank you for your replies in any case- seems to give me a starting point. – Ninke Oct 06 '21 at 04:47

0 Answers0