2.1 Markdown syntax

In this section, we give a very brief introduction to Pandoc’s Markdown. Readers who are familiar with Markdown can skip this section. The comprehensive syntax of Pandoc’s Markdown can be found on the Pandoc website http://pandoc.org.

2.1.1 Inline formatting

You can make text italic by surrounding it with underscores or asterisks, e.g., _text_ or *text*. For bold text, use two underscores (__text__) or asterisks (**text**). Text surrounded by ~ will be converted to a subscript (e.g., H~2~SO~4~ renders H2SO4), and similarly, two carets (^) produce a superscript (e.g., Fe^2+^ renders Fe2+). To mark text as inline code, use a pair of backticks, e.g., `code`.3 Small caps can be produced by the HTML tag span, e.g., <span style="font-variant:small-caps;">Small Caps</span> renders Small Caps. Links are created using [text](link), e.g., [RStudio](https://www.rstudio.com), and the syntax for images is similar: just add an exclamation mark, e.g., ![alt text or image title](path/to/image). Footnotes are put inside the square brackets after a caret ^[], e.g., ^[This is a footnote.]. We will talk about citations in Section 2.8.

2.1.2 Block-level elements

Section headers can be written after a number of pound signs, e.g.,

If you do not want a certain heading to be numbered, you can add {-} after the heading, e.g.,

Unordered list items start with *, -, or +, and you can nest one list within another list by indenting the sub-list by four spaces, e.g.,

The output is:

  • one item
  • one item
  • one item
    • one item
    • one item

Ordered list items start with numbers (the rule for nested lists is the same as above), e.g.,

The output does not look too much different with the Markdown source:

  1. the first item
  2. the second item
  3. the third item

Blockquotes are written after >, e.g.,

The actual output (we customized the style for blockquotes in this book):

“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

Plain code blocks can be written after three or more backticks, and you can also indent the blocks by four spaces, e.g.,

2.1.3 Math expressions

Inline LaTeX equations can be written in a pair of dollar signs using the LaTeX syntax, e.g., $f(k) = {n \choose k} p^{k} (1-p)^{n-k}$ (actual output: \(f(k)={n \choose k}p^{k}(1-p)^{n-k}\)); math expressions of the display style can be written in a pair of double dollar signs, e.g., $$f(k) = {n \choose k} p^{k} (1-p)^{n-k}$$, and the output looks like this:


You can also use math environments inside $ $ or $$ $$, e.g.,

\[\begin{array}{ccc} x_{11} & x_{12} & x_{13}\\ x_{21} & x_{22} & x_{23} \end{array}\]

\[X = \begin{bmatrix}1 & x_{1}\\ 1 & x_{2}\\ 1 & x_{3} \end{bmatrix}\]

\[\Theta = \begin{pmatrix}\alpha & \beta\\ \gamma & \delta \end{pmatrix}\]

\[\begin{vmatrix}a & b\\ c & d \end{vmatrix}=ad-bc\]

  1. To include literal backticks, use more backticks outside, e.g., you can use two backticks to preserve one backtick inside: `` `code` ``.