【发布时间】:2019-12-09 23:02:10
【问题描述】:
我在 R-Markdown 生成的 PDF 中使用 fancyhdr 包设置了页脚和页眉。但是,在某些时候,我注意到我的页脚在第一页之后消失了,而我的页眉按预期出现在每一页中。我不知道为什么会这样,我尝试了很多东西,但到目前为止似乎没有任何效果。
header-includes:
- \usepackage{fancyhdr}
- \pagestyle{fancy}
- \fancyfoot{}
- \fancyhead{}
- \renewcommand{\headrulewidth}{0pt}
... (some chunks of code go here)
\fancyhead[L]{\includegraphics[width=4cm]{/Users/username/Documents/SP_logo_login.png}}
\fancyfoot[R]{Page \thepage\ of \pageref{LastPage} \\ \today , \currenttime}
\fancyfoot[L]{Identification Report \\ User generating the report: {`r paste(user_code)`}}
\vspace*{1\baselineskip}
# IDENTIFICATION REPORT
(some more LaTex and code chunks follow, including bar plots and KableExtra tables)
...
不管我是把fancyfoot放在一些代码之后还是放在header-includes下面。结果是一样的。页脚在第一页上正确生成,仅此而已,而页眉出现在每一页的开头。
知道会发生什么吗?
【问题讨论】:
-
你能截取生成的 .tex 文件吗?
-
你能把 Rmd 缩小到 minimal reproducible example 吗?可以通过
output.pdf_document.keep_tex: yes拦截@samcarter 要求的.tex文件。 -
@samcarter 当我尝试执行一个最小的可重现示例时,我发现了一些东西。它是产生冲突的标头。如果我不使用 \includegraphics 而是将所有内容替换为一个字符(“Hello”),那么页眉和页脚都会出现在所有页面上。所以肯定是和header中的图片上传有关。
-
@MarcBF 我怀疑是headheight的问题,但我需要一个小的tex文档来测试。您是否在 .log 文件中收到任何有关 headheight 的警告?
-
@MarcBF 你能显示 tex 文件吗?
标签: latex markdown r-markdown pdflatex