我通过在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)
...
无论我在某些代码之后还是在header-includes下,都花哨的脚都没关系。结果是一样的。页脚是在第一页上正确生成的,仅此而已,而页眉则出现在每页的开头。
关于发生什么的任何想法?
\headheight
高得多,因此将内容和脚注推离页面。 .log
中有一个明确的警告,告诉您标题的高度。确切的值取决于图像的长宽比,对于我使用的示例图像,大约为75pt---
output:
pdf_document:
keep_tex: true
header-includes:
- \usepackage{fancyhdr}
- \pagestyle{fancy}
- \fancyfoot{}
- \fancyhead{}
- \renewcommand{\headrulewidth}{0pt}
- \geometry{head=75pt, includehead=true, includefoot=true}
---
... (some chunks of code go here)
\fancyhead[L]{\includegraphics[width=4cm]{example-image-duck}}
\fancyfoot[R]{Page \thepage\ of \pageref{LastPage} \\ \today}
\fancyfoot[L]{Identification Report \\ User generating the report: }
\vspace*{1\baselineskip}
# IDENTIFICATION REPORT
(some more LaTex and code chunks follow, including bar plots and KableExtra tables)
...