The package bookdownplus (Zhao 2017a) is an extension of R bookdown (Xie 2016). It is a collection of multiple templates on the basis of LaTeX, which are tailored so that I can work happily under the umbrella of bookdown. bookdownplus helps you write academic journal articles, guitar books, chemical equations, mails, calendars, and diaries.
bookdown features the collaboration of many fantastic tools. However, an R beginner might be confused or depressed in struggling in the flood of LaTeX, YAML, Markdown, Pandoc, etc. It would be a pity if users stop their steps at the door and give up the courage of entering the wonderful world of bookdown.
bookdownplus is the easiest shortcut to the world of bookdown. With just one single command users can get a demo book (or multiple demo books) in .pdf or .doc, or even more formats (see the quick start section). bookdownplus extends the features of bookdown, and simplifies the procedure. Users only have to choose a template, clarify the book title and author name, and then focus on writing the text. No need to struggle in YAML and LaTeX.
With bookdownplus users can
The website bookdownplus gallery shows some samples that bookdownplus provides.
Install R, RStudio. LaTeX(e.g. MiKTeX or TinyTeX. See the official manual of ‘bookdown’ for details.
Run RStudio. Type the following codes in the top-left panel to install ‘bookdown’ packages:
install.packages('bookdown')
# the development version from GitHub (recommended)
devtools::install_github("pzhaonet/bookdownplus")
# or the stable version from CRAN
install.package("bookdownplus")
Firstly check your working directory (getwd()
) and make sure that it is empty. bookdownplus
will generate lots of files. An empty folder as a working directory is highly recommended. If you don’t know how to change your working directory with R command, you can use RStudio to create a new project (File – New Project - New Directory – Empty Project) and work always in this project.
Run the following codes:
Now a demo dissertation for the University of Bayreuth is generated in many formats in the _book/
folder in your working directory. Open _book/ubt.pdf
or other files so as to get an impression.
bd()
is a simplified function for demos. The main function of the bookdownplus package is:
with multiple parameters.
For example,
bookdownplus(template = 'ubt', render = TRUE)
You can see some other files (e.g. index.Rmd
, body.Rmd
, -bookdownplus.Rproj
) and folders. Write your own texts in body.Rmd
and revise the author and the book title in index.Rmd
. You can use RStudio or any other text editor (but please don’t use Microsoft Word).
After writing some texts, open -bookdownplus.Rproj
with RStudio, and press ctrl+shift+b
to build your own lovely book.
By default, the book is built in a .pdf file and an .md file. From ‘bookdownplus v1.0.3’, users can get more output formats, including word, html and epub. From ‘bookdownplus v1.2.0’, uses can see the available output formats by running:
You can specify the more_output
argument in the bookdownplus()
function:
bookdownplus(more_output = get_output())
Then all the required output files are in _book/
folder.
By default, the book is built from the ‘ubt’ template. From ‘bookdownplus v1.2.0’, users can see the available templates by running:
A template with a name ended with ’_zh’ means that it supports Chinese characters. To list all these Chinese templates, run:
grep('_zh$', get_template()[, 'name'], value = TRUE)
You can specify the template
argument in the bookdownplus()
function:
bookdownplus(template = get_template()$name[1])
Then all the required output files are in _book/
folder.
Now it is time to witness the miracles. With the following magic trick you will see what bookdownplus can do.
Chinese users can run the following codes, and go and have a coffee break. When you come back, you will get more than 20 demo books generated from available templates, each in .pdf, .doc, .html, and .epub formats, in _book/
:
bd()
Non-Chinese users might encounter some errors because their computers do not support Chinese characters in the demo books. Instead, run the following codes, which exclude the Chinese templates and the remote templates:
my_t <- get_template()
my_t <- my_t$name[my_t$location == 'local' & !grepl('_zh$', my_t$name)]
bd(my_t)
I have been developing some other packages, which bring more features into ‘bookdown’, such as:
mindr (Zhao 2017b), which can extract the outline of your book and turn it into a mind map, and
pinyin (Zhao 2017c), which can automatically generate ‘{#ID}’ of the chapter headers even if there are Chinese characters in them.
Both of them have been released on CRAN and can be installed via install.packages('mindr')
and install.packages('pinyin')
.
Enjoy your bookdowning!
pandoc_args
changed from --chapters
into --top-level-division=chapter
rproj
added to bookdownplus()
function so that users can avoid creating an .Rproj file automatically._zh
means this template supports Chinese characters.ice
and ocean
.poster_theme()
which lists available poster themes.output_name
added. Thenbookdownplus()
can render the demo files automatically. You don’t have to open a .Rproj file to generate the template files any more!render = FALSE
in bookdownplus()
to switch it off.more_output()
: display available output formats besides pdf_booktemplate()
: display available templatesmail_bodysize()
: display available fontsize for mail bodymail_font()
: display available fonts for mail bodymail_fontsize()
: display available fontsize for mail templatemail_style()
: display available styles for mail templatemail_theme()
: display available themes for mail templatehelp(bookdownplus)
Xie, Yihui. 2016. Bookdown: Authoring Books and Technical Documents with R Markdown. https://github.com/rstudio/bookdown.
Zhao, Peng. 2017a. Bookdownplus: Generate Varied Types of Books and Documents with R ’Bookdown’ Package. https://CRAN.R-project.org/package=bookdownplus.
———. 2017b. Mindr: Convert Files Between Markdown or Rmarkdown Files and Mindmaps. https://CRAN.R-project.org/package=mindr.
———. 2017c. Pinyin: Convert Chinese Characters into Pinyin. https://CRAN.R-project.org/package=pinyin.