# Referencing section title and enumerate item number

I have multiple sections with enumerations in them. Given a reference, is it possible to get the section name it belongs to? And also the item number as well.

For example, given this code (with fictionary commands itemref and secref)

\section*{Example title}
\begin{enumerate}
\item first one
\item second one \label{ref:anchor}
\end{enumerate}

\section*{Second title}
See item \itemref{ref:anchor} in section \secref{ref:anchor}.


the result would be

Example title
1. first one
2. second one

Second title
See item 2 in section "Example title".

I've found numerous ways to reference a section name, but as I understand it, the anchor must be the section itself, which wouldn't work in my case since I move items around in this document and I'd like it to be dynamic.

EDIT: I have a working solution with the enumitem package for the item number reference, so only the section name is missing.

• With \section*, you're not going to have a section number. – TH. Jun 27 '17 at 6:54
• @TH. That's intentional, since my section titles contain only numbers and it would be confusing. Hence my need to reference section with titles. – rubik Jun 27 '17 at 6:55

The zref package can help you out here.

\documentclass{article}
\usepackage{enumitem}
\usepackage[titleref,user]{zref}
\ztitlerefsetup{}

\newcommand*\itemlabel[1]{%
\label{#1}%
\zlabel{#1}%
}
\newcommand*\itemref[1]{\ref{#1}}
\newcommand*\secref[1]{\ztitleref{#1}''}

\begin{document}

\section*{Example title}
\begin{enumerate}
\item first one
\item second one\itemlabel{ref:anchor}
\end{enumerate}

\section*{Second title}
See item~\itemref{ref:anchor} in Section \secref{ref:anchor}.
\end{document}


The one real difference to what you posted is I defined an \itemlabel macro which you need to use in place of \label.

• Thanks a lot, the zref packages seems really powerful. Your solution is perfect! – rubik Jun 27 '17 at 7:58