forked from hadley/adv-r
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_common.R
36 lines (29 loc) · 836 Bytes
/
_common.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
library(methods)
set.seed(1014)
options(digits = 3)
knitr::opts_chunk$set(
comment = "#>",
collapse = TRUE,
cache = TRUE,
out.width = "70%",
fig.align = 'center',
fig.width = 6,
fig.asp = 0.618, # 1 / phi
fig.show = "hold"
)
# Previously in oldbookdown -----------------------------------------------
doc_type <- function() knitr::opts_knit$get('rmarkdown.pandoc.to')
begin_sidebar <- function(title = NULL) {
if (identical(doc_type(), "latex")) {
knitr::asis_output(paste0("\\begin{SIDEBAR}", title, "\\end{SIDEBAR}\n"))
} else {
knitr::asis_output(paste0("<div class = 'sidebar'><h3>", title, "</h3>\n\n"))
}
}
end_sidebar <- function() {
if (identical(doc_type(), "latex")) {
knitr::asis_output("\\begin{ENDSIDEBAR}\\end{ENDSIDEBAR}\n")
} else {
knitr::asis_output("</div>\n")
}
}