[texhax] enumerate inconsistency
Ulrike Fischer
news3 at nililand.de
Sun Nov 8 13:44:12 CET 2015
Am Sat, 7 Nov 2015 12:20:42 -0800 schrieb William F Hammond:
> Victor Ivrii writes:
>
>> If in {enumerate} item does not have a custom "label" then supplying it
>> with a \label{A} works: \ref{A} returns a value of the standard label.
>>
>> On the other hand, if item has a custom label then \label{C} fails: \ref{C}
>> returns either empty (as in the example below) or value of the larger
>> environment (say, section)
>
> Yes, I think this is the way it is. \ref needs to look at a
> counter.
No, \ref looks at \@currentlabel, and there is no real technical
reason why the optional argument doesn't change it, it is a design
reason, which one can find arguable.
\documentclass[12pt]{article}
%\usepackage{enumitem}
%\usepackage{hyperref}
\begin{document}
%%%Standard labels%%%
\begin{enumerate}
\item one\label{A}
\item two\label{B}
\end{enumerate}
\ref{A} \ref{B}
%%%Custom labels%%%
\begin{enumerate}
\item[oh] \makeatletter \def\@currentlabel{oh} \makeatother
one\label{C}
\item[ah] \makeatletter \def\@currentlabel{ah} \makeatother
two\label{D}
\end{enumerate}
\ref{C} \ref{D}
\end{document}
--
Ulrike Fischer
http://www.troubleshooting-tex.de/
More information about the texhax
mailing list