Generalthe problem about theenumi

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
clement
Posts: 15
Joined: Wed Oct 14, 2009 5:06 am

the problem about theenumi

Post by clement »

hi:

I have a problem about the example 3-3-4 in book the latex companion.
the codes are as following:

Code: Select all

\usepackage{calc,pifont}  \newcounter{local}
\renewcommand\theenumi{\protect\setcounter{local}%
  {171+\the\value{enumi}}\protect\ding{\value{local}}}
\renewcommand\labelenumi{\theenumi}
....
\begin{document}
\begin{enumerate}
.....
\end{enumerate}
however, I don't know why to set the value of counter to {171+\the\value{enumi}}, and the command protect is really necessary?
thanks.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

the problem about theenumi

Post by josephwright »

The part reading

Code: Select all

\setcounter{local}{171+\the\value{enumi}}
sets up counter "local" so that it will turn into a symbol in the right part of the font. The value 171 is simply moving to the correct slots in the font to find the symbols wanted: try altering the value to see the effect.

\protect is needed here to prevent \setcounter being expanded at the wrong time. This often happens when stuff is written to a table of contents or other external file. Using \protect if it is not needed is very rarely wrong: it just does nothing.
Joseph Wright
Post Reply