# hook_movecode

0th

Percentile

##### Some potentially useful document hooks

A document hook is a function to post-process the output document.

##### Usage
hook_movecode(x)
##### Arguments
x

A character string (the whole output document).

##### Details

hook_movecode() is a document hook to move code chunks out of LaTeX floating environments like figure and table when the chunks were actually written inside the floats. This function is primarily designed for LyX: we often insert code chunks into floats to generate figures or tables, but in the final output we do not want the code to float with the environments, so we use regular expressions to find out the floating environments, extract the code chunks and move them out. To disable this behavior, use a comment % knitr_do_not_move in the floating environment.

##### Value

The post-processed document as a character string.

##### Note

These functions are hackish. Also note hook_movecode() assumes you to use the default output hooks for LaTeX (not Sweave or listings), and every figure/table environment must have a label.

##### References

https://yihui.name/knitr/hooks/

##### Aliases
• hook_movecode
##### Examples
# NOT RUN {
knit_hooks\$set(document = hook_movecode)
# }
# NOT RUN {
# see example 103 at https://github.com/yihui/knitr-examples
# }

Documentation reproduced from package knitr, version 1.22, License: GPL

### Community examples

Looks like there are no examples yet.