3 Experimenting with Bookdown
3.1 Old Content
You can label chapter and section titles using {#label}
after them, e.g., we can reference Chapter 2. If you do not manually label them, there will be automatic labels anyway, e.g., Chapter ??.
Figures and tables with captions will be placed in figure
and table
environments, respectively.
Reference a figure by its code chunk label with the fig:
prefix, e.g., see Figure 3.1. Similarly, you can reference tables generated from knitr::kable()
, e.g., see Table 2.1.
Sepal.Length | Sepal.Width | Petal.Length | Petal.Width | Species |
---|---|---|---|---|
5.1 | 3.5 | 1.4 | 0.2 | setosa |
4.9 | 3.0 | 1.4 | 0.2 | setosa |
4.7 | 3.2 | 1.3 | 0.2 | setosa |
4.6 | 3.1 | 1.5 | 0.2 | setosa |
5.0 | 3.6 | 1.4 | 0.2 | setosa |
5.4 | 3.9 | 1.7 | 0.4 | setosa |
4.6 | 3.4 | 1.4 | 0.3 | setosa |
5.0 | 3.4 | 1.5 | 0.2 | setosa |
4.4 | 2.9 | 1.4 | 0.2 | setosa |
4.9 | 3.1 | 1.5 | 0.1 | setosa |
5.4 | 3.7 | 1.5 | 0.2 | setosa |
4.8 | 3.4 | 1.6 | 0.2 | setosa |
4.8 | 3.0 | 1.4 | 0.1 | setosa |
4.3 | 3.0 | 1.1 | 0.1 | setosa |
5.8 | 4.0 | 1.2 | 0.2 | setosa |
5.7 | 4.4 | 1.5 | 0.4 | setosa |
5.4 | 3.9 | 1.3 | 0.4 | setosa |
5.1 | 3.5 | 1.4 | 0.3 | setosa |
5.7 | 3.8 | 1.7 | 0.3 | setosa |
5.1 | 3.8 | 1.5 | 0.3 | setosa |
You can write citations, too. For example, we are using the bookdown package (Xie 2024) in this sample book, which was built on top of R Markdown and knitr (Xie 2015).
3.2 New Content
“I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him.”
— Mark Twain
This text is displayed verbatim / preformatted
3.2.1 Experimenting with Mathematical Expressions
\[\begin{array}{ccc} x_{11} & x_{12} & x_{13}\\ x_{21} & x_{22} & x_{23} \tag{3.1} \end{array}\]
\[\begin{align} \Pr(D_i=1) &= 50, \nonumber \\ &=30, \nonumber \\ &=40.\tag{3.2} \end{align}\]
\[\begin{equation} \begin{aligned} \Pr(D_i=1) &= 50, \\ &=30, \\ &=40 . \end{aligned} \tag{3.3} \end{equation}\]
\[\begin{equation} f\left(k\right) = \binom{n}{k} p^k\left(1-p\right)^{n-k} \tag{3.4} \end{equation}\]
Let us reference array (3.1), then (3.2), and finally (3.3).
Theorem 3.1 (Pythagorean Theorem) This is a theorem
environment that can contain any Markdown syntax.
Let us reference Theorem 3.1
Proof (Proof of Pythagorean Theorem 3.1). This is a proof.