4

I'm using enumitem and trying to label items with only their current level, but reference them with their full "absolute" value. Here's a sample document:

\documentclass[letterpaper]{article}
\usepackage{enumitem}
\newlist{parin}{enumerate}{4}
\setlist[parin,1]{label=\arabic*.,ref=\arabic*,leftmargin=*}
\setlist[parin,2]{label=(\alph*),ref=\theenumi\alph*,leftmargin=*}
\setlist[parin,3]{label=(\arabic*),ref=\theenumii\arabic*,leftmargin=*}
\setlist[parin,4]{label=(\roman*),ref=\theenumiii\roman*,leftmargin=*}
\begin{document}
\begin{parin}
\item Foo
\label{foo}
\begin{parin}
\item Bar
\label{bar}
\begin{parin}
\item Baz
\label{baz}
\begin{parin}
\item Label Me
\label{labelme}
\end{parin}
\end{parin}
\end{parin}
\end{parin}
\ref{foo}
\ref{bar}
\ref{baz}
\ref{labelme}
\end{document}

The expected output is for the references to appear as:

1 1a 1a1 1a1i

But instead, they appear as:

1 0a 1 i

Would love some guidance, thanks!

  • Good and instructive question! (Which triggered a nice and instructive answer.) – Sveinung Jan 21 '14 at 20:59
5

Your new list is parin, so the associated counters are parini, parinii, pariniii, and not enumi, enumii, enumiii:

\documentclass[letterpaper]{article}
\usepackage{enumitem}
\newlist{parin}{enumerate}{4}
\setlist[parin,1]{label=\arabic*.,ref=\arabic*,leftmargin=*}
\setlist[parin,2]{label=(\alph*),ref=\theparini\alph*,leftmargin=*}
\setlist[parin,3]{label=(\arabic*),ref=\theparinii\arabic*,leftmargin=*}
\setlist[parin,4]{label=(\roman*),ref=\thepariniii\roman*,leftmargin=*}
\begin{document}
\begin{parin}
\item Foo
\label{foo}
\begin{parin}
\item Bar
\label{bar}
\begin{parin}
\item Baz
\label{baz}
\begin{parin}
\item Label Me
\label{labelme}
\end{parin}
\end{parin}
\end{parin}
\end{parin}
\ref{foo}
\ref{bar}
\ref{baz}
\ref{labelme}
\end{document}

enter image description here

  • Ugh, nice. It must be pretty obvious I have basically no idea what I'm doing. Thanks for the tip! It did the trick and was exactly what I was looking for! – aardvarkk Jan 21 '14 at 17:42

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.