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

amsthm, cleveref, \newtheorem, shared counter, \label #773

Open
alexanderperlis opened this issue Dec 20, 2024 · 2 comments
Open

amsthm, cleveref, \newtheorem, shared counter, \label #773

alexanderperlis opened this issue Dec 20, 2024 · 2 comments

Comments

@alexanderperlis
Copy link

Thankfully firstaid seems to make amsthm and cleveref usable in many circumstances, allowing tagging experiments on existing documents.

Here's a particular combination that currently won't compile (on MacTeX, TeX Live 2024, both pdfTeX and LuaTeX, LaTeX2e 2024-11-01, L3 layer 2024-11-02, nor under pdflatex-dev or lualatex-dev, LaTeX2e 2025-06-01 pre-release-1 2024-12-18 branch, L3 layer 2024-12-09):

\DocumentMetadata{testphase={phase-III,firstaid}}
\documentclass{article}
\usepackage{amsthm}
\usepackage{cleveref}

\newtheorem{theorem}{Theorem}[section]
\newtheorem{proposition}[theorem]{Proposition}

\begin{document}

\begin{proposition}
\label{mylabel}   % <--- error ("Something's wrong--perhaps a missing \item")
\end{proposition}

\end{document}

Key ingredients:

  • Loading amsthm before loading cleveref (as instructed in cleverref documentation)
  • Loading cleveref before calling \newtheorem (as instructed in cleverref documentation)
  • Defining a theorem type that uses someone else's counter
  • Using \label with that theorem type

Error goes away with any one of the following (undesirable) changes:

  • Comment-out \DocumentMetadata line
  • Comment-out \usepackage{amsthm} line
  • Comment-out \usepackage{cleveref} line
  • Swap order of \usepackage{amsthm} and \usepackage{cleveref}
  • Give proposition its own counter: \newtheorem{proposition}{Proposition}[section]
  • Move \usepackage{cleveref} below the various \newtheorem
@krypt-n
Copy link

krypt-n commented Dec 20, 2024

Quick notes (since I'm also interested in this combination of packages):

  • the same compilation error happens for me without the \label

  • using lualatex-dev (develop 2024-12-19 branch), I get a different error:

! LaTeX template Error: The instance '\l__block_block_instance_tl -\int_use:N
(template)              \g_block_nesting_depth_int ' of type 'block' is
(template)              unknown.

@u-fischer
Copy link
Member

when cleveref is loaded after amsthm it overwrites the new tagging code for the theorems and so breaks tagging. Try what happens if you load it before amsthm, it is probably easier to solve whatever problem arisethere.

Or consider to use e.g. zref-clever instead of cleveref. cleveref contains so many patches that is is quite hard to make it fully tagging compatible.

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

3 participants