Rmd: Hide FOOTER on title&content page - latex

I am creating a RMarkdown template of Beamer slides and use the metropolis theme as a basis.
Now I want to add a footer with some text on the left side and the slide number as fraction on the right side. That works. Furthermore, the whole footer should not be shown on the title & content page. How can I control where the foot line is shown?
This is my (minimal working example):
slides.rmd
---
title: "Title"
subtitle: "Subtitle"
author: "Simon"
institute: "RUB"
date: "September 22, 2021"
output:
beamer_presentation:
keep_md: true
keep_tex: no
latex_engine: xelatex
#theme: metropolis
includes:
in_header:
#- toc.tex
slide_level: 2 # which header level should be printed as slides
incremental: no
header-includes:
- \usetheme[numbering=fraction]{metropolis}
- \definecolor{beaublue}{rgb}{0.74, 0.83, 0.9}
- \setbeamertemplate{frame footer}{\tiny{\textcolor{beaublue}{Conference 56. Jahrestagung der DGSMP, 2021}}}
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
## Content
\tableofcontents[]
# Level I
Test
## Slide with Bullets
- Bullet 1
- Bullet 2
- Bullet 3
# Slide with R Output
```{r cars, echo = TRUE}
summary(cars)
```
I know that it would be possible in Latex via the begingroup & endgroup command combined with the plain-option ({}) used on \setbeamertemplate{footline}:
\documentclass{beamer}
\setbeamertemplate{footline}[frame number]
\begin{document}
\begin{frame}
normal frame
\end{frame}
\begingroup
\setbeamertemplate{footline}{}
\begin{frame}
without footline
\end{frame}
\endgroup
\begin{frame}
normal frame
\end{frame}
\end{document}
But I don't know how to implement it in RMarkdown.

To remove the footline from your title and toc page, you can use the same trick as in https://topanswers.xyz/tex?q=1004#a1198
Add the following to your header includes:
\makeatletter
\def\ps#navigation#titlepage{%
\setbeamertemplate{footline}{}
\#nameuse{ps#navigation}
}
\addtobeamertemplate{title page}{\thispagestyle{navigation#titlepage}}{}
\pretocmd{\tableofcontents}{\thispagestyle{navigation#titlepage}}{}{}
\makeatother
(please also note that the syntax \tiny{...} is wrong. This macro is a switch and does not take an argument. You can instead use {\tiny ...}
---
title: "Title"
subtitle: "Subtitle"
author: "Simon"
institute: "RUB"
date: "September 22, 2021"
output:
beamer_presentation:
keep_md: true
keep_tex: no
latex_engine: xelatex
#theme: metropolis
includes:
in_header:
#- toc.tex
slide_level: 2 # which header level should be printed as slides
incremental: no
header-includes:
- \usetheme[numbering=fraction]{metropolis}
- \definecolor{beaublue}{rgb}{0.74, 0.83, 0.9}
- \setbeamertemplate{frame footer}{{\tiny\textcolor{beaublue}{Conference 56. Jahrestagung der DGSMP, 2021}}}
- \makeatletter
- \def\ps#navigation#titlepage{\setbeamertemplate{footline}{}\#nameuse{ps#navigation}}
- \addtobeamertemplate{title page}{\thispagestyle{navigation#titlepage}}{}
- \pretocmd{\tableofcontents}{\thispagestyle{navigation#titlepage}}{}{}
- \setbeamertemplate{section in toc}{\leavevmode\inserttocsectionnumber. \inserttocsection\par}
- \makeatother
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
## Content
\tableofcontents[]
# Level I
Test
## Slide with Bullets
- Bullet 1
- Bullet 2
- Bullet 3
# Slide with R Output
```{r cars, echo = TRUE}
summary(cars)
```

Related

How to make image appear on the top of the first page in rmarkdown documents

I try to put image file (logo.png) on the top of the first page of my document. I followed the guideline from here: Insert a logo in upper right corner of R markdown pdf document. However, the image still does not appear. My code is: I still don't know what's wrong with my codes. Thanks.
---
title: 'Theory'
date: "Fall 2021"
output:
pdf_document:
keep_tex: yes
fig_caption: yes
latex_engine: pdflatex
template: Syllabus_template.tex
html_document:
df_print: paged
geometry: margin=1in
header-includes:
- \usepackage{fancyhdr}
- \usepackage{graphicx}
- \usepackage{eurosym}
- \usepackage{booktabs,xcolor}
- \pagestyle{fancy}
- \fancyhf{}
- \addtolength{\headheight}{1.0cm}
- \rhead{MainSky Stress Test Report - \today}
- \lhead{\includegraphics[width=6cm]{/Users/jj/Documents/logo.png}}
- \rfoot{Page \thepage}
- \fancypagestyle{plain}{\pagestyle{fancy}}
#Fill this in with any number of instructors. It uses a two column layout with a column break after each instructor.
# teachingassistant:
# - name: Filler
# email: filler#fill.com
# officehours: W T
# office: OfficeNumber
# sections: '301'
classroom: 'Remote (either MS Teams or Zoom)'
fontsize: 11pt
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(timeDate)
library(tibble)
library(dplyr)
library(knitr)
#This code chunk sets up a table of meeting days for the course.
#You can set days of the week for course meetings (e.g. Monday and Wednesday).
#Semester start and end dates are selected and then university holidays like spring break are specified.
You can add an image to the title page like this:
---
title: 'Theory'
date: "Fall 2021"
output:
pdf_document:
keep_tex: yes
fig_caption: yes
latex_engine: pdflatex
# template: Syllabus_template.tex
html_document:
df_print: paged
geometry: margin=1in
header-includes:
- \usepackage{graphicx}
- \usepackage{eurosym}
- \usepackage{booktabs,xcolor}
- \makeatletter\patchcmd{\#maketitle}{\begin{center}}{\begin{center}\includegraphics[width=3cm]{example-image-duck}\par}{}{}\makeatother
#Fill this in with any number of instructors. It uses a two column layout with a column break after each instructor.
# teachingassistant:
# - name: Filler
# email: filler#fill.com
# officehours: W T
# office: OfficeNumber
# sections: '301'
classroom: 'Remote (either MS Teams or Zoom)'
fontsize: 11pt
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(timeDate)
library(tibble)
library(dplyr)
library(knitr)
#This code chunk sets up a table of meeting days for the course.
#You can set days of the week for course meetings (e.g. Monday and Wednesday).
#Semester start and end dates are selected and then university holidays like spring break are specified.

How do I format a TOC in bookdown using latex?

I am using bookdown with latex styling to make a report that contains headers, footers and section formatting. When i knit the report all pages have the correct formatting except the TOC.
MWE is below. There are no headers and the default section title formatting is not applied to the contents page.
index.Rmd
---
title: "A Quick Test"
author: "Jack Jill"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
documentclass: article
description: "This is a minimal example of a report."
papersize: a4
output:
bookdown::pdf_document2:
includes:
in_header: in_header.tex
before_body: before_body.tex
toc: true
geometry: top=20mm,bottom=60mm,footnotesep=10mm,left=24mm,right=30mm
---
\newpage
# **HEADING 1**
## **Subheading**
Here is some text for the document.
# **HEADING 2**
Here is some text for the document.
# **HEADING 3**
Here is some text for the document.
in_header.tex
%Essential packages
\usepackage{graphicx, color}
\usepackage{multirow}
\usepackage[T1]{fontenc}
\usepackage{titlesec}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{etoolbox}
\usepackage{tocloft}
\definecolor{airforceblue}{rgb}{0.36, 0.54, 0.66}
\definecolor{aliceblue}{rgb}{0.94, 0.97, 1.0}
\definecolor{amber}{rgb}{1.0, 0.75, 0.0}
\definecolor{amaranth}{rgb}{0.9, 0.17, 0.31}
\definecolor{amber}{rgb}{1.0, 0.75, 0.0}
\definecolor{black}{rgb}{0, 0, 0}
% This changes all section headings
\titleformat*{\section}{\bfseries\Large\itshape}
\titleformat*{\section}{\color{airforceblue}}
% Turn off default title page so I can make my own
\let\oldmaketitle\maketitle
\AtBeginDocument{\let\maketitle\relax}
before_body.tex
\pagestyle{fancy}
\fancyhead{}
\fancyhf{}
% Page layout
\parindent 0pt
\parskip 0pt
% Make custom page numbers
\cfoot{Page \thepage \hspace{1pt} of \pageref{LastPage}}
% Make a pretty header for every page
\fancyhead[L]{\includegraphics[width=3.5cm]{logo.png}}
\fancyhead[R]{\raisebox{1.6cm}{\color{amaranth}www.website.com.au}}
% Make the title page here
\setlength\headheight{68pt}
\vspace*{2.5cm}
\fontsize{36pt}{42pt}\selectfont\bfseries\color{airforceblue}
MY REPORT TITLE
\vspace*{0.5cm}
\color{airforceblue}
{\bfseries\huge{ SUBTITLE } }
\vspace*{1.0cm}
\colorbox{amber}{\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\bfseries\huge\strut\textcolor{aliceblue}{ AUTHOR NAME } }}
% replace default title page with my new one
\let\maketitle\oldmaketitle
% end page
\clearpage
% Set default fonts for doc
\fontsize{10}{12}\selectfont
\fontfamily{qcr}\selectfont
\setlength{\headheight}{98pt}
\color{black}
% Manually adding TOC does not add header either
% \tableofcontents
% \addcontentsline{toc}{section}{\contentsname}
The toc page uses the plain page style. If your version of the fancyhdr package is reasonable new, you can change the plain page style to be the same as your fancy page style with the simple command
\fancypagestyle{plain}[fancy]{}
---
title: "A Quick Test"
author: "Jack Jill"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
documentclass: article
description: "This is a minimal example of a report."
papersize: a4
output:
bookdown::pdf_document2:
toc: true
toc_depth: 2
keep_tex: true
includes:
in_header: in_header.tex
before_body: before_body.tex
header-includes: \fancypagestyle{plain}[fancy]{}
geometry: top=20mm,bottom=60mm,footnotesep=10mm,left=24mm,right=30mm
---
\newpage
# **HEADING 1**
## **Subheading**
Here is some text for the document.
# **HEADING 2**
Here is some text for the document.
# **HEADING 3**
Here is some text for the document.

Fancyhead for unnumbered appendix in R Markdown knit to pdf

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 {-}
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}

Include after_body in toc with bookdown

I am creating a pdf book, and want to include the after_body header in the toc. I use the following yaml:
---
author: "name"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
geometry: "left=4cm,right=3cm,top=3cm,bottom=3cm"
subparagraph: true
output:
bookdown::pdf_book:
toc: false
citation_package: natbib
includes:
before_body: frontpage.tex
after_body: after_body.tex
in_header: preamble.tex
fontsize: 11pt
linestretch: 1.2
documentclass: book
bibliography: [packages.bib, library.bib]
biblio-style: apalike
link-citations: yes
---
In the after_body.tex i have the following:
\backmatter
\begin{titlepage}
\LARGE
\textbf{Enclosed articles I - III}
\end{titlepage}
How do I include the "Enclosed articles I - III" in the toc? I create the toc with \tableofcontents before \mainmatter in the index.Rmd file.
Edit: I also noticed that bookdown creates an empty page with a page number after the \titlepage latex environment. This also happens in the frontpage.tex. Is there any way to remove the numbers on these pages?
I managed to do this by changing the \textbf to \chapter, and include this in the preamble.tex:
\usepackage{fancyhdr}
\pagestyle{fancy}
\setlength{\headheight}{13.6pt} % as requested by fancyhdr's warning
\renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}}
\makeatletter
\renewcommand{\chaptermark}[1]{%
\if#mainmatter
\markboth{Chapter \thechapter{}: #1}{}%
\else
\markboth{#1}{}%
\fi
}
As taken from this post

page numbers in beamer output from R markdown

I am trying to add page numbers to my beamer presentation. I am using the following code in Rmarkdown (see below). The problem is that the page numbers are cut off. I have tried using geometry to adjust the dimensions but i keep getting an error message that they are incompatible. Does anyone have any ideas? I have spent hours searching for a solution.
---
title: my title
author: "me"
date: "May 05, 2016"
output: beamer_presentation
header-includes:
- \usepackage{fancyhdr}
- \pagestyle{fancy}
- \fancyhead{}
- \fancyfoot{}
- \fancyfoot[R]{\thepage}
- \setbeamertemplate{footline}{\thepage}
---
Global Options
=======================================================
```{r global_options, include=FALSE}
# Setting up your workspace for standard figure output and exclusion of chunk codes, warnings, and messages unless otherwise specified:
knitr::opts_chunk$set(fig.width=6, fig.height=4,
fig.path='Figs/',
fig.show='asis', include=FALSE, warning=FALSE, message=FALSE)
```
```{r}
library(knitr)
```
```{r cars, include=TRUE, echo=FALSE}
summary(cars)
```
# Including Plots
```{r pressure, echo=FALSE, include=TRUE}
plot(pressure)
```
As #Werner already said, you should not use fancyhdr with beamer, because beamer has its own mechanism for head and footline.
The easiest way to add page numbers to a beamer presentation is to use one of the predefined templates, e.g. \setbeamertemplate{footline}[frame number]:
---
title: my title
author: "me"
date: "May 05, 2016"
output:
beamer_presentation:
keep_tex: true
header-includes:
- \setbeamertemplate{footline}[frame number]
---
Global Options
=======================================================
```{r global_options, include=FALSE}
# Setting up your workspace for standard figure output and exclusion of chunk codes, warnings, and messages unless otherwise specified:
knitr::opts_chunk$set(fig.width=6, fig.height=4,
fig.path='Figs/',
fig.show='asis', include=FALSE, warning=FALSE, message=FALSE)
```
```{r}
library(knitr)
```
```{r cars, include=TRUE, echo=FALSE}
summary(cars)
```
# Including Plots
```{r pressure, echo=FALSE, include=TRUE}
plot(pressure)
```

Resources