如何解决LaTeX 空白未显示在 RMarkdown PDF 中
我使用 rmarkdown
和 beamer
制作教学幻灯片。我试图在我的幻灯片中插入一个 LaTeX 方程,这个方程中有几个空格。
$Scott's \space pi = \frac{\% \space obs. \space agreements - \% \space exp. \space agreements}{1 - \% \space exp. \space agreements}$
当我将光标悬停在它上面时,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,center]{section in foot} % footsection 2
\usebeamerfont{section in foot} \inserttitle
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.34\paperwidth,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}
}
解决方法
请不要对整个单词使用数学模式,除了缺少空格之外,字距调整一团糟!
相反,您可以使用 \text{...}
包中的 amsmath
宏(由 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}}$
,
您需要使用它来为 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}$$
输出:
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。