从R Markdown到LaTeX的错误转换

Ada*_*ter 4 latex pandoc knitr r-markdown

为什么以下R Markdown最小(非)工作示例无法编译为PDF?

---
header-includes:
- \usepackage{fancyhdr}
- \pagestyle{fancy}
- \lhead{}
- \chead{}
- \rhead{The performance of new graduates}
- \lfoot{From: K. Grant}
- \cfoot{To: Dean A. Smith}
output:
  pdf_document:
    keep_tex: yes
    latex_engine: xelatex
---

# Test
Run Code Online (Sandbox Code Playgroud)

特别是,有问题的转换发生在-\lfoot{From: K. Grant}-\cfoot{To: Dean A. Smith},如输出.tex文件所示:

---
header-includes:
- \usepackage{fancyhdr}
- \pagestyle{fancy}
- \lhead{}
- \chead{}
- \rhead{The performance of new graduates}
- \lfoot{From: K. Grant}
- \cfoot{To: Dean A. Smith}
output:
  pdf_document:
    keep_tex: yes
    latex_engine: xelatex
---

# Test
Run Code Online (Sandbox Code Playgroud)

出于某种原因,这两种线被转换为true使

LaTeX错误:缺少 \begin{document}

从而防止将文档编译为PDF。

更改\lfoot以及\cfoot几乎所有其他更改似乎都导致它们正确地转换了。那么这是怎么回事?我认为转换过程中knitr或其中一定有问题pandoc

注意:我对R Markdown不太熟悉,这是对在Fancyhead中创建的页眉和页脚的后续问题,在Tom的TeX.SX上的PDF中显示

sco*_*coa 5

:字符的问题。pandoc似乎试图将header-includes内容解析为变量,并:用于将变量和值分开。如果引用有问题的行,它将编译(不要忘记,以免出现反斜杠)

---
header-includes:
- \usepackage{fancyhdr}
- \pagestyle{fancy}
- \lhead{}
- \chead{}
- \rhead{The performance of new graduates}
- "\\lfoot{From: K. Grant}"
- "\\cfoot{To: Dean A. Smith}"
output:
  pdf_document:
    keep_tex: yes
    latex_engine: xelatex
---

# Test
Run Code Online (Sandbox Code Playgroud)