TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 10 down vote accepted

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.

share|improve this answer
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}.... – raxacoricofallapatorius Feb 21 '12 at 22:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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