3 Basic

3.1 Markdown Syntax

This chapter briefly introduces Markdown and its syntax in ‘bookdown’. You can skip this chapter if you are already an R ‘bookdown’ user. This chapter is a simply memo comprised of some summarized notes without detailed explanation. You can check this chapter if you forget something when using ‘bookdown’. The details and explanations of the syntax can be found in the bookdown manual16 or the Markdown cheatsheets in RStudio - Help - Cheatsheets.

3.1.1 What is Markdown

‘bookdownplus’ is based of ‘bookdown’, which is based on ‘markdown’. Markdown is a lightweight markup language with plain text formatting syntax.17 It means, for example, if you want to display italic texts in your document, you don’t choose your texts and click an format button of ‘italic’ like what you do in Microsoft Word. Instead, you type *my texts* and the italic texts my texts will be displayed in your output documents.

One of the advantages of such a markup language is that the typing is fast. You don’t have to move your fingers between your keyboard and your mouse. Another advantage is that it is easy to change the style or formats of your document. For example, you can replace all CO2 with CO~2~, then the chemical formula of carbon dioxide will be displayed as CO2 .

3.1.2 Basic syntax

marks output
*Italic* Italic
**bold** bold
CO~2~ CO2 (subscript)
R^2^ R2 (superscript)
$E = mc^2$ \(E = mc^2\) inline equation
($$ for displayed equation)
[hyperlink](http://pzhao.net) [hy perlink](http://pzhao.net)
<pzhao@pzhao.net> pzhao@pzhao.net email
![](hyperlink of figure) insert a figure
> quote quote
code
# Chapter One chapter title
1. First numbered list
- First unnumbered list
^[footnote] footnote
<!-- hidden texts --> hidden texts

3.1.3 Chapters

# (PART) Part I {-} 
# (APPENDIX) Appendix {-} 
# References {-}
# chapter {#ID}
## section {#ID}
# chapter {#ID .unnumbered}

\@ref(ID)

3.1.4 Figures and tables

A figure can be inserted with R plotting codes:

```{r, fig.cap='caption', out.width='80%', 
fig.align='center', echo=FALSE}
plot(1:10)
```

\@ref(fig:fig1)

or with R inserting codes:

```{r img1, fig.cap='caption', out.width='80%', 
fig.align='center', echo=FALSE}
knitr::include_graphics("images/img1.png")
```

\@ref(fig:img1)

or with markdown basic syntax:

![caption](images/img1.png)

A table can be inserted with basic markdown syntax:

col one      col two
----------- ----------
row 1.1     row 1.2
row 2.1     row 2.2

and you will get:

col one col two
row 1.1 row 1.2
row 2.1 row 2.2

or with R codes:

```{r tab1, tidy=FALSE, echo=FALSE}
knitr::kable(
head(iris, 20), caption = 'Here is a nice table!',
booktabs = TRUE
)
```

\@ref(tab:tab1)

3.1.5 References

Bibliography entries must be saved in .bib.

Citation: [@R-bookdown] , [@zhao2017; @xie2016]

Bibliography: # References {-}

Created a library of R packages for bibliography:

knitr::write_bib(c("bookdownplus", "beginr"), "", width = 60)
# or
beginr::bib(c("bookdownplus", "beginr"))

3.1.6 Theorems, lemma, definitions, etc.

Full name Abbreviations
theorems thm
lemma lem
definition def
corollary cor
proposition prp
example exm
exercise exr

r {Full name, label=, name=}

\@ref(Abbreviation:label)

3.1.7 Equations numbering

(@eq-mc) $E = mc^2$

I like Eq. (@eq-mc) so much that I am falling love with her.
\begin{equation} 
E = mc^2
  (\#eq:mc2)
\end{equation} 

I like Eq. \@ref(eq:mc2) so much that I am falling love with her.

3.2 R, RStudio and bookdown

3.3 LaTeX and Pandoc

3.4 Workflow