## Monday, December 25, 2006

### How to create a new environment in LaTeX

This is an example how to create a new environment in latex.
The \newenvironment command have two important parts: the begin code and the and code. The begin code is executed when the environment is initialized (in our case \begin{example}) and the end code executed at the \end{example} command.\documentclass[a4paper,12pt,oneside]{article}\newcounter{Examplecount}\setcounter{Examplecount}{0}\newenvironment{example}{% This is the begin code\stepcounter{Examplecount} {\bf\small Example} \arabic{Examplecount}\scriptsize \begin{it}}{% This is the end code\end{it} }\begin{document}\begin{example}This is an example\end{example}\end{document}

sturmer said...

Thanks, good example.

Anonymous said...

Thank you. This is what I was looking for.

Anonymous said...

Thanks!