-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmy_knitter.R
53 lines (43 loc) · 1.23 KB
/
my_knitter.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
## knitter functions for changing colors, etc
colorize <- function(x, color) {
if (knitr::is_latex_output()) {
sprintf("\\textcolor{%s}{%s}", color, x)
} else if (knitr::is_html_output()) {
sprintf("<span style='color: %s;'>%s</span>", color, x)
} else x
}
sk2 <- function() {
if (knitr::is_latex_output()) {
sprintf("\\bigskip")
} else if (knitr::is_html_output()) {
sprintf("<br><br>")
} else NULL
}
sk1 <- function() {
if (knitr::is_latex_output()) {
sprintf("\\medskip")
} else if (knitr::is_html_output()) {
sprintf("<br>")
} else NULL
}
myblue <- function(x) {
if (knitr::is_latex_output()) {
sprintf("\\textcolor{%s}{%s}", "blue", x)
} else if (knitr::is_html_output()) {
sprintf("<span style='color: %s;'>%s</span>", "dodgerblue", x)
} else x
}
myred <- function(x) {
if (knitr::is_latex_output()) {
sprintf("\\textcolor{%s}{%s}", "red", x)
} else if (knitr::is_html_output()) {
sprintf("<span style='color: %s;'>%s</span>", "red", x)
} else x
}
mygrn <- function(x) {
if (knitr::is_latex_output()) {
sprintf("\\textcolor{%s}{%s}", "FG", x)
} else if (knitr::is_html_output()) {
sprintf("<span style='color: %s;'>%s</span>", "ForestGreen", x)
} else x
}