5 Lifestyle

5.1 Journal

A demo book produced by the 'journal' template.

Figure 5.1: A demo book produced by the ‘journal’ template.

You can write a laboratory journal or a personal diary with the ‘journal’ template (Fig. 5.1) by simply running:

bookdownplus(template = 'journal')

Your will get a book file named ‘journal.pdf’ in ’_book/’ folder as an example.

If you would like to specify the title and author, you can run the following code instead:

bookdownplus(template = 'journal',
             author = 'John Smith',
             title = 'My journal')

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 journal book. You could revise the title and author list in ‘index.Rmd’.

You might notice the wide margin of the pages. The margins are for your future use, i.e. adding comments or notes.

The ‘journal’ template is built on the basis of the LaTeX class ‘labbook.cls’ by Frank Küster. You could customize ‘style/labbook.cls’ if you are an expert on LaTeX.

5.2 Poem book

A poem book produced with ‘bookdownplus’ looks like Fig. 5.2. You can write such a book with the ‘poem’ template by simply running:

bookdownplus(template = 'poem')

Your will get a book file named ‘poem.pdf’ in ’_book/’ folder as an example.

A demo book produced by the 'poem' template.

Figure 5.2: A demo book produced by the ‘poem’ template.

If you would like to specify the title and author, you can run the following code instead:

bookdownplus(template = 'poem',
             author = 'John Smith',
             title = 'My Poem book')

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 poem book. You could revise the title and author list in ‘index.Rmd’.

In ‘body.Rmd’ you can use the mark \bb{} to enlarge the first letter of each paragraph of a poem.

5.3 Music

Writing books including music pieces is difficult. Think about how to do it in Microsoft Word. Fortunately ‘bookdown’ works on the top of LaTeX, and there are LaTeX solutions for music books.

For example, you can write a guitar chord book by simply running:

bookdownplus(template = 'guitar')

Your will get a book file named ‘guitar.pdf’ in ’_book/’ folder as an example. The book looks like Fig. 5.3.

A guitar chord book

Figure 5.3: A guitar chord book

If you would like to specify the title and author, you can run the following code instead:

bookdownplus(template = 'guitar',
             author = 'John Smith',
             title = 'My Guitar book')

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 guitar chord book. You could revise the title and author list in ‘index.Rmd’.

Open ‘body.Rmd’, and you could see how the chords are inserted. For example, the mark \F means ‘F chord’, and the mark \Am means ‘A minor chord’. These marks are pre-defined by users in ‘tex/template_guitar.tex’. I have defined some often-used chords. If you are interested, you can add more chords and share them with me, so that we could build a complete chord library for ‘bookdownplus’ users. The method to define a new chord can be found in the documentation of ‘gchord,’21 which is a LaTeX package for typesetting guitar chord diagrams by Kasper Peeters.

Writing a guitar chord book22 is the upper limit of my knowledge in music. I would not go further in this direction, but you can do more with ‘bookdown’ if you want to. For instance, the ‘musixtex’ package23 of LaTeX makes it possible to typesetting music like Fig. 5.4. I guess it should not be difficult to tailor it into ‘bookdownplus’. Be brave to do it!

Typesetting music with musixtex package.

Figure 5.4: Typesetting music with musixtex package.