Creating a footer for every page (including first!) using R markdown

你。 提交于 2019-12-23 10:26:57

问题


I'd like to add to the question Creating a footer for every page using R markdown: how do I do this for the first page of the document in addition to all the following pages?

In RStudio, this code:

---
title: "Test"
author: "Author Name"
header-includes:
- \usepackage{fancyhdr}
- \usepackage{lipsum}
- \pagestyle{fancy}
- \fancyhead[CO,CE]{This is fancy header}
- \fancyfoot[CO,CE]{And this is a fancy footer}
- \fancyfoot[LE,RO]{\thepage}
output: pdf_document
---
\lipsum[1-30]

Produces this at the bottom of pg1:

and this (oddly, shouldn't this go on the left because of the \fancyfoot[LE,RO]{\thepage}?) at the bottom of pg2:

and this at the bottom of pg3:


回答1:


Use

---
title: "Test"
author: "Author Name"
header-includes:
- \usepackage{fancyhdr}
- \usepackage{lipsum}
- \pagestyle{fancy}
- \fancyhead[CO,CE]{This is fancy header}
- \fancyfoot[CO,CE]{And this is a fancy footer}
- \fancyfoot[LE,RO]{\thepage}
- \fancypagestyle{plain}{\pagestyle{fancy}}
output: pdf_document
---
\lipsum[1-30]

which should override the plain page style - used on the first page with an issue of \maketitle - to be equivalent to fancy.



来源:https://stackoverflow.com/questions/30922602/creating-a-footer-for-every-page-including-first-using-r-markdown

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!