I'm working on a knitr document and trying to place knitr output inside of a new environment defined using the environ package.

The example below illustrates the problem. With a traditional LaTeX environment definition, the resulting LaTeX output is as expected and the document compiles with no problems. (I want to use environ for other reasons.) But using the environ package, the resulting LaTeX is identical (except for the relevant lines indicated below) but the document won't compile, throwing multiple errors.


% This works

% This doesn't


l <- list(a=1)

The situation is similar to that described in this earlier question but in this case, the inner environment is actually four nested knitr environments. To my reading, this means that both of the solutions offered on that question (the accepted one and the newenviron package) are probably impossible here or at least very ugly. Any suggestions?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.