Tuesday, June 14, 2011

Defining your own Environments

You can do this with a hack by defining a new command, e.g. define
 \beq as a short cut for \begin{equation}
and
\eeq as a short cut for \end{equation}

But with a new environment foo you can simply use
\begin{foo}
\end{foo}

Two examples (one is a list so it needs to handle counters):

\newcounter{abc}
\newenvironment{abclist}
   {\begin{list}{(\alph{abc})} {\usecounter{abc}} \setlength{\itemsep}{0pt}
                             
  \setlength{\labelwidth}{4em} }
   {\end{list}}

\newenvironment{solution}{\mbox{}\vspace*{\parskip}\\\sf Solution:}{\rm}
 
Usage:
\begin{abclist}
\item
\item
\item
\end{abclist}

\begin{solution}
Put the solution here
\end{solution}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.