forked from yihui/knitr-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
044-size.Rnw
41 lines (29 loc) · 812 Bytes
/
044-size.Rnw
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
\documentclass{article}
\begin{document}
The size option controls the font size of chunks. This is the default size:
<<>>=
head(iris)
@
This is scriptsize:
<<size='scriptsize'>>=
head(iris)
@
The size does not work when results = 'asis':
<<test-asis, size='small', results='asis'>>=
cat(letters, sep = ' ')
@
But you can use a hook to add the size environment in this case:
<<setup, include=FALSE>>=
library(knitr)
knit_hooks$set(size = function(before, options, envir) {
# bring back the size environment when results='asis'
if (options$results != 'asis') return()
paste('\\end{kframe}',
sprintf(if (before) '\\begin{%s}' else '\\end{%s}', options$size),
'\\begin{kframe}', sep = '')
})
@
<<ref.label='test-asis', size='scriptsize', results='asis'>>=
@
Move on!
\end{document}