使用fancyhdr为2+页创建了页眉,但是如何使相同的页眉也出现在首页上?
这是rmarkdown:
---
title: "Untitled"
classoption: landscape
output:
pdf_document:
number_sections: false
dev: pdf
keep_tex: false
toc: yes
header-includes:
- \usepackage{fancyhdr}
- \pagestyle{fancy}
- \fancyhead[C]{center text}
- \fancyhead[R]{right text}
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r cars}
summary(cars)
```
## Including Plots
You can also embed plots, for example:
```{r pressure, echo=FALSE}
plot(pressure)
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
最佳答案
在文档的开头(例如,在yaml header 之后)添加\thispagestyle{fancy}
,以使第一页看起来很漂亮。
编辑以发表您的评论
如果您想在首页中使用不同的中心文本,则可以在定义\fancyhead
时使用
\fancyhead[C]{\ifnum\value{page}>1 center text \else \fi}
关于r - 第一页和其他页面上的标题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57981868/