Enumerating list with correct reference

  • LaTeX
  • Thread starter psie
  • Start date
  • Tags
    Latex
  • #1
psie
261
32
TL;DR Summary
I have a couple of enumerating lists in a document. Item 3 in list number 1 reads (1c) and so on. When I label an item in a list, and refer to that item in the text, I only get the output (c), so on printed paper you can't tell where this reference leads to.
Apologies if this is a simple fix, but I currently do not see it. I also appreciate any other advice on how to structure my document in regards to having several enumerating lists.

Currently, equations are numbered by numbers (1), (2), etc., so I can't use just numbers for my enumerating lists. Therefor I've chosen (1a), (1b), etc. for the items in list 1 and so on. Basically these lists are remarks made after definitions and theorems.

Here's some code:

Code:
\documentclass{article}
\usepackage{enumerate}

\newcounter{foo}

\AtBeginEnvironment{enumerate}{\addtocounter{foo}{1}}

\begin{document}

\begin{enumerate}[({\thefoo}a)]
\item one
\item two
\end{enumerate}

text

\begin{enumerate}[({\thefoo}a)]
\item one
\item two \label{list2item2}
\end{enumerate}

Item (\ref{list2item2}) prints as (b). But I want it to appear as (2b) or something similar.

\end{document}
 
Physics news on Phys.org
  • #2
Code:
\documentclass{article}
\usepackage{enumitem}

\newcounter{nestedenumerate}

\newlist{NestedEnumerate}{enumerate}{1}
\setlist[NestedEnumerate]{label=(\thenestedenumerate\alph*)}

\usepackage{etoolbox}
\AtBeginEnvironment{NestedEnumerate}{\refstepcounter{nestedenumerate}}

\begin{document}
    
    \begin{NestedEnumerate}
        \item\label{enum:spec} one
        \item two
    \end{NestedEnumerate}
    
    text; see item \ref{enum:spec}.
    
    \begin{NestedEnumerate}
        \item one
        \item two
    \end{NestedEnumerate}
    
    text
        
\end{document}
 

Similar threads

Replies
1
Views
5K
Replies
1
Views
6K
Replies
2
Views
21K
Replies
3
Views
450
Replies
7
Views
11K
Replies
1
Views
7K
Replies
1
Views
2K
Back
Top