knitr::opts_chunk$set(echo = TRUE)
不需額外安裝字體,此套件提供便捷的函數直接下載。
plot(pressure)
以下內容完全根據 @xie2016 所撰寫。
(ref:plot2-caption) 使用 ggplot2
繪製 iris
數據。這段文字用於 figure caption 可使用 R Markdown 語法,甚至 inline code chunk。此圖繪製於 r Sys.Date()
。
plot(pressure)
同樣的邏輯也可應用於表格上:
(ref:iris-table-caption) 這是使用 bookdown
Text Reference 產生的 table caption。
knitr::kable(iris[1:5, 1:3], caption = '(ref:iris-table-caption)')
章節、圖片、表格,皆可透過 bookdown
的特殊語法 \@ref(label)
在文章任意處建立超連結。要建立超連結前,需要先有 ID。
\@ref(label)
中的 label
依據使用的是章節、圖片或表格[^reference]會有所不同:
章節:ID
圖片:fig:code-chunk-label
表格:tab:code-chunk-label
為章節建立 ID 的方式很簡單,只要在標題後面加上 {#<id>}
即可
## 章節 ID {#section-ref}
圖片與表格的 ID 即是生成它們的 R code chunk 的 label -- ```r
。
透過
\@ref(id)
連結 Section \@ref(section-ref)
\@ref(fig:plot2)
連結 Fig. \@ref(fig:plot2)
\@ref(tab:iris-table)
連結 Table \@ref(tab:iris-table)
[^reference]: 此外,bookdown
還提供了數學公式與定理的引用。
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.