Hao Zhu | e10cfd3 | 2017-02-21 16:41:14 -0500 | [diff] [blame] | 1 | --- |
| 2 | title: add_footnote - PDF |
| 3 | output: pdf_document |
Hao Zhu | 9495658 | 2017-02-21 18:18:29 -0500 | [diff] [blame^] | 4 | vignette: > |
| 5 | %\VignetteIndexEntry{Use add_footnote in PDF document} |
| 6 | %\VignetteEngine{knitr::rmarkdown} |
| 7 | %\VignetteEncoding{UTF-8} |
Hao Zhu | e10cfd3 | 2017-02-21 16:41:14 -0500 | [diff] [blame] | 8 | --- |
| 9 | |
| 10 | # Through Pandoc |
| 11 | ```{r through_pandoc} |
| 12 | library(knitr) |
| 13 | library(kableExtra) |
| 14 | dt <- mtcars[1:5, 1:2] |
| 15 | colnames(dt)[1] <- c("mpg[note]") |
| 16 | rownames(dt)[2] <- c("Mazda RX4 Wag[note]") |
| 17 | dt[3, 2] <- paste0(dt[3, 2], "[note]") |
| 18 | |
| 19 | kable(dt) %>% |
| 20 | add_footnote(c("footnote 1", "footnote 2", "footnote 3")) |
| 21 | ``` |
| 22 | |
| 23 | # Through LaTeX |
| 24 | ## Plain LaTeX |
| 25 | ```{r through_latex_plain} |
| 26 | kable(dt, format = "latex") %>% |
| 27 | add_footnote(c("footnote 1", "footnote 2", "footnote 3")) |
| 28 | ``` |
| 29 | |
| 30 | ## LaTeX + booktabs |
| 31 | ```{r through_latex_booktabs} |
| 32 | kable(dt, format = "latex", booktabs = T) %>% |
| 33 | add_footnote(c("footnote 1", "footnote 2", "footnote 3")) |
| 34 | ``` |
| 35 | |
Hao Zhu | c541563 | 2017-02-21 17:16:13 -0500 | [diff] [blame] | 36 | ## LaTeX + longtable + booktabs |
| 37 | Centered Table + page footnotes |
Hao Zhu | e10cfd3 | 2017-02-21 16:41:14 -0500 | [diff] [blame] | 38 | ```{r through_latex_longtable} |
Hao Zhu | c541563 | 2017-02-21 17:16:13 -0500 | [diff] [blame] | 39 | kable(dt, format = "latex", longtable = T, booktabs = T) %>% |
| 40 | add_footnote(c("footnote 1", "footnote 2", "footnote 3")) |
Hao Zhu | e10cfd3 | 2017-02-21 16:41:14 -0500 | [diff] [blame] | 41 | ``` |