When I define a label inside an enumerate-list I get a reference to the item number.
Is it possible to get a reference to the section?
Example:
\documentclass[english]{scrartcl}
\usepackage{babel}
\usepackage{blindtext}
\newcommand\secref[1]{[section of label '#1']}%<-- I ask for this function.
\begin{document}
%Should be: The 2nd item point on page 3 is in section 2.3.1
The \ref{mylabel}nd item point on page \pageref{mylabel} is in section \secref{mylabel}
%Should be: The 2nd item point on page 3 is in section 2.3.1
The \ref{mylabel}nd item point on page \pageref{mylabel} is in section \ref{sec:mylabel}
\blinddocument%create some (sub)sections
\label{sec:mylabel}
\begin{enumerate}
\item point 1
\item \label{mylabel} here is a label
\end{enumerate}
\end{document}
Remark I: I don't want to replace \ref
to show always the section reference. I want to have the choice to get the item reference or the section reference.
Remark II:
The 2nd sentence in my example shows the result I want. But I want to avoid the definition of the help-label sec:mylabel
.
Best Answer
Emit two
\label
commands:This gives
Of course, if
hyperref
is loaded, clicking on the link created by\ref{sec:mylabel}
will take to the item in theenumerate
environment.