我正在尝试将以下 RMarkdown 编织为 pdf:
---
title: 'Title'
params:
set_title: 'title report'
header-includes:
- \usepackage{fancyhdr}
- \pagestyle{fancy}
- \lhead{}
- \chead{}
- \rhead{Semester Graduation Report `r params$set_title`}
output:
pdf_document:
latex_engine: xelatex
---
```{r, include =FALSE}
knitr::opts_chunk$set(echo = F, message = F, warning = F)
library(knitr)
library(tidyverse)
library(kableExtra)
options(knitr.kable.NA = '-')
```
```{r, results='asis'}
kable(mtcars, format = 'latex', longtable = T, booktabs = T, caption='This is a caption' ) %>%
add_header_above(c(" " = 1, "something"=2, "something else"=2)) %>%
kable_styling(latex_options = c("repeat_header"))
```
```{r}
kable(mtcars)
```
但是,它检索和错误
!缺少插入的 $。$ l.239 \end{文档}
我注意到如果我删除header-includes
它可以正常工作,但我宁愿不必删除标题。我究竟做错了什么?