I use rmarkdown
and beamer
to make teaching slides. I'm trying to insert a LaTeX equation in my slide, and this equation has a few spaces in it.
$Scott's \space pi = \frac{\% \space obs. \space agreements - \% \space exp. \space agreements}{1 - \% \space exp. \space agreements}$
When i hover on it with my cursor, Rstudio previews the equation correctly, as you can see in the screenshot below:
However, when I knit the PDF, the spaces don't appear, and I get this:
Am I missing something here?
My markdown header is as follows:
---
title: "XXXXXXXXXXXXXXXXXXXXXXXXXXXX"
author: "XXXXXXXXXXXXXXXXXXXXXXXXX"
institute: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
date: "XXXXXX"
output:
beamer_presentation:
incremental: true
theme: "Berlin"
colortheme: "dove"
fonttheme: "structurebold"
includes:
in_header: preamble.tex
classoption: "aspectratio=169"
---
The `preamble.tex' file is as follows:
\usepackage{caption}
\captionsetup[figure]{labelformat=empty}
\setbeamercolor{frametitle}{fg=white,bg=black} %section slide title
\setbeamercolor{section in foot}{fg=white, bg=black} % footsections
\setbeamercolor{part title}{fg=white, bg=black}
\setbeamertemplate{footline}
{
\hbox{%
\begin{beamercolorbox}[wd=.33\paperwidth,ht=2.6ex,dp=1ex,left,leftskip=2ex]{section in foot} % footsection 1
\usebeamerfont{section in foot}\insertshortauthor
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.33\paperwidth,ht=2.6ex,dp=1ex,center]{section in foot} % footsection 2
\usebeamerfont{section in foot} \inserttitle
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.34\paperwidth,ht=2.6ex,dp=1ex,right,rightskip=2ex]{section in foot} % footsection 3
\usebeamerfont{section in foot} XXXXXXXXXXXXXXXXXXXXX
\end{beamercolorbox}}%
\vskip0pt%
}
\setbeamertemplate{section page}{
\centering
\begin{columns}
\begin{column}{\paperwidth}
\begin{beamercolorbox}[sep=12pt,center]{part title}
\usebeamerfont{section title}\insertsection\par
\end{beamercolorbox}
\end{column}
\end{columns}
}
Please don't ever use math mode for whole words, besides the missing spaces, the kerning is all messed up!
Instead you can use the \text{...}
macro from the amsmath
package (which is automatically loaded by beamer)
---
title: "XXXXXXXXXXXXXXXXXXXXXXXXXXXX"
author: "XXXXXXXXXXXXXXXXXXXXXXXXX"
institute: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
date: "XXXXXX"
output:
beamer_presentation:
incremental: true
theme: "Berlin"
colortheme: "dove"
fonttheme: "structurebold"
includes:
in_header: preamble.tex
classoption: "aspectratio=169"
---
- $\text{Scott's pi} = \frac{\text{\% obs. agreements} - \text{\% exp. agreements}}{1 - \text{\% exp. agreements}}$