Skip to content
Prev 348558 / 398500 Next

Getting Rmarkdown to generate custom LaTEX environment

On 25/02/2015 1:53 PM, Thierry Onkelinx wrote:
But rmarkdown is based on knitr, which is very flexible.  Presumably it 
is possible (and probably not that hard) to generate code to insert 
native LaTeX automatically.  It might look something like this, with the 
details filled in:

hook_fullpage <- function(before, options, envir) {
   # save the options
   # edit the options to set fig.env, which I think is a knitr concept
   # call the knitr latex hook
   # restore the options
}

knitr::knit_hooks$set(fullpage = hook_fullpage)

Then any chunk where you wanted this kind of inclusion you'd use the 
fullpage=TRUE option, and knitr
would insert a bit of LaTeX code into the middle of your markdown document.

Duncan Murdoch