D RMarkdown/Bookdown 排版示例

本文无意全文翻译 RMarkdown/Bookdown 的使用方法,只是简单的复制,详细内容请参考页面:

以下为全文复制 https://bookdown.org/yihui/bookdown/components.html ,有改动。

This chapter demonstrates the syntax of common components of a book written in bookdown, including code chunks, figures, tables, citations, math theorems, and equations. The approach is based on Pandoc, so we start with the syntax of Pandoc’s flavor of Markdown.

D.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.

D.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`.1 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 D.8.

D.1.2 Block-level elements

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

# First-level header

## Second-level header

### Third-level header

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

# Preface {-}

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.,

- one item
- one item
- one item
    - one item
    - one item

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.,

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

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.,

> "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