Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
muzimuzhi opened this issue Oct 29, 2020 · 0 comments
Open

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

muzimuzhi opened this issue Oct 29, 2020 · 0 comments

Comments

@muzimuzhi
Copy link

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:

enumitem/enumitem.sty

Lines 541 to 551 in 1bdcad0

\def\enit@reflabel#1#2{%
\ifnum\enit@depth=\@ne\else % no level 0
\advance\enit@depth\@ne
\@namedef{p@\@enumctr}{}% Don't accumulate labels
\advance\enit@depth\m@ne
\fi
\ifcase#2%
\@namedef{the\@enumctr}{{#1}}%
\else
\enit@normlabel{\csname the\@enumctr\endcsname}{#1}%
\fi}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant