Text Formattingchange \ref of item in deep list

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
R0berto
Posts: 2
Joined: Sat May 08, 2010 8:22 pm

change \ref of item in deep list

Post by R0berto »

Hi there!

I've been searching the web for a solution for this problem for some time now. I couldn't find a solution, so I thought I'd post it here.
So here goes:

I have an enumerated list 4 levels deep. I labeled all the items, because I want to use the references in a table somewhat later. Only the format of the \ref is wrong. It now displays as: 2(e)iiiA
whereas I would like it to be: 2.e.iii-A (or 2.e.iii.A if that is easier).

I hope someone can help me resolve this problem, because it shouldn't be that difficult, I guess...

Code: Select all

\documentclass{article}
\begin{document}

\begin{enumerate}
	\item One \label{one}
		\begin{enumerate}
			\item One.a \label{onea}
				\begin{enumerate}
					\item One.a.one \label{oneaone}
						\begin{enumerate}
							\item One.a.one-A \label{oneaonea}
						\end{enumerate}
				\end{enumerate}
		\end{enumerate}
\end{enumerate}

\ref{one} should be 1\\
\ref{onea} should be 1.a\\
\ref{oneaone} should be 1.a.i\\
\ref{oneaonea} should be 1.a.i-A (or 1.a.i.A)\\

\end{document}
Last edited by R0berto on Sat May 08, 2010 9:35 pm, 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.

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

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

change \ref of item in deep list

Post by gmedina »

Hi,

try the enumitem package:

Code: Select all

\documentclass{article}
\usepackage{enumitem}
\begin{document}

\begin{enumerate}
   \item One \label{one}
      \begin{enumerate}[ref=\arabic*.\alph*]
         \item One.a \label{onea}
            \begin{enumerate}[ref=\arabic*.\alph*.\roman*]
               \item One.a.one \label{oneaone}
                  \begin{enumerate}[ref=\arabic*.\alph*.\roman*--\Alph*]
                     \item One.a.one-A \label{oneaonea}
                  \end{enumerate}
            \end{enumerate}
      \end{enumerate}
\end{enumerate}

\noindent\ref{one}\\
\ref{onea}\\
\ref{oneaone}\\
\ref{oneaonea}\\

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
R0berto
Posts: 2
Joined: Sat May 08, 2010 8:22 pm

Re: change \ref of item in deep list

Post by R0berto »

thanks a million!

that's exactly what I needed :)
Post Reply