A document hook function to move code out of floating environments
This 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.
- a character string (the content of the whole document output)
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
in the floating environment.
- The post-processed document as a character string.
This function is hackish. It assumes you to use the default output hooks for LaTeX (not Sweave or listings), and every figure/table environment must have a label.
knit_hooks$set(document = hook_movecode)