Text Formattingadvanced use of enumerate

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
itatitl
Posts: 13
Joined: Thu Mar 24, 2011 8:20 am

Re: advanced use of enumerate

Post by itatitl »

Thank you; that works.

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

itatitl
Posts: 13
Joined: Thu Mar 24, 2011 8:20 am

advanced use of enumerate

Post by itatitl »

There is a problem with the counter while using nested enumeration.

Code: Select all

\documentclass{article}

\newcommand\itemone{\stepcounter{enumi}\item[$\ast$\, \theenumi.]}
\newcommand\itemtwo{\stepcounter{enumi}\item[$\ast\ast$\, \theenumi.]}
\newcommand\itemthree{\stepcounter{enumi}\item[$\ast\ast\ast$\, \theenumi.]}

\begin{document}
\begin{enumerate} \item Consider the following items
\begin{enumerate}
  \itemone first item.
  \item second item.
  \itemone third item.
  \itemtwo fourth item.
  \itemthree fifth item.
  \itemone sixth item.
\end{enumerate}
\item This is the second item of the main list
\end{enumerate}
\end{document}
hugovdberg
Posts: 133
Joined: Sat Feb 25, 2012 6:12 pm

advanced use of enumerate

Post by hugovdberg »

I think I know what your problem is, but you don't explain what you would like to accomplish. I guess your main problem is that the nested list actually starts at 2, and the second item of the outer list continues from where the previous nested list ended. If you always use the asterisked version as a nested list you could simply change the references to counter enumi to enumii, this is the counter for the second level. This makes sure the second item of the nested list also gets the correct number. Since this counter is by default setup with an alphabetic counter between brackets I changed that as well for consistency. A code snippet showing the new \newcommands:

Code: Select all

\newcommand\itemone{\stepcounter{enumii}\item[$\ast$\, (\theenumii)]}
\newcommand\itemtwo{\stepcounter{enumii}\item[$\ast\ast$\, (\theenumii)]}
\newcommand\itemthree{\stepcounter{enumii}\item[$\ast\ast\ast$\, (\theenumii)]}
Ubuntu 13.10 + Tex Live 2013 + Texmaker / Windows 7 Pro + MikTex 2.9 + TexnicCenter / Android 4.3 + TexPortal + DroidEdit
Post Reply