Debian Codegraph @

man/hook_document.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/hooks-latex.R
3 \name{hook_movecode}
4 \alias{hook_movecode}
5 \title{Some potentially useful document hooks}
6 \usage{
7 hook_movecode(x)
8 }
9 \arguments{
10 \item{x}{A character string (the whole output document).}
11 }
12 \value{
13 The post-processed document as a character string.
14 }
15 \description{
16 A document hook is a function to post-process the output document.
17 }
18 \details{
19 \code{hook_movecode()} is a document hook to move code chunks out of LaTeX
20 floating environments like \samp{figure} and \samp{table} when the chunks
21 were actually written inside the floats. This function is primarily designed
22 for LyX: we often insert code chunks into floats to generate figures or
23 tables, but in the final output we do not want the code to float with the
24 environments, so we use regular expressions to find out the floating
25 environments, extract the code chunks and move them out. To disable this
26 behavior, use a comment \code{\% knitr_do_not_move} in the floating
27 environment.
28 }
29 \note{
30 These functions are hackish. Also note \code{hook_movecode()} assumes
31 you to use the default output hooks for LaTeX (not Sweave or listings), and
32 every figure/table environment must have a label.
33 }
34 \examples{
35 \dontrun{
36 knit_hooks$set(document = hook_movecode)
37 }
38 # see example 103 at https://github.com/yihui/knitr-examples
39 }
40 \references{
41 \url{https://yihui.org/knitr/hooks/}
42 }