Page Numbering in R Bookdown










7















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










share|improve this question




























    7















    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










    share|improve this question


























      7












      7








      7


      2






      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










      share|improve this question
















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      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






















          3 Answers
          3






          active

          oldest

          votes


















          11





          +50









          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 as book.tex to the working directory

          • update book.tex to include frontmatter, mainmatter and backmatter (diff below)

          • update _output.yml to refer to book.tex as template (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)$





          share|improve this answer
































            6














            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 latex frontmatter command at the end,


            • after_body.tex with the latex backmatter command,

            Then, before your first actual main body, just add the mainmatter command (just in latex) to, say, your index.Rmd (whichever of your *.Rmds 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.






            share|improve this answer


















            • 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


















            0














            It's actually very simple:



            In the front matter part do this:



            cleardoublepage
            pagenumberingroman


            In the main matter part:



            cleardoublepage
            pagenumberingarabic





            share|improve this answer






















              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
              );



              );













              draft saved

              draft discarded


















              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









              11





              +50









              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 as book.tex to the working directory

              • update book.tex to include frontmatter, mainmatter and backmatter (diff below)

              • update _output.yml to refer to book.tex as template (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)$





              share|improve this answer





























                11





                +50









                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 as book.tex to the working directory

                • update book.tex to include frontmatter, mainmatter and backmatter (diff below)

                • update _output.yml to refer to book.tex as template (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)$





                share|improve this answer



























                  11





                  +50







                  11





                  +50



                  11




                  +50





                  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 as book.tex to the working directory

                  • update book.tex to include frontmatter, mainmatter and backmatter (diff below)

                  • update _output.yml to refer to book.tex as template (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)$





                  share|improve this answer















                  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 as book.tex to the working directory

                  • update book.tex to include frontmatter, mainmatter and backmatter (diff below)

                  • update _output.yml to refer to book.tex as template (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)$






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Jun 19 '18 at 10:22

























                  answered Jan 13 '18 at 20:47









                  Ralf StubnerRalf Stubner

                  14.4k21537




                  14.4k21537























                      6














                      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 latex frontmatter command at the end,


                      • after_body.tex with the latex backmatter command,

                      Then, before your first actual main body, just add the mainmatter command (just in latex) to, say, your index.Rmd (whichever of your *.Rmds 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.






                      share|improve this answer


















                      • 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















                      6














                      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 latex frontmatter command at the end,


                      • after_body.tex with the latex backmatter command,

                      Then, before your first actual main body, just add the mainmatter command (just in latex) to, say, your index.Rmd (whichever of your *.Rmds 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.






                      share|improve this answer


















                      • 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













                      6












                      6








                      6







                      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 latex frontmatter command at the end,


                      • after_body.tex with the latex backmatter command,

                      Then, before your first actual main body, just add the mainmatter command (just in latex) to, say, your index.Rmd (whichever of your *.Rmds 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.






                      share|improve this answer













                      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 latex frontmatter command at the end,


                      • after_body.tex with the latex backmatter command,

                      Then, before your first actual main body, just add the mainmatter command (just in latex) to, say, your index.Rmd (whichever of your *.Rmds 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.







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      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












                      • 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











                      0














                      It's actually very simple:



                      In the front matter part do this:



                      cleardoublepage
                      pagenumberingroman


                      In the main matter part:



                      cleardoublepage
                      pagenumberingarabic





                      share|improve this answer



























                        0














                        It's actually very simple:



                        In the front matter part do this:



                        cleardoublepage
                        pagenumberingroman


                        In the main matter part:



                        cleardoublepage
                        pagenumberingarabic





                        share|improve this answer

























                          0












                          0








                          0







                          It's actually very simple:



                          In the front matter part do this:



                          cleardoublepage
                          pagenumberingroman


                          In the main matter part:



                          cleardoublepage
                          pagenumberingarabic





                          share|improve this answer













                          It's actually very simple:



                          In the front matter part do this:



                          cleardoublepage
                          pagenumberingroman


                          In the main matter part:



                          cleardoublepage
                          pagenumberingarabic






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 13 '18 at 18:10









                          soerensensoerensen

                          113




                          113



























                              draft saved

                              draft discarded
















































                              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.




                              draft saved


                              draft discarded














                              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





















































                              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







                              Popular posts from this blog

                              How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

                              Syphilis

                              Darth Vader #20