JesseStraat / reptheorem

LaTeX Project Public License v1.3c
1 stars 0 forks source link

Repeating "lemmas" does not seem to work when theorems and lemmas share a same counter #11

Closed emalizia closed 1 day ago

emalizia commented 1 day ago

Hi,

It seems that repeating "lemmas" does not work properly when theorems and lemmas share a same counter. The is a MWE:

\documentclass{article}

\usepackage{amsthm}

\usepackage{reptheorem}

\theoremstyle{plain}
\newtheorem{theorem}{Theorem}
\newtheorem{lemma}[theorem]{Lemma}

\begin{document}

\section{First section}

\begin{makethm}{theorem}{thm_one}
This is a theorem.
\end{makethm}

\begin{makethm}{lemma}{thm_two}
This is a Lemma.
\end{makethm}

\repthm{thm_one}

\repthm{thm_two}

\end{document}

The example above does not compile. In the LaTeX log appears ! LaTeX Error: No counter 'lemma' defined. However, when \repthm{thm_two} is commented out, or lemmas have their own counter, i.e., substitute \newtheorem{lemma}[theorem]{Lemma} with \newtheorem{lemma}{Lemma}, the LaTeX code correctly compiles.

JesseStraat commented 1 day ago

Thanks for the bug report! Importing thmtools fixes the issue (it defines the lemma counter even if it shares a counter with theorem).

I will continue to look into whether there is a way of fixing the issue without thmtools.

JesseStraat commented 1 day ago

thmtools's \@counteralias macro (see here) is an essential tool when using shared counters. It is highly unlikely that I will be able to fix the issue without essentially copying over the macro's functionality. Instead, a future version of reptheorem will add the issue to the documentation and implement a custom warning for when the counter isn't recognised.