1

I would like the use the package showlabels to display the labels of everything I have in my document, as https://www.overleaf.com/learn/latex/Latex-questions/Keep_track_of_your_labels_with_showlabels demonstrates. I'm using the newtcbtheorem environment to create theorem/lemma boxes, which automatically come with labels (as discussed here: Main text of tcbtheorem environment absorbed into options). However

\documentclass{article}
\usepackage{amsmath}
\usepackage{tcolorbox}
\tcbuselibrary{theorems}
\tcbuselibrary{breakable}
\usepackage[colorlinks = true, urlcolor = red]{hyperref}
\usepackage{pifont}
\usepackage{showlabels}


\newtcbtheorem[number within=section]{mylemma}{Lemma}%
{colframe=blue!45!white,enlarge top by=0.15cm,before
skip=3pt,after skip=6.5pt,fonttitle=\slshape,breakable}{lem}

\usepackage{thmtools}
\declaretheorem[name=Theorem,numberwithin=section]{thm}

\begin{document}


\[
E=mc^2 \label{eq:einstein} \tag{\ding{37}}
\]
As we can see from \eqref{eq:einstein}

\begin{mylemma}{Substitution lemma}{substitution}
Lemma in a tcolorbox
\end{mylemma}
Reference to the lemma \ref{lem:substitution}
\end{document}

the lemma box is not visibly labelled in the output (whereas the explicitly \labeled equation is): enter image description here (MWE inspired in part by Label equation with a symbol).

1 Answer 1

0

You mention that theorem/lemma boxes automatically define labels, such as lem:substitution. My guess would be that that's doing it in such a way that it's using the original definition of \label, rather than the one that showlabels has altered. I would have thought that the definition used would be the one in effect when {mylemma} is expanded, but I can imagine circumstances where it is instead the definition in effect when {mylemma} is defined.

If so, then it might be that this would magically work if you were to put showlabels before the package that defines {mylemma}. Otherwise, it would involve stepping through what {mylemma} is actually doing, to see what definition of \label it's using.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .