Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wrap LaTeX command in environment

Tags:

How can I wrap a LaTeX command in an environment? In essence, how can I turn \somecommand{contents} into \begin{somecommand} contents \end{somecommand}? I have tried the obvious in creating a new environment as such:

\newenvironment{somecommand}[0]{   \somecommand{ } {   } } 

but this causes problems with the curly brackets. Let me give a more concrete example. Say that you want to create the environment very-important and you want to use the command emph to accomplish this. An straightforward (but incorrect) solution would be to write something as

\newenvironment{very-important}[0]{   \emph{ } {   } } 

The problem here is that the command works with the information that is found inside the environment, so it is not one of the opening commands of the environment, nor is it a closing command of the environment. The question is then: how can you do this?

like image 290
kvaruni Avatar asked Dec 09 '09 10:12

kvaruni


1 Answers

This can be done with the environ package as follows:

 \usepackage{environ} ... \NewEnviron{very-important}{\emph{\BODY}} 

\BODY contains the body of the environment, and environments may be nested. See the documentation for more details.

like image 122
Will Robertson Avatar answered Oct 22 '22 20:10

Will Robertson