latex - 我的页脚在 R-Markdown 的第一页(但不是页眉!)之后消失了
问题描述
我通过在 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下面。结果是一样的。页脚在第一页上正确生成,但仅此而已,而页眉出现在每一页的开头。
知道会发生什么吗?
解决方案
您的标题远高于默认标题\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)
...
推荐阅读
- javascript - Javascript - 你如何找到一个数字随时间的总增长?
- powershell - 使用 Get-StorageBlobContent 将 blob 下载到本地目录的问题
- php - 当仅在 Woocommerce 中的一个区域提供免费送货时,隐藏其他送货选项
- python-3.x - Plotly python - 将不透明度数组传递给 Scatter3d 对象中的标记
- javascript - Chart.js 到 PHPWord
- c# - C# 中的动作委托
- c++ - 磁盘已满时 Boost 日志崩溃
- r - 在 R 中对两个数据帧使用 Countifs 函数
- node.js - Passport JS 没有给出用户名
- sql-server - 通过 JDBC 驱动程序连接到 SQL Server 的 SSL 握手验证错误