# Mis-referencing of a label from an enumerate environment

MWE:

\documentclass[12pt]{article}
\usepackage{icomma}
\usepackage[english]{babel}
\newcommand{\bookcite}[6]{#1, #2: \textit{#3}. #4 ed. #5, #6 pp.}
\usepackage{enumitem}
\usepackage{hyperref}
\hypersetup{
urlcolor=blue
}
\begin{document}
Text Text Text
\tableofcontents
\newpage
\section{Section Here}
\begin{enumerate}[label=(\thesection.\arabic*)]
\item \begin{enumerate}[label={(\alph*)},ref=(\thesection.\arabic*.\alph*)]
\item \bookcite{Authors}{Year}{Title}{Edition}{Publisher}{Number of Pages}\label{book-A}
\item \bookcite{Authors}{Year}{Title}{Edition}{Publisher}{Number of Pages} \label{book-B}
\end{enumerate}
\item \ref{book-B}
\end{enumerate}
\end{document}


Image:

The reference, shown in blue as (1.2.b), should not be (1.2.b), but rather, (1.1.b). What am I doing wrong here?

I've narrowed it down to either the label not being liked (for some reason, a hyphen in the ref is problematic) or it doesn't like my bookcite command. (Note: I do know some BibTeX... if it could potentially give me better results than what I have here, I would love to know about it!)

• In my point of view the \label command should be directly after \item, otherwise following code could have an \refstepcounter hidden (it's not the case here, I know), which would lead to a wrong label setting. (This comment is no solution to the problem) – user31729 Mar 31 '16 at 3:36

The error is ref={(\thesection.\arabic*.\alph*)}, precisely the command \arabic*, since this will be replaced by enumii (it's the 2nd level) and not as requested, refering backward to the higher level enumi.

It's somehow stated in the enumitem manual, that ref is not inherited and one has to use \ref{level1} etc (but this is an unclear statement, in my point of view.)

One solution is to explicitly refer to \arabic{enumi} in the middle part of the user defined reference of the second level, i.e.

\begin{enumerate}[label={(\alph*)},ref={(\thesection.\arabic{enumi}.\alph*})]
...


as 2nd level setting.

\documentclass[12pt]{article}
%\usepackage{icomma} % Is this needed?
\usepackage[english]{babel}
\newcommand{\bookcite}[6]{#1, #2: \textit{#3}. #4 ed. #5, #6 pp.}
\usepackage{enumitem}
\usepackage{hyperref}
\hypersetup{
urlcolor=blue
}
\begin{document}
Text Text Text
\tableofcontents
\newpage
\section{Section Here}
\begin{enumerate}[label=(\thesection.\arabic*),ref={(\thesection.\arabic*)}]
\item
\begin{enumerate}[label={(\alph*)},ref={(\thesection.\arabic{enumi}.\alph*})]
\item \label{book-A}\bookcite{Authors}{Year}{Title}{Edition}{Publisher}{Number of Pages}
\item \label{book-B}\bookcite{Authors}{Year}{Title}{Edition}{Publisher}{Number of Pages}
\end{enumerate}
\item \ref{book-B}
\end{enumerate}
\end{document}