This is somewhat a follow-up question to "Vertical spacing in enumitem list".
Note that the question is incorporated into the example below.
\documentclass{article}
\usepackage{enumitem}
\makeatletter
\def\myitem{%
\@ifnextchar[ \@myitem{\@noitemargtrue\@myitem[\@itemlabel]}}
\def\@myitem[#1]{\item[#1]\mbox{}}
\makeatother
\setlist[enumerate,1]{
wide = 0\parindent,
listparindent = 0pt,
label = \textbf{Exercise~\arabic*}
}
\setlist[enumerate,2]{
wide = 0\parindent,
listparindent = 0pt,
label = \textbf{\alph*)}
}
\begin{document}
\noindent \underline{Example code:}
\begin{enumerate}
\myitem
\begin{enumerate}
\item Something.
\item Something.
\end{enumerate}
\myitem
\begin{enumerate}
\item Something.
\item Something.
\end{enumerate}
\myitem
\begin{enumerate}
\item Something.
\item This is exercise~\textbf{3b)}.
\end{enumerate}
\underline{Question:} Can I avoid manually labeling every single \verb|\item| and \verb|\myitem| and then -- somehow -- combine these labels to get the number of both \verb|\item| and \verb|\myitem| in a single reference?
Example: If I write \verb|This is exercise~\ref{3b}| I would like to get the output ``This is exercise~\textbf{3b)}'' without having to put a \verb|\label| after the \verb|\item|.
\end{enumerate}
\end{document}



\ref. You can simply writeThis is exercise~3b). – Ulrike Fischer Jun 17 '15 at 14:18\label{\myitem-number\item-number-within-the-\myitem}. Then the reference should change automatically when I insert a new exercise or a new question within the exercise. (I hope it makes sense but I'm not sure it does...) P.S. I have to go for tonight (Danish time.) – Svend Tveskæg Jun 17 '15 at 14:21\labels is that they don't change when you add a new item. It does no good for me to use\label{equation1}if I subsequently add an equation before that one. If I know that there will never be an equation before the one I labeled equation1 then I may as well not use thelabelrefparadigm altogether and just write "Equation 1" in the text of the document. Thelabelreffunctionality of LaTeX allows us to define what a thing is based on its context, rather than its location and that is a strength of the system. – Paul Stiverson Jun 17 '15 at 14:43\ref{item.n-1)has to change to\ref{item.n-2)when an item is inserted. – Ulrike Fischer Jun 18 '15 at 08:33\ref{1a}" without actually stating "1" because as you point out we could insert an item at the top of the list which would make this ref obsolete. If possible to use relative refs to compare rigidly spaced/clustered items, this would be in the list only as no where else would n be changing with each sequentially produced item. – EngBIRD Jun 19 '15 at 07:44