Duplicated title page in r-markdown beamer presentation - latex

Im trying to include a title page customized in latex in my r markdown beamer presentation, but im getting two title pages in the output: one generated by R markdown and another one generated by the latex code that I included in the before-body option of the YAML header.
Is there any way to prevent r markdown from generating a title page so that I only get my personalized title page in the output?
Here is a MWE:
---
author: my-name
title: my-title
date: "`r format(Sys.time(), '%d %B %Y')`"
output:
beamer_presentation:
includes:
before_body: title-page.tex
---
## First frame
- some content
## Second frame
- some content
Contents of title-page.tex:
\begin{frame}[plain]
\inserttitle
\insertauthor
\insertdate
\end{frame}
I already tried adding \AtBeginDocument{\let\maketitle\relax} to a file included in_header but I still got two title pages.

Instead of manually creating your title page, you can simply modify the frame title template:
---
author: my-name
title: my-title
date: "`r format(Sys.time(), '%d %B %Y')`"
output:
beamer_presentation:
keep_tex: true
header-includes: |
\setbeamertemplate{title page}{
\inserttitle
\insertauthor
\insertdate
}
---
## First frame
- some content
## Second frame
- some content

Related

Include by \input an header-includes: preamble in a markdown file

I have plenty of markdown files starting with a rather long header-includes, followed by some included directives:
---
header-includes:
- \usepackage{fvextra}
- \usepackage{tcolorbox}
- \DefineVerbatimEnvironment{Highlighting}{Verbatim}{breaklines,breakanywhere,breaksymbol=,breakanywheresymbolpre=,commandchars=\\\{\}}
- \usepackage[margins=raggedright]{floatrow}
title: "Mathématiques \n55. Les dérivées"
subtitle: ""
author: Marc Le Bihan
geometry: margin=2cm
fontsize: 12pt
output: pdf
classoption: fleqn
urlcolor: blue
---
\input{apprentissage-include}
where apprentissage-include.tex has such definitions:
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{breaklines,breakanywhere,breaksymbol=,breakanywheresymbolpre=,commandchars=\\\{\}}
\newcommand{\donnee}[1]{\textbf{\textcolor{Purple}{#1}}}
\newcommand{\definition}[1]{\textbf{\textcolor{blue}{#1}}}
[...]
I would like to include the header-includes preamble too, to change its content more easily when updates are needed.
I've created an header-include.tex containing:
---
header-includes:
- \usepackage{fvextra}
[...]
---
But whatever I've tried :
\input{header-include}
\input{apprentissage-include}
or
---
\input{header-include}
---
\input{apprentissage-include}
I'm receiving the message :
! LaTeX Error: Can be used only in preamble.
Do I have a way to succeed?
As you are loading packages in the header-include.tex file it needs to go into the header. To get access to the latex syntax of \input{...}, you have to put it into the header includes:
markdown file:
---
output:
pdf_document:
keep_tex: true
header-includes:
- \input{header-include}
- \input{apprentissage-include}
title: "Mathématiques \n55. Les dérivées"
subtitle: ""
author: Marc Le Bihan
geometry: margin=2cm
fontsize: 12pt
classoption: fleqn
urlcolor: blue
---
test
The header-include.tex file needs to use latex syntax, so no - or any other markdown syntax
header-include.tex:
\usepackage{fvextra}
The apprentissage-include.tex file is the same as in your question
apprentissage-include.tex
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{breaklines,breakanywhere,breaksymbol=,breakanywheresymbolpre=,commandchars=\\\{\}}
\newcommand{\donnee}[1]{\textbf{\textcolor{Purple}{#1}}}
\newcommand{\definition}[1]{\textbf{\textcolor{blue}{#1}}}

Removing page numbers from PDF created using knitr from a moderncv template

This question covers R Studio, pandoc and also LaTeX I suppose. The following is what my YAML looks like in R Studio:
---
name: Me Me Me
surname: Myself
position: "Job seeker"
address: "Some address in Newfoundland"
phone: +1 800 111111
www: google.com
email: "myemail#yahoo.com"
linkedin: john-joseph-jingle-jabber-smith/123
date: "`r format(Sys.time(), '%B %Y')`"
output: vitae::moderncv
theme: classic
---
In the footer, the page number is displayed. People with a similar problem have fixed this by changing the LaTeX preamble, but I have no such file, instead I have a collection of one .cls and several .sty files. Which of these would I need to change in order to suppress page numbering? Or is it possible to add pandoc args for this in the preamble?
moderncv has the \nopagenumbers macro to switch off page numbers:
---
name: Me Me Me
surname: Myself
position: "Job seeker"
address: "Some address in Newfoundland"
phone: +1 800 111111
www: google.com
email: "myemail#yahoo.com"
linkedin: john-joseph-jingle-jabber-smith/123
date: "`r format(Sys.time(), '%B %Y')`"
output:
vitae::moderncv:
keep_tex: true
header-includes:
- \nopagenumbers
theme: classic
---
test
\clearpage
test

Repeat Title and Date R Markdown PDF

I am struggling what what is likely a trivial markdown matter. I am hoping to avoid YAML and additional header templates and such if I can. So my question is straightforward and I welcome your feedback. For an R Markdown knitted as a PDF, how can I repeat the title and date on each printed page?
Alternatively I am happy to use headers using the '#' syntax. But if I can use the title parameters that would be preferred.
The Header thus far:
---
title: "Dashboard"
date: '`r paste(Sys.Date(), " to ", Sys.Date()+14)`'
output:
pdf_document:
latex_engine: xelatex
mainfont: Calibri
geometry: margin=1cm
classoption: landscape
params:
set_title: !r test_title
header-includes:
- \usepackage{titling}
- \pretitle{\begin{flushleft}\huge}
- \posttitle{\end{flushleft}}
- \preauthor{\begin{flushleft}}
- \postauthor{\end{flushleft}}
- \predate{\begin{flushleft}\large}
- \postdate{\end{flushleft}}
---
From the rmarkdown cookbook:
When a Rmd document is compiled, all of its metadata in the YAML section
will be stored in the list object rmarkdown::metadata. You can use this object
in your R code. For example, rmarkdown::metadata$title gives you the title
of the document.

Remove table of contents from a R bookdown to pdf_book or pdf_document2

I compiling a short document using bookdown in Rstudio. I would simply like to drop the table of contents at the beginning of the document. I could "knit to pdf" instead of "knit to pdf_book" or "knit to pdf_document2", but then would loose a lot of the bookdown functions (cross references etc.).
Should be fairly easy, isn't it?
---
title: "MWE"
output:
bookdown::pdf_book:
toc: false
---
It also works with pdf_document2:
---
title: "MWE"
output:
bookdown::pdf_document2:
toc: false
---

How can I use latex packages in R markdown beamer?

I want to include latex packages in R markdown pdf and beamer.
Could you help me in including usepackage command in rmarkdown beamer file?
Thanks a lot.
A simple solution would be to have your header setup like this:
---
title: "Document title"
author: "Author's name"
date: "Document date"
output: beamer_presentation
header-includes:
- \usepackage[brazil]{babel}
- \usepackage{graphicx}
- \usepackage[a4paper]{geometry}
---
The YAML header of the Rmd would look like:
---
title: "Habits"
output:
pdf_document:
includes:
in_header: header.tex
---
Then, in the file header.tex, include any usepackage statements you need, eg. \usepackage{pdflscape}
See http://rmarkdown.rstudio.com/pdf_document_format.html for more information.

Resources