Text FormattingList numbering problems using the enumerate package

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
nick1234
Posts: 4
Joined: Thu Nov 11, 2010 12:39 pm

List numbering problems using the enumerate package

Post by nick1234 »

Hello all,

Hope someone can help with this, I've spent quite a long time on it already and can't seem to find anything that solves my problem.

I am trying to use the enumerate package to generate a numbered list like this:

1 text text text
1.1 text text text
1.1.1 text text text
1.1.2 text text text
2 text text text

but the default list formatting appears like

1 text text text
a text text text
i text text text
etc.

I first tried adding this to my the top of the file:

\\renewcommand{\\labelenumi}{\\arabic{enumi}}
\\renewcommand{\\labelenumii}{\\arabic{enumii}}
\\renewcommand{\\labelenumiii}{\\arabic{enumiii}}
\\renewcommand{\\labelenumiv}{\\arabic{enumiv}}

If I do this then the side item numbers appear as I would like but when I use any \label{labelName} \ref{labelName} pairs to refer to other items in the list, the item numbers inserted in place of the \ref{labelName} still appear as 2c, 1b etc.

I then tried doing this:

\\renewcommand{\\theenumi}{\\arabic{enumi}}
\\renewcommand{\\labelenumi}{\\theenumi}
\\renewcommand{\\theenumii}{.\\arabic{enumii}}
\\renewcommand{\\labelenumii}{\\theenumi\\theenumii}
\\renewcommand{\\theenumiii}{.\\arabic{enumiii}}
\\renewcommand{\\labelenumiii}{\\theenumi\\theenumii\\theenumiii}
\\renewcommand{\\theenumiv}{.\\arabic{enumiv}}
\\renewcommand{\\labelenumiv}{\\theenumi\\theenumii\\theenumiii\\theenumiv}

With these commands it almost all works fine except that the output for the \ref{labelName} is displayed like 1(.2).2 seemingly still using some default formatting, which looks a bit strange. Is there any way to get rid of these brackets?

It seems like i am missing some sort of styling for the inline references.
As you can probably tell I'm pretty clueless when it comes to latex so would be really grateful for any help.

I have had a brief look at the enumitem package but dont really think that is what im looking for. Any suggestions on how to get this method to work?
Last edited by nick1234 on Thu Aug 11, 2011 9:31 am, edited 1 time in total.

Recommended reading 2024:

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

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

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

List numbering problems using the enumerate package

Post by frabjous »

enumitem can do what you want, no problem.

Code: Select all

\documentclass{article}
\usepackage{enumitem}
\setlist[enumerate,1]{label=\arabic*}
\setlist[enumerate,2]{label*=.\arabic*}
\setlist[enumerate,3]{label*=.\arabic*}
\setlist[enumerate,4]{label*=.\arabic*}
\begin{document}
\begin{enumerate}
\item Something
\begin{enumerate}
\item Something
\begin{enumerate}
\item Something \label{smthg}
\end{enumerate}
\end{enumerate}
\end{enumerate}
\ref{smthg}
\end{document}

nick1234
Posts: 4
Joined: Thu Nov 11, 2010 12:39 pm

Re: List numbering problems using the enumerate package

Post by nick1234 »

Ohhh ok. That looks pretty good. Thanks for the quick response. The only problem is that I would like my sub points to be like:

1
_1.1
_1.2
__1.2.1

so you can see where exactly you are in the document. Currently the sub points don't show the parent point number too(if that makes sense). Can't get white space to show up so have just used '_'

1
_1
_2
__1

Is there any way to do this with the enumitem package?

Thanks again.
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Re: List numbering problems using the enumerate package

Post by frabjous »

It shows the parent subpoints when I try my code above. Be sure to use label*= instead of label= for \setlist[enumerate,2]{...} and above.
nick1234
Posts: 4
Joined: Thu Nov 11, 2010 12:39 pm

Re: List numbering problems using the enumerate package

Post by nick1234 »

Ah right, sorry my fault for not reading it properly. :oops:

Thanks very much that is working perfectly now!
Post Reply