I am creating a RMarkdown template of Beamer slides and use the metropolis theme as a basis.
This already includes:
Numbered TOC
Hiding of footer on title page
Now I want to add the footer to the section's start/title pages (the page which includes only the title of the next section in the middle of the slide). I tried to show the footer on this pages by this code snipet
- |
\makeatletter
\def\ps#sectionpage{%
\setbeamertemplate{frame footer}{\tiny{\textcolor{beaublue}{Conference 56. Jahrestagung der DGSMP, 2021 | SIMON RESS}}}
}
\addtobeamertemplate{section page}{\thispagestyle{sectionpage}}{}
\makeatother
, but it is not working.
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
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 | SIMON RESS}}}
#hide footer on title page:
- |
\makeatletter
\def\ps#titlepage{%
\setbeamertemplate{footline}{}
}
\addtobeamertemplate{title page}{\thispagestyle{titlepage}}{}
\makeatother
#show footer on section's start/title pages
- |
\makeatletter
\def\ps#sectionpage{%
\setbeamertemplate{frame footer}{\tiny{\textcolor{beaublue}{Conference 56. Jahrestagung der DGSMP, 2021 | SIMON RESS}}}
}
\addtobeamertemplate{section page}{\thispagestyle{sectionpage}}{}
\makeatother
#add secrtion numbers to TOC:
- |
\setbeamertemplate{section in toc}{
\leavevmode%
\inserttocsectionnumber.
\inserttocsection\par%
}
\setbeamertemplate{subsection in toc}{
\leavevmode\leftskip=2.5em\inserttocsubsection\par}
---
```{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)
```
The metropolis theme uses hard coded plain,c,noframenumbering for their section pages, but you can overwrite their definition like this:
---
title: "Title"
subtitle: "Subtitle"
author: "Simon"
institute: "RUB"
date: "September 22, 2021"
output:
beamer_presentation:
keep_md: true
keep_tex: true
latex_engine: xelatex
#theme: metropolis
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 | SIMON RESS}}}
#hide footer on title page:
- |
\makeatletter
\def\ps#titlepage{%
\setbeamertemplate{footline}{}
}
\addtobeamertemplate{title page}{\thispagestyle{titlepage}}{}
\makeatother
#show footer on section's start/title pages
- |
\makeatletter
\def\ps#sectionpage{%
\setbeamertemplate{frame footer}{\tiny{\textcolor{beaublue}{Conference 56. Jahrestagung der DGSMP, 2021 | SIMON RESS}}}
}
\addtobeamertemplate{section page}{\thispagestyle{sectionpage}}{}
\makeatother
#add secrtion numbers to TOC:
- |
\setbeamertemplate{section in toc}{
\leavevmode%
\inserttocsectionnumber.
\inserttocsection\par%
}
\setbeamertemplate{subsection in toc}{
\leavevmode\leftskip=2.5em\inserttocsubsection\par}
\makeatletter
\renewcommand{\metropolis#enablesectionpage}{
\AtBeginSection{
\ifbeamer#inframe
\sectionpage
\else
\frame[c]{\sectionpage}
\fi
}
}
\metropolis#enablesectionpage
\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
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
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
I'm writing my Ms thesis with R markdown, and I have a problem with the Appendix section. I need to put some tables in the appendix section but when I render it the header of the subsection appears below de table. like this:
I would like to know if there are some way to fix this.
The way I write the code is:
# Appendix {-}
## Subsection title
chunk with table
R-markdown chunk:
title: "Title of my thesis"
subtitle:
author:
- "Student :"
- "Director: "
output:
pdf_document:
number_sections: true
latex_engine: xelatex
template: NULL
word_document: default
degree: Ms Biology
field: Experimental biology
year: 2021
geometry: left=2cm,right= 2 cm,top=2 cm, bottom=2 cm
papersize: a4
header-includes:
- \usepackage{amsmath}
- \usepackage{booktabs}
- \usepackage{pdflscape}
- \usepackage[justification=raggedright,labelfont=bf,singlelinecheck=false]{caption}
- \usepackage{setspace}
bibliography: library.bib
csl: apa7.csl
fontsize: 11 pt
indent: true
spacing: 1.5
And chunk options
knitr::opts_chunk$set(
echo = FALSE,
warning = FALSE,
message = FALSE,
error =FALSE)
Well, in order to stop putting tables under de subtitle, I have to add
- \usepackage{flafter}
Then the table appears in the next page, in order to avoid that, I added
kbl(data)%>%
kable_styling(latex_options = "hold_position")
That's all.
I am trying to knit a pdf in Rmarkdown, but I receive the same error over and over again:
! LaTeX Error: Two \documentclass or \documentstyle commands.
I already different approaches like deleting some rows, putting \begin{document} in different places or changing the order of loading packages.
This is my code:
---
title: "Feedback"
author: "Me"
date: "09 02 2021"
toc: true
toc_depth: 2
toc-title: "Verzeichnis"
fig.caption: "Tabelle"
smooth_scroll: false
header-includes:
\documentclass{article}
\PassOptionsToPackage[usenames,dvipsnames]{xcolor}
\usepackage{fancyhdr}
\usepackage[T1]{fontenc}
\usepackage[default]{sourcesanspro}
\usepackage{tikz}
mainfont: SourceSansPro
output: pdf_document
---
\begin{document}
\addtolength{\headheight}{1.0cm}
\fancypagestyle{plain}{}
\thispagestyle{fancy}
\fancyhead[L]{\includegraphics[width = 500pt]{"/Users/lisak/One Drive/OneDrive/Dokumente/Masterarbeit/Erhebung/Anschreiben/alt/banner.png"}}
\renewcommand{\headrulewidth}{0pt}
{r, echo = FALSE, message = FALSE}
.onLoad <- function(libname = find.package("kableExtra"), pkgname = "kableExtra") {
if (knitr::is_latex_output()) {
load_packages <- getOption("kableExtra.latex.load_packages", default = TRUE)
if (load_packages) {
usepackage_latex("booktabs")
usepackage_latex("longtable")
usepackage_latex("array")
usepackage_latex("multirow")
usepackage_latex("wrapfig")
usepackage_latex("float")
usepackage_latex("colortbl")
usepackage_latex("pdflscape")
usepackage_latex("tabu")
usepackage_latex("threeparttable")
usepackage_latex("threeparttablex")
usepackage_latex("ulem", "normalem")
usepackage_latex("makecell")
usepackage_latex("xcolor")
}
}
auto_format <- getOption("kableExtra.auto_format", default = TRUE)
if (auto_format) auto_set_format()
if (!is.null(rmarkdown::metadata$output) &&
rmarkdown::metadata$output %in% c(
"ioslides_presentation", "slidy_presentation",
"gitbook", "bookdown::gitbook", "radix_article", "radix::radix_article",
"distill_article", "distill::distill_article"
)) {
options(kableExtra.html.bsTable = TRUE)
}
if (!is.null(knitr::opts_knit$get("rmarkdown.pandoc.to")) &&
knitr::opts_knit$get("rmarkdown.pandoc.to") %in% c("epub3", "epub")) {
options(kableExtra.knit_print.dependency = FALSE)
}
}
stuff....
\end{document}
Rmarkdown will automatically insert stuff like \documentclass{article} and \begin{document} when converting the rmarkdown document into a tex document. You must not insert it a second time
\PassOptionsToPackage[usenames,dvipsnames]{xcolor} must be used before the documentclass. As rmarkdown takes away your ability to insert the document class yourself, you can't use this
rmarkdown has trouble to correctly parse the square brackets of optional arguments. As a workaround, you can hide these commands in a separate .tex file
the syntax of your r chunk is wrong. You must surround it with backticks
---
title: "Feedback"
author: "Me"
date: "09 02 2021"
toc: true
toc_depth: 2
toc-title: "Verzeichnis"
fig.caption: "Tabelle"
smooth_scroll: false
mainfont: SourceSansPro
output:
pdf_document:
keep_tex: true
includes:
in_header: preamble.tex
---
```{r, echo = FALSE, message = FALSE}
.onLoad <- function(libname = find.package("kableExtra"), pkgname = "kableExtra") {
if (knitr::is_latex_output()) {
load_packages <- getOption("kableExtra.latex.load_packages", default = TRUE)
if (load_packages) {
usepackage_latex("booktabs")
usepackage_latex("longtable")
usepackage_latex("array")
usepackage_latex("multirow")
usepackage_latex("wrapfig")
usepackage_latex("float")
usepackage_latex("colortbl")
usepackage_latex("pdflscape")
usepackage_latex("tabu")
usepackage_latex("threeparttable")
usepackage_latex("threeparttablex")
usepackage_latex("ulem", "normalem")
usepackage_latex("makecell")
usepackage_latex("xcolor")
}
}
auto_format <- getOption("kableExtra.auto_format", default = TRUE)
if (auto_format) auto_set_format()
if (!is.null(rmarkdown::metadata$output) &&
rmarkdown::metadata$output %in% c(
"ioslides_presentation", "slidy_presentation",
"gitbook", "bookdown::gitbook", "radix_article", "radix::radix_article",
"distill_article", "distill::distill_article"
)) {
options(kableExtra.html.bsTable = TRUE)
}
if (!is.null(knitr::opts_knit$get("rmarkdown.pandoc.to")) &&
knitr::opts_knit$get("rmarkdown.pandoc.to") %in% c("epub3", "epub")) {
options(kableExtra.knit_print.dependency = FALSE)
}
}
```
stuff....
and preamble.tex:
\usepackage{fancyhdr}
\usepackage[T1]{fontenc}
\usepackage[default]{sourcesanspro}
\usepackage{tikz}
\addtolength{\headheight}{1.0cm}
\fancypagestyle{plain}{}
\thispagestyle{fancy}
\fancyhead[L]{\includegraphics[width = 500pt]{example-image}}
\renewcommand{\headrulewidth}{0pt}
building my book in R bookdown using the build tab but running into errors
I have updated my R and R Studio to the latest version
---
title: "Lessons for Africa"
subtitle:
- "By"
- "Saanuo"
author:
- "A thesis submitted to"
- "MASTER’S OF PHILOSOPHY"
- "[FINANCE]"
date: "June, 2020"
output:
bookdown::pdf_book:
includes:
in_header: preamble.tex
keep_tex: yes
latex_engine: xelatex
citation_package: none
toc: true
fig_width: 8
fig_height: 6
fig_caption: true
mainfont: Timesnewroman
fontsize: 12pt
linestretch: 1.5
toc-depth: 3
lot: True
lof: True
site: bookdown::bookdown_site
documentclass: book
bibliography: library.bib
csl: harvard-educational-review.csl
link-citations: yes
geometry: "left=4cm, right=2.5cm, top=2.5cm, bottom=2.5cm"
---
\pagenumbering{roman}
# ->Declaration<- {-}
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents.
===
# ->Dedication<- {-}
You can also embed plots, for example:
===
# ->Acknowledgement<- {-}
You can also embed plots, for example:
===
# ->Abstract<- {-}
You can also embed plots, for example:
===
# ->Abbreviations<- {-}
library(tidyverse)
library(knitr)
data_frame(
Abbreviation = c("WM", "STM", "LTM"),
Term = c("Working memory", "Short-term memory", "Long-term memory")) %>%
arrange(Abbreviation) %>%
kable(booktab = T)
I wanted to build my book by encountering this error message. Xie please this the my entire index file, as requested. Thank you for your concern. Much appreciated. Hope this helps give my clarity to my problem.
Error in yaml::yaml.load(..., eval.expr = TRUE) :
Scanner error: mapping values are not allowed in this context at line 19, column 14
Calls: <Anonymous> ... enumerate_output_formats -> yaml_load_file -> yaml_load -> <Anonymous>
Execution halted
Exited with status 1.
I want to create a single PDF document from many .Rmd child documents using pdf_document2().
I have a wrapper file pdf_wrapper.Rmd that looks as follows
---
title: "title"
author: "author"
output:
bookdown::pdf_document2:
number_sections: true
---
# Header1
```{r child = 'child1.Rmd'}
```
With child1.Rmd having the following content
---
title: "Title2"
output: rmarkdown::html_document
---
## Title 3
Now when I render pdf_wrapper.Rmd, I get the following:
# Header 1
## Title 3
I want to end up with
# Header 1
## Title 2
### Title 3
I put all level 2 headers manually in the main document pdf_wrapper.Rmd, e.g. Title2.
Additionally, I decreased all remaining headers in all child documents by one level using the following bash call:
for i in *.Rmd; do
sed -i '# /## /g' $i
done
The main document then looks as follows:
---
title: "title"
author: "author"
output:
bookdown::pdf_document2:
number_sections: true
---
# Header1
## Title2
```{r child = 'child1.Rmd'}
```
Initially I though that the <title> fields in the YAML metadata of the child documents get processed as level 1 headers but this is not the case.