Debian Codegraph @

man/opts_hooks.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/hooks.R
3 \docType{data}
4 \name{opts_hooks}
5 \alias{opts_hooks}
6 \title{Hooks for code chunk options}
7 \format{
8 An object of class \code{list} of length 7.
9 }
10 \usage{
11 opts_hooks
12 }
13 \description{
14 Like \code{\link{knit_hooks}}, this object can be used to set hook functions
15 to manipulate chunk options.
16 }
17 \details{
18 For every code chunk, if the chunk option named, say, \code{FOO}, is not
19 \code{NULL}, and a hook function with the same name has been set via
20 \code{opts_hooks$set(FOO = function(options) { options })} (you can manipuate
21 the \code{options} argument in the function and return it), the hook function
22 will be called to update the chunk options.
23 }
24 \examples{
25 # make sure the figure width is no smaller than fig.height
26 opts_hooks$set(fig.width = function(options) {
27 if (options$fig.width < options$fig.height) {
28 options$fig.width = options$fig.height
29 }
30 options
31 })
32 # remove all hooks
33 opts_hooks$restore()
34 }
35 \references{
36 \url{https://yihui.org/knitr/hooks/}
37 }
38 \keyword{datasets}