jbezos / enumitem

Customize enumerate, itemize and description
MIT License
48 stars 5 forks source link

Option "label" adds an extra pair of braces to \cs{the\@enumctr} #23

Open muzimuzhi opened 4 years ago

muzimuzhi commented 4 years ago

When option label is used, an extra pair of braces is added to \cs{the\@enumctr}, which influences \@currentlabel. This may break macros aiming to retrieve value from a label, for example the \gerrefnumber from refcount package (see this TeX-SX question as an example).

Is this pair of braces a must?

\documentclass{article}
\usepackage{enumitem}

\begin{document}
\makeatletter
\def\test{\meaning\@currentlabel}
\makeatother

\begin{enumerate}
  \item text \test
  % this defines \@currentlabel to "1"
\end{enumerate}

\begin{enumerate}[label=\arabic*., ref=\arabic*]
  \item text \test
  % this defines \@currentlabel to "{1}"
\end{enumerate}
\end{document}

Related source code, see line 548: https://github.com/jbezos/enumitem/blob/1bdcad0987823b3716c86b126b3863f895ea9c4a/enumitem.sty#L541-L551