Under certain conditions (triggered by selection of a package option) I would like to change specific environments into margin notes. However marginnote is not itself an environment, but a command that takes its contents as an argument. So what I want to do is replace




but I clearly cannot do this with something like

    {\marginnote{ }
    { }}

What is the correct way to replace an environment with a command that takes the environment's contents as an argument?


The environ package may be of help here. You define an environment using

  % environment contents

and the contents of the environment is available in the macro \BODY. Here's a minimal example:

enter image description here

\usepackage{marginnote}% http://ctan.org/pkg/marginnote
\usepackage{environ}% http://ctan.org/pkg/environ
  \marginnote{\BODY}% Place contents of <someenvironment> in a \marginnote
Here is some text with a margin note.
This is a margin note.

\NewEnviron has a macro-like look to it, so the usage should be fairly intuitive.

  • Thanks, that worked, thigh it ended up begin a bit more complicated in my case. I'm redefining an already defined environment, and end up with a lot of floats, so I had to \usepackage[maxfloats=36]{morefloats} and \let\existingenv ... \NewEnviron{existingenv}.... – orome Feb 21 '12 at 22:25

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.