Saturday, January 16, 2010

Indenting an item in an enumerate environment in LaTeX

To indent an item in a list in LaTeX, we will use the following two commands:

\setlength\itemindent{size}

And we will use it like such:

\begin{enumerate}
\item This item is not indented
{\setlength\itemindent{25pt} \item This item is indented}
\item This item is not indented
{\setlength\itemindent{25pt} \item This item is indented}
{\setlength\itemindent{25pt} \item This item is indented}
\item This item is not indented
\end{enumerate}

This will generate the following:





We can improve the above code by making use of the \newcommand to encapsulate \setlength and \itemindent into a single command :

\newcommand{\indentitem}{\setlength\itemindent{25pt}}

\begin{enumerate}
\item This item is not indented
{\indentitem \item This item is indented}
\item This item is not indented
{\indentitem \item This item is indented}
{\indentitem \item This item is indented}
\item This item is not indented
\end{enumerate}