Writing academic articles with ‘bookdown’ was my original intention of developing ‘bookdownplus’. This chapter comes so late because I would not like those non-academic users to be scared. Actually, writing academic articles is the most beautiful essence of ‘bookdown’ from my point of view. Only in an academic article can users utilize the full support of superscripts, subscripts, footnotes, equations, tables, reproducible figures, citations, and cross-references.
An academic article produced with ‘bookdownplus’ looks like Fig. 7.1. You can write such an article with the ‘article’ template by simply running:
bookdownplus(template = 'article')
Your will get a book file named ‘article.pdf’ in ’_book/’ folder as an example.
If you would like to specify the title and author, you can either run the following code instead:
bookdownplus(template = 'article', author = 'John Smith', title = 'My article')
In your working directory you could now open ‘bookdownplus.Rproj’ with RStudio. Write your own text in ‘index.Rmd’ and ‘body.Rmd’, and press ‘ctrl+shift+b’ to build your own article. You could revise the title and author list in ‘index.Rmd’.
By default, the ‘article’ templates uses the two-columned LaTeX package by Copernicus Publications.24 They provide a template for discussion layout as well, which was tailored as the ‘discussion’ template:
bookdownplus(template = 'discussion')
For the sake of the copyright, you can find in the header the following texts:
Manuscript prepared for J. Name with version 4.2 of the LATEX class copernicus.cls.
You can remove them for personnel use if you don’t like it. Open ‘style/copernicus.cls’ with a text editor, and remove or revise Line 1006 and 1192.
Furthermore, numerous academic journals provide their own LaTeX templates. Although I will add more article templates to ‘bookdownplus’ in the future, it would be appreciated if you join me and share your work.
An academic thesis produced with ‘bookdownplus’ looks like Fig. 7.2. Multiple templates for thesis are available in ‘bookdownplus’. You can create such a thesis with the ‘thesis_ubt’ template by simply running:
bookdownplus(template = 'thesis_ubt')
Your will get a book file named ‘thesis_ubt.pdf’ in ’_book/’ folder as an example.
In your working directory you could now open ‘bookdownplus.Rproj’ with RStudio. Press ‘ctrl+shift+b’ to build it.
The postfix ‘ubt’ is the abbreviation of University of Bayreuth (UBT) where I achieved my PhD. The ‘thesis_ubt’ template is actually originated from the LaTeX file of my PhD dissertation. Thanks to my UBT colleagues who taught me how to use LaTeX.
To modify the demo thesis into your own, you have to go through more steps than creating single articles due to the complicated structure of a dissertation. Don’t worry. Follow me and you can eat it like a piece of cake.
The main part of your thesis can be written in ‘body.Rmd’ and ‘index.Rmd’ in the same way as other templates. Congratulations! You have done 90% of the work.
Open ‘tex/template_thesis_ubt.tex’ with a text editor (e.g. ‘NotePad++’). Now you see scary LaTeX codes in it. Be brave. You will conquer them.
In Line 68 – 82 you can specify your own subject, institute, supervisor’s name, etc.
In Line 94 – 119 you can modify them into the symbols and abbreviations of your own. If you don’t need them, just remove these lines.
In Line 122 – 136 you can remove the chapters you don’t need, but leave
$body$is the location where the content of ‘body.Rmd’ will be inserted.
Now it is done.
The dissertation of UBT requires some chapters written in German, which you can see in ‘tex/template_thesis_ubt.tex’. I leave them there for the convenience of those users studying in German speaking regions. If you don’t need them, just simply remove them as you like.
Besides ‘thesis_ubt’, a simple template called ‘thesis_mypku_zh’ can be performed for those written in Chinese:
bookdownplus(template = 'thesis_mypku_zh')
This template was modified from ‘yihui_zh’ template with some pages from my master thesis in Peking University (PKU). Be careful, though, if you use this template to write your PKU thesis. There have been official requirements for the thesis format recently, which is different from my thesis written more than a decade ago.
Other templates for academic thesis are ‘thesis_classic’ and ‘thesis_zju_zh’. The pdf version of this book you are reading now is created with ‘thesis_classic’ by Andre Miede.25 You can see how it works in the source code of this book.26 For example, you could add a
subtitle field in the YAML header of ‘index.Rmd’, then the subtitle apprears on the cover page of the book.
The ‘thesis_zju_zh’ template is modified from the LaTeX template of thesis of Zhejiang University, which will be described in Chapter 7.2.
Numerous universities and institutes provide their own LaTeX templates for thesis. Although I will add more thesis templates to ‘bookdownplus’ in the future, it would be appreciated if you join me and share your work.
I did not expect to create academic posters with R ‘bookdown’ or ‘markdown’, because I think posters are not necessarily as structured as articles. Microsoft Powerpoint is still the easiest way to make a poster. A poster created in markdown syntax has its own advantages, though. It is reproducible, easy to maintain, easy to change the style, and has the common features of R markdown. You could see the posters generated by ‘bookdownplus’ in Fig. 7.3. Not bad, hmmm?
The procedure of creating a poster template is different from other ‘bookdownplus’ templates. Firstly, you have to prepare the software environment. Windows users can do the following steps:
Install Python 2.
Install Python filter support for Pandoc: on a Windows command prompt, type
pip install pandocfilters
Install SumatraPDF for auto-refresh of PDF previews
Add the Python directory to the system PATH variable (Computer – right click – Properties – Advanced System Settings – Environmental Variables – PATH – Edit).
Linux users can refer to the instruction of kuleuven-templates,27 which is the origin of the ‘poster’ template.
Now you can create such a poster with the ‘poster’ template by running:
bookdownplus(template = 'poster', theme = 'eco', email = 'youremail@email', institute = 'your institute', web = 'http://youdomain.com', logo = 'your logo picture', backimg = 'your background image', bibliofiles = 'your bib file')
In ‘bookdownplus()’, only
theme have to be specified. Other arguments are optional, which can be modified later.
Three themes for posters are available in ‘bookdownplus 1.0.2’: ‘eco’ (default), ‘ocean’, and ‘rose’. Of course you can create your own theme on the basis of ‘tex/poster_eco.tex’ if you are a LaTeX expert .
In your working directory you could now open ‘index.Rmd’ with RStudio. Click the ‘Knit’ button in the toolbar of the top-left panel, and you will get a file named ‘index.pdf’ in your working directory as a demo. However, the Bibliography section in the poster is empty. Click the ‘Knit’ button once again and it will be filled. If you know how bibtex works, it will be easy to understand why you have to knit twice. But just do it and never be bothered.
As you know the steps of creating a demo poster, now it is time to build your own poster. I would recommend you to read the demo ‘index.Rmd’ from A to Z, then you will get all the ideas of the key elements in a markdown poster. Besides the common bookdown syntax, the following is a list of specific ones for the poster:
[columns=2]to make a new row split into 2 columns and
[/columns]to end the row. Use
[column]to start a new column in the row.
\vskip0.5cmto adjust the verticle blank space in a column.
\printbibliographyto create the Bibliography section.
Have you noticed something? The hot key or button of building a ‘bookdown’ document has never been used for the ‘poster’ template! Indeed ‘bookdownplus’ poster template is nothing to do with ‘bookdown’. It is a ‘markdown’ solution for posters extracted from kuleuven-templates28 with my additional contribution. I put it in the ‘bookdownplus’ package only because poster is a piece of the puzzle in academic productions, and I would like to build ‘bookdownplus’ as a complete academic tool.
In the meanwhile I am developing a stand-alone version of the poster template as the ‘postr’ package (Zhao 2017e) for non ‘bookdown’ users. This stand-alone version is more advanced and up-to-date with some more themes and features. For instance, it has a function for removing unnecessary files and folders bi-produced by the poster template.
A chemistry article or book produced with ‘bookdownplus’ looks like Fig. 7.4. You can write such a book with the ‘chemistry’ template by simply running:
bookdownplus(template = 'chemistry')
Your will get a book file named ‘chemistry.pdf’ in ’_book/’ folder as an example.
In your working directory you could now open ‘bookdownplus.Rproj’ with RStudio. Write your own text in ‘index.Rmd’ and ‘body.Rmd’, and press ‘ctrl+shift+b’ to build your own chemistry book. You could revise the title and author list in ‘index.Rmd’.
In ‘body.Rmd’ you can see how to insert chemical formulae, chemical equations, and structural formulae. For more details, please see the ‘mhchem’ LaTeX package by Martin Hensel.29
Zhao, Peng. 2017e. Postr: Generage Posters with R Markdown. https://github.com/pzhaonet/postr.