Rmarkdown PDF:在横向柔性 PDF 报告中添加页码

Rmarkdown PDF: add page number in landscape flextable PDF report

我有

---
title: ""
header-includes:
  - \usepackage{xcolor}
output: pdf_document
classoption: landscape, a4paper
geometry: left=1cm,right=1cm,top=1cm,bottom=0.2cm

---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(flextable)
library(datasets)
set_flextable_defaults(fonts_ignore=TRUE)
world_phones<-data.frame(WorldPhones)
```




```{r  echo=F}
flextable(world_phones)
```
\hfill \small Report generated:  `r Sys.time() `

我想在脚注中心(页面底部中央)添加页码。如果可能的话,我想将页码添加为第 X 页,共 Y 页。

然而,即使 \pagenumbering{arabic} 似乎也不起作用,我怀疑是因为利润率太低。我怎样才能做到这一点?

您实际上确实在您的页面上有页码,但是因为您将底部边距做得非常小,所以您看不到它被推到下页下方边界。如果您增加页边距,您将获得页码:

---
title: ""
header-includes:
  - \usepackage{xcolor}
  - \usepackage{fancyhdr}
  - \pagestyle{fancy}
  - \usepackage{lastpage}
  - \fancyfoot[C]{\thepage\ of \pageref{LastPage}}
  - \renewcommand{\headrulewidth}{0pt}
output: 
  pdf_document:
    keep_tex: true
classoption: landscape, a4paper
geometry: left=1cm,right=1cm,top=1cm,bottom=2.2cm
---


test