Home > Software engineering >  Why my pdf r markdown headings are showing up in page header
Why my pdf r markdown headings are showing up in page header

Time:01-10

I am going include a logo in the header part of all my pdf pages.
I have a table of contents in my document as well.
Now when I add commands below I get what I want about the logo, however I also get the #headings in the header parts too. Howcan I avoid showing the heading inside header?

---
title: "my title"
output:
  pdf_document:
    latex_engine: xelatex
    toc: true 
    toc_depth: 4 
    fig_caption: true

header-includes:
  - \usepackage{fancyhdr}
  - \usepackage{multicol}
  - \usepackage{xcolor}
  - \usepackage{graphicx}
  - \usepackage{lscape}
  - \renewcommand{\familydefault}{\sfdefault}
  - \usepackage[debrief, save]{silence} 
  - \WarningFilter{fancyhdr}{\headheight is too small}
  - \WarningFilter{fancyhdr}{\footskip is too small}
  - \usepackage{floatrow}
  - \floatsetup[figure]{capposition=top}
  - \floatsetup[table]{capposition=top}
  - \usepackage{fontspec}
---
\addtolength{\headheight}{1.0cm} 
\pagestyle{fancyplain} 
\lhead{\includegraphics[height=1.2cm]{C:/Path/to/logo/mylogo.png}} 
\renewcommand{\headrulewidth}{0pt}


```{r setup, include=FALSE}
knitr::opts_chunk$set(
    echo = FALSE,
    message = FALSE,
    warning = FALSE
)
```

\newpage

# Cats

cat cat cat

\newpage

# Dogs
 dog dog dog

\newpage

enter image description here

CodePudding user response:

To remove the headers title from the header, you can use \fancyhead[RO,RE]{}.

---
title: "my title"
output:
  pdf_document:
    latex_engine: xelatex
    toc: true 
    toc_depth: 4 
    fig_caption: true

header-includes:
  - \usepackage{fancyhdr}
  - \usepackage{multicol}
  - \usepackage{xcolor}
  - \usepackage{graphicx}
  - \usepackage{lscape}
  - \renewcommand{\familydefault}{\sfdefault}
  - \usepackage[debrief, save]{silence} 
  - \WarningFilter{fancyhdr}{\headheight is too small}
  - \WarningFilter{fancyhdr}{\footskip is too small}
  - \usepackage{floatrow}
  - \floatsetup[figure]{capposition=top}
  - \floatsetup[table]{capposition=top}
  - \usepackage{fontspec}
---

\addtolength{\headheight}{1.0cm} 
\pagestyle{fancyplain} 
\lhead{\includegraphics[height=1.2cm]{posit-logo.png}}
\fancyhead[RO,RE]{}
\renewcommand{\headrulewidth}{0pt}


```{r setup, include=FALSE}
knitr::opts_chunk$set(
    echo = FALSE,
    message = FALSE,
    warning = FALSE
)
```

\newpage

# Cats

cat cat cat

\newpage

# Dogs
 dog dog dog

\newpage

  • Related