为什么以下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
特别是,有问题的转换发生-\lfoot{From: K. Grant}
和-\cfoot{To: Dean A. Smith}
,如在输出端看到.tex
的文件:
\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{}
\chead{}
\rhead{The performance of new graduates}
true
true
出于某种原因,这两行都被转换为true
导致
乳胶错误:遗失
\begin{document}
从而防止文档编译为PDF。
改变\lfoot
和\cfoot
几乎任何其他东西似乎导致他们被正确转换。那么这里发生了什么?我认为转换过程中的任何一个knitr
或pandoc
转换过程都存在问题。
注意:我对R Markdown不太熟悉,这是对Fancyhead中创建的页眉和页脚的后续问题,而不代表Tom在TeX.SX上以PDF格式显示。
发布于 2019-06-10 09:38:52
该:
字符的问题。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
发布于 2019-06-10 10:31:20
拼接的答案在这里与反复试验,我发现,只有通过删除title
键,用YAML管表示多字符串语法会编译:
---
output:
pdf_document:
keep_tex: yes
latex_engine: xelatex
header-includes: |
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\fancyfoot{}
\lhead{My Title}
\rhead{My Note}
\lfoot{\today}\rfoot{Page \thepage}
---
https://stackoverflow.com/questions/-100009083
复制相似问题