Document Classes ⇒ Enumeration package: Can \ref print the whole label?
Enumeration package: Can \ref print the whole label?
i have a question concerning the enumeration package of David Carlisle and the \ref - command.
I have the following code:
\begin{enumeration}[Step (1)]
\item \label{AA} ...
.
.
.
\end{enumeration}
Then \ref{AA} just prints '1'. Is there a way to change this behaviour such that \ref{AA} prints the whole label and not just the number, i. e. 'Step 1'?
Thank you
Michi
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
Enumeration package: Can \ref print the whole label?
to customise the list-like environments I would recommend you to use the enumitem package. Your example:
Code: Select all
\documentclass{book}
\usepackage{enumitem}
\begin{document}
\begin{enumerate}[label=Step (\arabic*)]
\item \label{AA}
\item \label{BB}
\end{enumerate}
As can be seen in \ref{AA}...
\end{document}
Enumeration package: Can \ref print the whole label?
Code: Select all
\documentclass{article}
\begin{document}
\begin{enumerate}
\renewcommand{\theenumi}{Step (\arabic{enumi})}
\item\label{AAA} Text.
\item More text.
\end{enumerate}
Here we write a reference to \ref{AAA}.
\begin{enumerate}
\renewcommand{\theenumi}{[\Roman{enumi}]}
\renewcommand{\labelenumi}{\textbf{Level \theenumi}.-}
\item\label{BBB} Text
\item More text
\end{enumerate}
Here we write a reference to level or stage \ref{BBB}.
\end{document}
For numbered nested lists, you may need to replace enumi by enumii, enumiii or enumiv in the above code. Note that:
- \ theenumi controls the way the counter is printed (think in the way you would like to print the counter in a future reference to the corresponding item);
- \ labelenumi indicates how the full label should be printed;
- the redefinition of both commands should be done inside the enumerate environment in order to not change any subsequent list.