R Markdown Colored Background - latex

I have reproduced a simple example of an R Markdown presentation. Basically, I want to achieve a colored page that overlays both the headline and the footline. At the moment, only the headline is overlayed. The approach with a preamble in a tex file is needed in my full example. "Red.jpg" is simply a red image. There may be a better approach to achieve this. The reproducible code is as follows:
---
title: "Untitled"
author: "Author"
date: "21 6 2021"
output:
beamer_presentation:
includes:
in_header: preamble.tex
---
---
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.center) {\includegraphics[width=\paperwidth]{red.jpg}};
\end{tikzpicture}
The code for the preamble is as follows:
\usepackage{tikz}
\setbeamertemplate{headline}{My Title}
\setbeamertemplate{footline}{Author \hfill \insertframenumber}
This really represents a simple MWE, without borthering about spacing of footline etc.
The current result is as follows:

You can use a plain frame without head- or footline:
---
title: "Untitled"
author: "Author"
date: "21 6 2021"
output:
beamer_presentation
header-includes:
- \usepackage{tikz}
- \setbeamertemplate{headline}{My Title}
- \setbeamertemplate{footline}{Author \hfill \insertframenumber}
---
---
# {.plain}
\begin{tikzpicture}[remember picture,overlay]
\fill[red] (current page.south west) rectangle (current page.north east);
\end{tikzpicture}

Related

Tikz node won't apply left (nor right) alignment

I have been struggling with this issue for a while. I want to insert a title on a white box on top of a background image for a report cover, and everything is coming up great with the exception of the title alignment. It is centered and I want to make it left aligned, but so far none of the options I have tried have worked.
So far, this is what I got:
\usepackage{tikz}
\usepackage{makecell}
\begin{titlepage}
\setlength{\parindent}{0pt}
\begin{figure}
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.center) {\includegraphics[scale=0.2]{example-image-10x16}};
\node[fill=white, scale=2, text=red, text width=94mm, align=left] at ([xshift=7mm,yshift=30mm]current page.center) {\makecell{\textbf{The title goes here and it is very}\\\textbf{long so it covers two lines}\\\Xhline{2\arrayrulewidth}\\[-18pt]\scalebox{.35}{\textbf{\fontfamily{phv}\selectfont DEPARTMENT OF SOME ENGINEERING DISCIPLINE $\vert$ MY UNIVERSITY}}\\[-7pt]\scalebox{.35}{\textbf{\fontfamily{phv}\selectfont MY NAME HERE $\vert$ NAME OF PROGRAM}}}};
\end{tikzpicture}
\end{figure}
\end{titlepage}
I have tried raggedright options with the \usepackage{ragged2e} and the \begin{flushleft}\end{flushleft} approach with different variations but I don't seem to make it align to the left or even to the right.
Cheers!
I would avoid all this messing with \makecell and whatnot. Instead use a simple minipage:
\documentclass{article}
\usepackage{tikz}
\usepackage{makecell}
\begin{document}
\begin{titlepage}
\setlength{\parindent}{0pt}
\begin{figure}
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.center) {\includegraphics[scale=0.2]{example-image-10x16}};
\node[
fill=white,
text=red,
text width=92mm,
font=\bfseries
] at ([yshift=30mm]current page.center) {
\begin{minipage}{\linewidth}
\LARGE The title goes here and it is very
long so it covers two lines
\vskip-0.5cm
\rule{\textwidth}{1pt}
\vskip0.1cm
\scriptsize\fontfamily{phv}\selectfont DEPARTMENT OF SOME ENGINEERING DISCIPLINE $\vert$ MY UNIVERSITY
NAME HERE $\vert$ NAME OF PROGRAM
\end{minipage}};
\end{tikzpicture}
\end{figure}
\end{titlepage}
\end{document}

Body text after latex title page not showing, Rmarkdown

I have successfully been able to add a latex title page to my Rmarkdown file, but the rest of the document doesn't appear. Here is my YAML:
---
output:
pdf_document:
includes:
in_header: title.tex
---
I haven't changed anything else in the Rmarkdown file, it has the standard text starting with: This is an Rmarkdown document etc. I include my title.tex file:
\usepackage{graphicx}
\begin{document}
\begin{titlepage}
\begin{center}
\includegraphics{UCTLogoLong.jpg}
\vspace*{2cm}
\textbf {\Huge Applied Spatial Data Analysis} % MAIN TITLE
\vspace{0.5cm}
{\LARGE Assignment 1} % SUBTITLE
\vspace{1cm}
\noindent\makebox[\linewidth]{\rule{\textwidth}{1pt}}
{\LARGE Geostatistics}
\noindent\makebox[\linewidth]{\rule{\textwidth}{1pt}}
\vspace{1cm}
{\Large NAME } % AUTHOR
{\Large STUDENT NUMBER}
\vspace{1cm}
\includegraphics[width=5cm,height=5cm,keepaspectratio]{statslogo.png}
\vspace{0.2cm}
Department of Statistical Sciences\\
University of Cape Town\\
South Africa\\
\today
\end{center}
\end{titlepage}
\end{document}
I am relatively new to Rmarkdown and have no idea why the standard Rmarkdown text isn't showing in knitted pdf. Any help will be much appreciated.
The problem is that with the \begin{document}...\end{document} you tell latex that it should ignore everything after that. Instead you could issue the content of the title page \AtBeginDocument{...}
title.tex:
\usepackage{graphicx}
\AtBeginDocument{
\begin{titlepage}
\begin{center}
\includegraphics{example-image-duck}
\vspace*{2cm}
\textbf {\Huge Applied Spatial Data Analysis} % MAIN TITLE
\vspace{0.5cm}
{\LARGE Assignment 1} % SUBTITLE
\vspace{1cm}
\noindent\makebox[\linewidth]{\rule{\textwidth}{1pt}}
{\LARGE Geostatistics}
\noindent\makebox[\linewidth]{\rule{\textwidth}{1pt}}
\vspace{1cm}
{\Large John Doe } % AUTHOR
{\Large something}
\vspace{1cm}
\includegraphics[width=5cm,height=5cm,keepaspectratio]{example-image-duck}
\vspace{0.2cm}
Department of Statistical Sciences\\
University of Cape Town\\
South Africa\\
\today
\end{center}
\end{titlepage}
\clearpage
}
Furthermore, I had to remove the empty line in
---
output:
pdf_document:
includes:
in_header: title.tex
---

R Markdown (beamer) - how to create 2 columns

I am trying to create a presentation using RMarkdown beamer. I want a slide to have 2 columns and this is what I have so far:
---
title: title
author: name
date: date
output:
beamer_presentation:
theme: Szeged
slide_level: 2
includes:
in_header: header.tex
keep_tex: true
linkcolor: false
---
## TEST
\footnotesize
\justify
:::::::::::::: {.columns}
::: {.column}
- I will write something here tex text text tex text text tex text text
:::
::: {.column}
- And then something here tex text text tex text text tex text text tex text text
:::
::::::::::::::
The header.tex's content is:
\definecolor{mycolorlightblue}{RGB}{103,153,200}
\definecolor{mycolordarkblue}{RGB}{0,70,127}
% add packages
\usepackage{tikz}
\usetikzlibrary{arrows}
\usepackage{tcolorbox}
\usepackage{ragged2e}
% remove 2nd section from header
\makeatletter
\beamer#theme#subsectionfalse
\makeatother
% change colour of lines
\setbeamercolor{separation line}{bg=mycolorlightblue}
% text title
\setbeamercolor{title}{fg=mycolordarkblue}
\setbeamercolor{frametitle}{fg=mycolordarkblue}
% text colour
\setbeamercolor{frametitle}{fg=mycolordarkblue}
% item colour
\setbeamercolor{structure}{fg=mycolordarkblue}
% define colour text
% \usebeamerfont{section title}\color{blue!70!green}\insertsection\par
% no header or footer on first page
\thispagestyle{empty}
% remove title slides at beginning of sections
\AtBeginSection{}
% add page counter to the footer
\setbeamertemplate{footline}[frame number]
% logo of my university
\titlegraphic{%
\begin{picture}(0,0)
\put(155,0){\makebox(0,0)[rt]{\includegraphics[]{ALL-ICONS.png}}}
\end{picture}}
This is the result I am seeing, almost perfect, but the 2nd column starts slight below the first one, as shown below, do you understand why?
correspondent .tex file to the .rmd:
\begin{frame}{TEST}
\protect\hypertarget{test}{}
\footnotesize
\justify
\begin{columns}[T]
\begin{column}{0.48\textwidth}
\begin{itemize}
\tightlist
\item
I will write something here text text text text text text text text
text text text text text text text
\end{itemize}
\end{column}
\begin{column}{0.48\textwidth}
\begin{itemize}
\tightlist
\item
And then something here text text text text text text text text text
text text text text text text
\end{itemize}
\end{column}
\end{columns}
\end{frame}
The problem is the \justify, it should be \justifying instead (but at the position you use it, it won't have any effect on the text in the columns anyway, so you could also just remove it ...)
---
title: title
author: name
date: date
output:
beamer_presentation:
theme: Szeged
slide_level: 2
includes:
in_header: header.tex
keep_tex: true
---
## TEST
\footnotesize
:::::::::::::: {.columns}
::: {.column}
- I will write something here tex text text tex text text tex text text
:::
::: {.column}
- And then something here tex text text tex text text tex text text tex text text
:::
::::::::::::::

How to have multiple note page in Rmarkdown beamer presentation

In Markdown beamer presentation output, my multiple notes pages are being combined into one note page. When I looked into the .tex file (from my keep_text=TRUE option), it is because the notes commands are put between \begin{frame} ... \end{frame} instead of outside \end{frame}. Below is my reproducible code in Rmarkdown beamer presentation document. Any help will be appreciated.
---
output:
beamer_presentation
keep_tex: yes
---
## slide title
- item 1
- item 2
\note{
long paragraph 1
}
\note{
long paragraph 2
}
I get this output
But what I wanted was:
You can temporarily switch from markdown to real latex and end the frame before adding the notes:
---
output:
beamer_presentation:
keep_tex: true
header-includes:
- \setbeameroption{show notes}
---
## slide title
- item 1
- item 2
``` {=latex}
\end{frame}
\note{
long paragraph 1
}
\note{
long paragraph 2
}
\begin{frame}
```
normal slide
https://rstudio.cloud/project/1051204

Insert multiple pages before body with bookdown

I am rendering a pdf book with bookdown and have a manual front page created by frontpage.tex. In my index.Rmd file, i specify the output in the YAML like this:
output:
bookdown::pdf_book:
citation_package: natbib
includes:
before_body: frontpage.tex
in_header: preamble.tex
I would, however, like to have multiple pages before the Table of Contents, such as the quote page, acknowledgements etc. The quote page should not include any header, just the quote itself.
Is this possible by extending the frontpage.tex to multiple pages?
The frontpage.tex looks like this:
\begin{titlepage}
\begin{center}
\Huge
\textbf{Title}
\vspace{0.5cm}
\LARGE
\textbf{Subtitle}
\end{center}
\end{titlepage}
I tried to add \newpage and continue on a new blank page, then added another \vspace, but the text appears at the top of the page no matter what i do.
You could simply add multiple titlepage environments into the frontpage.tex file, e.g.
{
\pagestyle{empty}
\begin{titlepage}
\begin{center}
\Huge
\textbf{Title}
\vspace{0.5cm}
\LARGE
\textbf{Subtitle}
\end{center}
\end{titlepage}
\begin{titlepage}
\begin{center}
\Huge
\textbf{AnotherTitle}
\vspace{0.5cm}
\LARGE
\textbf{Subtitle}
\end{center}
\end{titlepage}
}

Resources