# customizing individual enumerate keys

I want to customize (say underline) individual enumerate keys. Here is a MWE:

\documentclass[11pt]{book}

\begin{document}

\begin{enumerate}

\item OK

\begin{enumerate}

\item Should be $\rm(\underline a).$

\item OK

\end{enumerate}

\item Should be $\underline 2.$

\item OK

\end{enumerate}

\end{document}


• Please don't use \rm and it's not necessary to switch to math mode for \underline – user31729 Sep 13 '15 at 6:14
• If such an \item is followed by \label, the counter in the \ref does not seem to increase properly. – Chris Impens Sep 13 '15 at 8:01

You should update the counter in question manually in two ways:

1. Stepping it, either with \stepcounter or \refstepcounter if you want proper referencing capability;

2. Setting the appropriate format as the optional argument to \item[..].

\documentclass{article}

\begin{document}

\begin{enumerate}
\item OK
\begin{enumerate}
\refstepcounter{enumii}% \stepcounter{enumii}
\item[(\underline{\theenumii})] Should be (\underline{a}).
\item OK
\end{enumerate}
\refstepcounter{enumi}% \stepcounter{enumi}
\item[\underline{\theenumi}.] Should be \underline{2}.
\item OK
\end{enumerate}

\end{document}


The first level of enumerate has counter enumi, the second level has enumii, ...

• Maybe it's better to use \refstepcounter instead of \stepcounter, because the latter doesn't work with \label-\ref system. – skevin93 Sep 13 '15 at 8:39
• @skevin93: Done. – Werner Sep 13 '15 at 14:30

The changing of individual keys is 'difficult', by design, since this breaks the consistent typesetting!

However, it's possible by using the optional argument to the \item macro.

Using \item[\underline{\theenumi}] (\theenumi outputs the counter value of the first enumeration level) is not sufficient, since at this time of typesetting the counter isn't stepped. Using \refstepcounter before is possible. I decided to show another way, with \numexpr.

Some notes:

• Don't use \rm -- it's deprecated in LaTeX
• It's not necessary to switch to math mode for \underline

\documentclass[11pt]{book}

\begin{document}

\begin{enumerate}

\item OK

\begin{enumerate}
\refstepcounter{enumii}
\item[\underline{(\theenumii)}] Should be \underline{(\theenumii)}.

\item OK

\end{enumerate}

\item[\underline{\the\numexpr\number\value{enumi}+1}.\refstepcounter{enumi}] Should be \underline{2}. and is \underline{2}. now!
\refstepcounter{enumi}
\item[\underline{enumi}.] Does work also
\item OK

\end{enumerate}

\end{document}