I want to reference an item of an enumerate list by it's normal label, if we are still in that same enumeration and by an parent.item
syntax if we are somewhere else in the document. For example:
\documentclass{scrartcl}
\usepackage[colorlinks]{hyperref}
\makeatletter
\newcounter{entity}
\def\theentity{\Roman{entity}}
\newenvironment{entity}[1]{\refstepcounter{entity}\@startsection{entity}{4}{-1em}{\baselineskip}{.1\baselineskip}{\bfseries}{\theentity. Entity: #1}}{}
\newcommand\entitymark{\@gobble}
\newcommand\toclevel@entity{3}
\newcommand\l@entity{\@gobbletwo}
\newcommand\entityautorefname{Entity}
\newcommand\entityname{Entity}
\makeatother
\begin{document}
\begin{entity}{Test1}
\begin{enumerate}
\item Some text \label{label}!
\item Some more text, oh and \autoref{label}.
\end{enumerate}
\end{entity}
Even more text and here: \autoref{label}.
\begin{entity}{Test2}
Referencing \ref{label} again.
\end{entity}
\end{document}
Now the references are item 1
, item 1
and 1
. But I want them to be printed as item 1
, entity 1 item 1
and 1.1
.
The aux
file contains a line like:
\newlabel{label}{{1}{1}{\theentity . Entity: Test1\relax }{Item.1}{}}
which I could maybe access via \r@label
if I understand egreg correctly. But currently it does not contain any information about which entity
it was defined in. Can I add that somehow?