我的页脚在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*{1baselineskip}
# IDENTIFICATION REPORT
(some more LaTex and code chunks follow, including bar plots and KableExtra tables)
...

我将花哨的脚放在一些代码之后或在标头(包括标头(之下,这并不重要。结果是一样的。页脚在第一页上正确生成,但仅此而已,而标题出现在每个页面的开头。

对可能发生的事情有任何想法吗?

您的标题比默认的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*{1baselineskip}
# IDENTIFICATION REPORT
(some more LaTex and code chunks follow, including bar plots and KableExtra tables)
...

最新更新