Search Contact information
University of Cambridge Home Department of Engineering
University of Cambridge >  Engineering Department >  computing help
next up previous contents
Next: Packages Up: Customising Previous: Modifications

New Commands

A completely new command can be created using

\newcommand{\ commandname}[number of arguments]{ command text, using #1, #2 etc to denote arguments}

For example,

\newcommand{\ve}[1]{\(#1_1 ... #1_n\)}
\ve{x}
produces as output x1 ... xn

A problem with this example is that it shouldn't change to math mode if LATEX is already in that mode. A better try would be

\newcommand{\ve}[1]{\ensuremath{#1_1 ... #1_n}}
which will only change to math mode if it's necessary.

A new environment is just as easily created - give the name of the environment, and what you want to happen on entering and leaving the environment. The following provides a variant of the itemize command.

\newenvironment{emlist}{\begin{itemize} \em}{\end{itemize}}
\begin{emlist}
\item first comment
\item second comment
\end{emlist}
The end of the environment ends the scope of the emphasis.
The end of the environment ends the scope of the emphasis.



© Cambridge University Engineering Dept
Information provided by Tim Love
2006-08-30