TransWikia.com

Leave Header Blank Fancyhdr

TeX - LaTeX Asked by VickiB on September 2, 2021

I am new to coding and Latex so please forgive me as I’m sure this is a very straight forward solution. I am creating a PDF report using RMarkdown with a .tex file to control the header, margins, and page type.

I have managed to create a base header that I will continue to tweak more to my liking but I need to be able to turn the header off for the 2nd page of the report and then turn it back on for the 3rd page. I have a flextable that is too large with the header to fit on the 2nd page but fits without it.

I have read many questions where they are asking about the 1st page but I haven’t been able to tweak those answers to solve my problem. I have read the fancyhdr vignette and I’m sure the answer is in there but everything I tried did not work. Most turned the header off on the first page and didn’t touch the second. Do I need to put the code directly into the .rmd?

YAML header for my RMarkdown file:

---
title: "Team Report"
classoption: landscape
output:
  pdf_document:
    includes:
      in_header: "preamble.tex"

---

preamble.tex file

usepackage{fancyhdr}
usepackage{etoolbox}
usepackage{color}
usepackage{geometry}

 geometry{a4paper, landscape, left = 13mm, right = 5mm, top = 5mm, bottom = 13mm, head = 44pt, includeheadfoot}
  headsep = 2mm



AtBeginDocument{letmaketitlerelax}
pagestyle{fancyplain}
definecolor{col1}{RGB}{210, 35, 42}
fancyhead[L]{colorbox{col1}{{color{white}{largetextbf{July 2020}}}}}
fancyhead[CO,CE]{Hugetextbf{Team Report Template}}
rhead{includegraphics[height=1.2cm]{Team_logo.png}} % right logo
renewcommand{headrulewidth}{4pt}

One Answer

R markdown can use LaTeX commands directly, so simply add thispagestyle{empty} in the second page.

The command just before or after the R chunk could be enough, but to be sure will be not load before the first page break nor after the second page break, place it just before a newpage: I

---
title: "Team Report"
classoption: landscape
output:
  pdf_document:
    includes:
      in_header: "preamble.tex"

---

(first page contents)

newpage 
thispagestyle{empty}


 
```{r}
# R chunk of the second page 
```

Alternatively, you can also load the afterpage package and place afterpage{thispagestyle{empty}} somewhere in the first page.

Answered by Fran on September 2, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP