I want to create an enumerated list with description of items and a label assigned so that each item can individually be referenced by \ref
or \nameref
It is obvious how to do this manually but I would like to save myself a bit of work and create some commands to have latex do the job
This is the LaTeX code I want to atomise
\begin{enumerate}[label=\textbf{T\,\arabic*},leftmargin=1cm]
\item \textit{caption} \label{itm:1}
\end{enumerate}
now I would like to reference the label like this
\ref{itm:1}
>> T1
\nameref{itm:1}
>> (T1) caption
referencing subsequent items accordingly by increasing the counter
any idea / help is highly appreciated
Best Answer
This uses a wrapper command
\myitem
to grab the item text and stores it into\@currentlabelname
, which is needed by\nameref
to use the 'name' properly!Update -- With automatic labelling, be careful on reset on the enumerate list!
The
Ti1
is the first label of the first level of an enumerate, theTii1
,Tiii1
andTiv1
will be the relevant labels of deeper levels.