[英]How to show the total number of pages in a PDF via the RMarkdown (i.e. display "Page 1 of 10")?
鑒於下面的代碼,它當前在頁面頂部輸出頁碼,我希望它到 output PDF 頁數,如Page 1 of 3
。 我做了很多搜索,但沒有找到任何方法來包含總頁碼。
問題這可以在 R Markdown 中執行嗎? 如果沒有,是否有任何解決方法?
我用谷歌搜索了這個,沒有發現任何明顯的東西,比如 YAML 或 TeX 解決方案,但是,我可能遺漏了一些東西或沒有尋找正確的東西。
RMarkdown 代碼
---
title: "R Markdown Example With Numbered Sections"
output:
bookdown::pdf_document2:
toc: true
toc_depth: 6
number_sections: true
includes:
in_header: header.tex
header-includes:
- \usepackage{fancyhdr}
- \pagestyle{fancy}
- \fancyhead[RO,RE]{\thepage}
- \fancyhead[LO,LE]{Header Message}
- \fancyfoot[LE,LO]{Footer Messge on the Left}
- \fancyfoot[LE,RO]{Footer Messge on the Right}
---
\thispagestyle{fancy}
# Example R Rarkdown : Numbered Sections
## R Markdown
### Description
Some description text
\newpage
#### Details
Details go here.
\newpage
## Plots
Plots go here
\newpage
Last page
當前 header
所需的 Header
確保您已安裝最后lastpage
。
然后修改您的 header 包括如下所示:
header-includes:
- \usepackage{fancyhdr}
- \usepackage{lastpage}
- \pagestyle{fancy}
- \fancyhead[RO,RE]{\thepage\ of \pageref{LastPage}}
- \fancyhead[LO,LE]{Header Message}
- \fancyfoot[LE,LO]{Footer Messge on the Left}
- \fancyfoot[LE,RO]{Footer Messge on the Right}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.