[英]LaTeX whitespace not showing up in RMarkdown PDF
我使用rmarkdown
和beamer
制作教学幻灯片。 我试图在我的幻灯片中插入一个 LaTeX 方程,这个方程中有几个空格。
$Scott's \space pi = \frac{\% \space obs. \space agreements - \% \space exp. \space agreements}{1 - \% \space exp. \space agreements}$
当我在 hover 上使用我的 cursor 时,Rstudio 正确预览方程,如下面的屏幕截图所示:
但是,当我编织 PDF 时,没有出现空格,我得到了这个:
我在这里错过了什么吗?
我的 markdown header 如下:
---
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"
---
`preamble.tex' 文件如下:
\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}
}
请不要对整个单词使用数学模式,除了缺少空格外,字距都乱了!
相反,您可以使用amsmath
package 中的\text{...}
宏(由投影仪自动加载)
---
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}}$
您需要使用它为 RMarkdown 中的方程式添加空间: http://www.emerson.emory.edu/services/latex/latex_119.html 。 在您的情况下,您只需将\space
替换为\:
。
.Rmd
文件示例:
---
title: "Equation with space"
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
$$Scott's \: pi = \frac{\% \: obs. \: agreements - \% \: exp. \: agreements}{1 - \% \: exp. \: agreements}$$
输出:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.