Page Numbering in R Bookdown
How do you achieve roman numerals for things like preface, acknowledgement etc and restart Arabic numbering at 1 for first page of chapter one in R Bookdown.
I am wanting to render to pdf in bookdown, but have not found any good information on how to change page numbering like this
thanks
r latex bookdown
add a comment |
How do you achieve roman numerals for things like preface, acknowledgement etc and restart Arabic numbering at 1 for first page of chapter one in R Bookdown.
I am wanting to render to pdf in bookdown, but have not found any good information on how to change page numbering like this
thanks
r latex bookdown
add a comment |
How do you achieve roman numerals for things like preface, acknowledgement etc and restart Arabic numbering at 1 for first page of chapter one in R Bookdown.
I am wanting to render to pdf in bookdown, but have not found any good information on how to change page numbering like this
thanks
r latex bookdown
How do you achieve roman numerals for things like preface, acknowledgement etc and restart Arabic numbering at 1 for first page of chapter one in R Bookdown.
I am wanting to render to pdf in bookdown, but have not found any good information on how to change page numbering like this
thanks
r latex bookdown
r latex bookdown
edited May 1 '17 at 2:56
Yihui Xie
20.9k11107285
20.9k11107285
asked Apr 30 '17 at 20:31
Lyndon SundmarkLyndon Sundmark
1089
1089
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
Please also look at the answer by @maxheld. It is simpler and for many use cases sufficient.
PDF output is produced with LaTeX using the book
document class. In this class, you can use frontmatter
, mainmatter
and backmatter
to separate different 'parts' of the book. In order to use this with bookdown
I did the following:
- start with a copy of https://github.com/seankross/bookdown-start
- copy
<R-library-path>/rmarkdown/rmd/latex/default-1.17.0.2.tex
asbook.tex
to the working directory - update
book.tex
to includefrontmatter
,mainmatter
andbackmatter
(diff below) - update
_output.yml
to refer tobook.tex
astemplate
(diff below)
With these changes the PDF produced with bookdown
used (loweercase) roman numerals for the ToC and restarted with arabic numbers for the actual body. Here the diff:
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$
begindocument
+$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)$
add a comment |
I think it might be easier to just follow the example @yihui used in his own bookdown krantz
example:
Add the following files, perhaps in a /latex
subfolder:
preamble.tex
with the latexfrontmatter
command at the end,after_body.tex
with the latexbackmatter
command,
Then, before your first actual main body, just add the mainmatter
command (just in latex) to, say, your index.Rmd
(whichever of your *.Rmd
s is first, conventionally index.Rmd
).
Then, to amend your _output.yml
like so:
bookdown::pdf_book:
includes:
in_header: latex/preamble.tex
after_body: latex/after_body.tex
This intersperses the correct frontmatter
, mainmatter
and backmatter
commands into your pandoc-ed latex book. It will be respected by most style files to make sure that arabic numbering only begins inside the main matter.
This is also documented in the publishing chapter of the bookdown book.
2
+1 since this is indeed much simpler. The only disadvantage is that the bibliography and any appendices are still part of mainmatter. However, you can place backmatter before the first appendix or at the end of the last chapter.
– Ralf Stubner
Mar 22 '18 at 10:00
add a comment |
It's actually very simple:
In the front matter part do this:
cleardoublepage
pagenumberingroman
In the main matter part:
cleardoublepage
pagenumberingarabic
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f43711029%2fpage-numbering-in-r-bookdown%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Please also look at the answer by @maxheld. It is simpler and for many use cases sufficient.
PDF output is produced with LaTeX using the book
document class. In this class, you can use frontmatter
, mainmatter
and backmatter
to separate different 'parts' of the book. In order to use this with bookdown
I did the following:
- start with a copy of https://github.com/seankross/bookdown-start
- copy
<R-library-path>/rmarkdown/rmd/latex/default-1.17.0.2.tex
asbook.tex
to the working directory - update
book.tex
to includefrontmatter
,mainmatter
andbackmatter
(diff below) - update
_output.yml
to refer tobook.tex
astemplate
(diff below)
With these changes the PDF produced with bookdown
used (loweercase) roman numerals for the ToC and restarted with arabic numbers for the actual body. Here the diff:
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$
begindocument
+$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)$
add a comment |
Please also look at the answer by @maxheld. It is simpler and for many use cases sufficient.
PDF output is produced with LaTeX using the book
document class. In this class, you can use frontmatter
, mainmatter
and backmatter
to separate different 'parts' of the book. In order to use this with bookdown
I did the following:
- start with a copy of https://github.com/seankross/bookdown-start
- copy
<R-library-path>/rmarkdown/rmd/latex/default-1.17.0.2.tex
asbook.tex
to the working directory - update
book.tex
to includefrontmatter
,mainmatter
andbackmatter
(diff below) - update
_output.yml
to refer tobook.tex
astemplate
(diff below)
With these changes the PDF produced with bookdown
used (loweercase) roman numerals for the ToC and restarted with arabic numbers for the actual body. Here the diff:
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$
begindocument
+$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)$
add a comment |
Please also look at the answer by @maxheld. It is simpler and for many use cases sufficient.
PDF output is produced with LaTeX using the book
document class. In this class, you can use frontmatter
, mainmatter
and backmatter
to separate different 'parts' of the book. In order to use this with bookdown
I did the following:
- start with a copy of https://github.com/seankross/bookdown-start
- copy
<R-library-path>/rmarkdown/rmd/latex/default-1.17.0.2.tex
asbook.tex
to the working directory - update
book.tex
to includefrontmatter
,mainmatter
andbackmatter
(diff below) - update
_output.yml
to refer tobook.tex
astemplate
(diff below)
With these changes the PDF produced with bookdown
used (loweercase) roman numerals for the ToC and restarted with arabic numbers for the actual body. Here the diff:
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$
begindocument
+$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)$
Please also look at the answer by @maxheld. It is simpler and for many use cases sufficient.
PDF output is produced with LaTeX using the book
document class. In this class, you can use frontmatter
, mainmatter
and backmatter
to separate different 'parts' of the book. In order to use this with bookdown
I did the following:
- start with a copy of https://github.com/seankross/bookdown-start
- copy
<R-library-path>/rmarkdown/rmd/latex/default-1.17.0.2.tex
asbook.tex
to the working directory - update
book.tex
to includefrontmatter
,mainmatter
andbackmatter
(diff below) - update
_output.yml
to refer tobook.tex
astemplate
(diff below)
With these changes the PDF produced with bookdown
used (loweercase) roman numerals for the ToC and restarted with arabic numbers for the actual body. Here the diff:
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$
begindocument
+$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)$
edited Jun 19 '18 at 10:22
answered Jan 13 '18 at 20:47
Ralf StubnerRalf Stubner
14.4k21537
14.4k21537
add a comment |
add a comment |
I think it might be easier to just follow the example @yihui used in his own bookdown krantz
example:
Add the following files, perhaps in a /latex
subfolder:
preamble.tex
with the latexfrontmatter
command at the end,after_body.tex
with the latexbackmatter
command,
Then, before your first actual main body, just add the mainmatter
command (just in latex) to, say, your index.Rmd
(whichever of your *.Rmd
s is first, conventionally index.Rmd
).
Then, to amend your _output.yml
like so:
bookdown::pdf_book:
includes:
in_header: latex/preamble.tex
after_body: latex/after_body.tex
This intersperses the correct frontmatter
, mainmatter
and backmatter
commands into your pandoc-ed latex book. It will be respected by most style files to make sure that arabic numbering only begins inside the main matter.
This is also documented in the publishing chapter of the bookdown book.
2
+1 since this is indeed much simpler. The only disadvantage is that the bibliography and any appendices are still part of mainmatter. However, you can place backmatter before the first appendix or at the end of the last chapter.
– Ralf Stubner
Mar 22 '18 at 10:00
add a comment |
I think it might be easier to just follow the example @yihui used in his own bookdown krantz
example:
Add the following files, perhaps in a /latex
subfolder:
preamble.tex
with the latexfrontmatter
command at the end,after_body.tex
with the latexbackmatter
command,
Then, before your first actual main body, just add the mainmatter
command (just in latex) to, say, your index.Rmd
(whichever of your *.Rmd
s is first, conventionally index.Rmd
).
Then, to amend your _output.yml
like so:
bookdown::pdf_book:
includes:
in_header: latex/preamble.tex
after_body: latex/after_body.tex
This intersperses the correct frontmatter
, mainmatter
and backmatter
commands into your pandoc-ed latex book. It will be respected by most style files to make sure that arabic numbering only begins inside the main matter.
This is also documented in the publishing chapter of the bookdown book.
2
+1 since this is indeed much simpler. The only disadvantage is that the bibliography and any appendices are still part of mainmatter. However, you can place backmatter before the first appendix or at the end of the last chapter.
– Ralf Stubner
Mar 22 '18 at 10:00
add a comment |
I think it might be easier to just follow the example @yihui used in his own bookdown krantz
example:
Add the following files, perhaps in a /latex
subfolder:
preamble.tex
with the latexfrontmatter
command at the end,after_body.tex
with the latexbackmatter
command,
Then, before your first actual main body, just add the mainmatter
command (just in latex) to, say, your index.Rmd
(whichever of your *.Rmd
s is first, conventionally index.Rmd
).
Then, to amend your _output.yml
like so:
bookdown::pdf_book:
includes:
in_header: latex/preamble.tex
after_body: latex/after_body.tex
This intersperses the correct frontmatter
, mainmatter
and backmatter
commands into your pandoc-ed latex book. It will be respected by most style files to make sure that arabic numbering only begins inside the main matter.
This is also documented in the publishing chapter of the bookdown book.
I think it might be easier to just follow the example @yihui used in his own bookdown krantz
example:
Add the following files, perhaps in a /latex
subfolder:
preamble.tex
with the latexfrontmatter
command at the end,after_body.tex
with the latexbackmatter
command,
Then, before your first actual main body, just add the mainmatter
command (just in latex) to, say, your index.Rmd
(whichever of your *.Rmd
s is first, conventionally index.Rmd
).
Then, to amend your _output.yml
like so:
bookdown::pdf_book:
includes:
in_header: latex/preamble.tex
after_body: latex/after_body.tex
This intersperses the correct frontmatter
, mainmatter
and backmatter
commands into your pandoc-ed latex book. It will be respected by most style files to make sure that arabic numbering only begins inside the main matter.
This is also documented in the publishing chapter of the bookdown book.
answered Feb 22 '18 at 10:51
maxheldmaxheld
1,2931232
1,2931232
2
+1 since this is indeed much simpler. The only disadvantage is that the bibliography and any appendices are still part of mainmatter. However, you can place backmatter before the first appendix or at the end of the last chapter.
– Ralf Stubner
Mar 22 '18 at 10:00
add a comment |
2
+1 since this is indeed much simpler. The only disadvantage is that the bibliography and any appendices are still part of mainmatter. However, you can place backmatter before the first appendix or at the end of the last chapter.
– Ralf Stubner
Mar 22 '18 at 10:00
2
2
+1 since this is indeed much simpler. The only disadvantage is that the bibliography and any appendices are still part of mainmatter. However, you can place backmatter before the first appendix or at the end of the last chapter.
– Ralf Stubner
Mar 22 '18 at 10:00
+1 since this is indeed much simpler. The only disadvantage is that the bibliography and any appendices are still part of mainmatter. However, you can place backmatter before the first appendix or at the end of the last chapter.
– Ralf Stubner
Mar 22 '18 at 10:00
add a comment |
It's actually very simple:
In the front matter part do this:
cleardoublepage
pagenumberingroman
In the main matter part:
cleardoublepage
pagenumberingarabic
add a comment |
It's actually very simple:
In the front matter part do this:
cleardoublepage
pagenumberingroman
In the main matter part:
cleardoublepage
pagenumberingarabic
add a comment |
It's actually very simple:
In the front matter part do this:
cleardoublepage
pagenumberingroman
In the main matter part:
cleardoublepage
pagenumberingarabic
It's actually very simple:
In the front matter part do this:
cleardoublepage
pagenumberingroman
In the main matter part:
cleardoublepage
pagenumberingarabic
answered Nov 13 '18 at 18:10
soerensensoerensen
113
113
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f43711029%2fpage-numbering-in-r-bookdown%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown