6

Sorry the question is a bit awkward.

Basically I have nested \begin{enumerate} lists. I'd like something to appear like this:

1 Foo
 1.1 Bar
 Please see additional information in subsection 1
   1.1.1 Baz

But when I use this code:

\begin{enumerate}
  \item Foo
  \begin{enumerate}
     \item Bar
     Please see additional information in subsection \ref{test}
     \begin{enumerate}
       \item Baz
       \label{test}
     \end{enumerate}
  \end{enumerate}
\end{enumerate}

It appears like this:

1 Foo
 1.1 Bar
   Please see additional information in subsection 1.1.1
   1.1.1 Baz

When the nesting gets heavy, it ends up looking a lot uglier ("see subsection 3(d)iC"). Is there a way to just list the final nesting level? I've tried to simplify my code to make it a bit easier to read. Hopefully it doesn't confuse the issue.

4

enumitem provides separate label and ref components to its lists. So, you could have a different representation of your reference to an item than the label that is set for that item. Here's an example:

enter image description here

\documentclass{article}
\usepackage{enumitem}% http://ctan.org/pkg/enumitem
\begin{document}
\begin{enumerate}[label=\arabic*]
  \item Foo
  \begin{enumerate}[label*=(\alph*)]
     \item Bar
     Please see additional information in subsection \ref{test}
     \begin{enumerate}[label*=\roman*,ref=\roman*]
       \item Baz
       \label{test}
     \end{enumerate}
  \end{enumerate}
\end{enumerate}
\end{document} 

Although I've defined the list construction together with its usage, this can be performed globally. See section 5 Global settings (p 9) of the enumitem documentation.

This also interfaces seamlessly with hyperref.

  • This appears to be what I'm looking for. I can get the specific labels to work as you showed in this example, but I can't seem to get the global settings working? For instance: \documentclass{article} \usepackage{enumitem} \setlist[enumerate]{label=\Roman} \begin{document} \begin{enumerate} \item Foo \item Bar \end{enumerate} \end{document} – aardvarkk May 6 '13 at 15:22
  • That shows a list with Arabic numerals instead of Roman numerals as I'd expect. – aardvarkk May 6 '13 at 15:22
  • I'm using version 2.2 of the enumitem package. Maybe that's the problem? That's what came with TeX Live for my Ubuntu distribution, but from the documentation it appears to be very old compared to the latest version. – aardvarkk May 6 '13 at 15:29
  • @aardvarkk: The distribution on Ubuntu is notoriously out-of-date and yes, I would think that the outdated version of the package is the problem (it should be 3.5.2). See How do I update my TeX distribution? and maybe Where do I place my own .sty files, to make them available to all my .tex files? (in a pinch). – Werner May 6 '13 at 15:34
  • 1
    @aardvarkk Wow I was getting the same error. Google sent me to your comment. Thanks for replying with your solution! I have no idea how I missed that. – Paul Aug 26 '17 at 2:19
7

Please always post complete documents not just fragments. You can redefine the prefix used at each level of list to be empty.

enter image description here

\documentclass{article}
\makeatletter
\renewcommand\p@enumi{}
\renewcommand\p@enumii{}
\renewcommand\p@enumiii{}
\renewcommand\p@enumiv{}
\makeatother
\begin{document}

\begin{enumerate}
  \item Foo
  \begin{enumerate}
     \item Bar
     Please see additional information in subsection \ref{test}
     \begin{enumerate}
       \item Baz
       \label{test}
     \end{enumerate}
  \end{enumerate}
\end{enumerate}

\end{document}
  • +1 This definitely gets me where I was headed, but I think @Werner has an answer which more closely matched my intent and feels a bit more clean (in my opinion). Thanks so much for your help! – aardvarkk May 6 '13 at 16:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.