如何在R Bookdown的第一章的第一页实现罗马数字,如前言、致谢等,并在1处重新开始阿拉伯数字。
我想渲染到pdf在bookdown,但还没有找到任何好的信息,如何改变页码这样
谢谢
发布于 2018-01-14 04:48:00
请同时查看the answer by @maxheld。它更简单,并且对于许多用例来说已经足够了。另一个不需要编辑模板的简单解决方案是:
---
title: Page Numbering in R Bookdown
documentclass: book
output:
bookdown::pdf_book: default
header-includes:
- \AtBeginDocument{\frontmatter}
---
\mainmatter
# Header 1
Some text
\backmatter
# Appendix 1
Some text 这会在正确的位置插入\frontmatter、\mainmatter和\backmatter。
原始答案
PDF输出是使用book document类在LaTeX中生成的。在这个类中,您可以使用\frontmatter、\mainmatter和\backmatter来分隔图书的不同“部分”。为了在bookdown中使用它,我执行了以下操作:
从https://github.com/seankross/bookdown-start
book.tex to working directory<R-library-path>/rmarkdown/rmd/latex/default-1.17.0.2.tex的副本开始,包括book.tex、\frontmatter、\mainmatter和\backmatter (将D26_output.yml >称为<代码>D27(下面比较)<代码>H228<代码>F229通过这些更改,用bookdown生成的PDF对ToC使用(小写)罗马数字,并以阿拉伯数字重新开始实际的正文。下面是不同之处:
diff --git a/_output.yml b/_output.yml
index 112cf5b..b211ba7 100644
--- a/_output.yml
+++ b/_output.yml
@@ -13,5 +13,6 @@ bookdown::pdf_book:
in_header: preamble.tex
latex_engine: xelatex
citation_package: natbib
+ template: book.tex
bookdown::epub_book:
stylesheet: style.css
diff --git a/book.tex b/book.tex
index 0f9979d..3d03540 100644
--- a/book.tex
+++ b/book.tex
@@ -235,6 +235,9 @@ $header-includes$
$endfor$
\begin{document}
+$if(book-class)$
+\frontmatter
+$endif$
$if(title)$
\maketitle
$endif$
@@ -263,8 +266,14 @@ $endif$
$if(lof)$
\listoffigures
$endif$
+$if(book-class)$
+\mainmatter
+$endif$
$body$
+$if(book-class)$
+\backmatter
+$endif$
$if(natbib)$
$if(bibliography)$
$if(biblio-title)$发布于 2018-02-22 18:51:11
我觉得像@艺辉在他自己的bookdown krantz example中使用的例子可能会更容易一些
添加以下文件,可能是在/latex子文件夹中:
在末尾使用latex \frontmatter命令执行
preamble.tex,使用latex 命令执行
preamble.tex然后,在您的第一个实际主体之前,只需将\mainmatter命令(在latex中)添加到您的index.Rmd (无论您的*.Rmd中哪个是第一个,通常是index.Rmd)。
然后,像这样修改你的_output.yml:
bookdown::pdf_book:
includes:
in_header: latex/preamble.tex
after_body: latex/after_body.tex 这会将正确的\frontmatter、\mainmatter和\backmatter命令插入到您的pandoc-ed latex书籍中。它将被大多数样式文件所遵循,以确保阿拉伯编号仅从主要内容内部开始。
书中的publishing chapter中也记录了这一点。
发布于 2018-11-14 02:10:10
它实际上非常简单:
在前面的问题部分中,执行以下操作:
\cleardoublepage
\pagenumbering{roman}在主要内容部分:
\cleardoublepage
\pagenumbering{arabic}https://stackoverflow.com/questions/43711029
复制相似问题