texlive[76066] Master/texmf-dist: reptheorem (15aug25)
commits+karl at tug.org
commits+karl at tug.org
Fri Aug 15 23:25:27 CEST 2025
Revision: 76066
https://tug.org/svn/texlive?view=revision&revision=76066
Author: karl
Date: 2025-08-15 23:25:27 +0200 (Fri, 15 Aug 2025)
Log Message:
-----------
reptheorem (15aug25)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/latex/reptheorem/reptheorem-doc.pdf
trunk/Master/texmf-dist/source/latex/reptheorem/reptheorem.dtx
trunk/Master/texmf-dist/source/latex/reptheorem/reptheorem.ins
trunk/Master/texmf-dist/tex/latex/reptheorem/reptheorem.sty
Modified: trunk/Master/texmf-dist/doc/latex/reptheorem/reptheorem-doc.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/source/latex/reptheorem/reptheorem.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/reptheorem/reptheorem.dtx 2025-08-15 21:25:17 UTC (rev 76065)
+++ trunk/Master/texmf-dist/source/latex/reptheorem/reptheorem.dtx 2025-08-15 21:25:27 UTC (rev 76066)
@@ -89,7 +89,7 @@
\input docstrip.tex
\Msg{************************************************************************}
\Msg{* Installation}
-\Msg{* Package: reptheorem 2024-10-07 v1.3}
+\Msg{* Package: reptheorem 2025-08-15 v1.4}
\Msg{************************************************************************}
\keepsilent
@@ -128,7 +128,7 @@
\Msg{* To finish the installation you have to move the following}
\Msg{* file into a directory searched by TeX:}
\Msg{*}
-\Msg{* repthm.sty}
+\Msg{* reptheorem.sty}
\Msg{*}
\Msg{* To produce the documentation run the file `reptheorem.dtx'}
\Msg{* through LaTeX.}
@@ -305,6 +305,9 @@
% to replicate theorems ahead of time, similarly to
% how one has to run a file twice to make sure the
% references are correct.\par
+% It is also possible to use a starred version, \DescribeMacro{\repthm*} |\repthm*|.
+% It then automatically adds a star to the end of the theorem environment.
+% For example, |theorem| becomes |theorem*|.
%^^A
% \section{Replicating theorems between files}
% Let's say we have the following files for our project:
@@ -352,7 +355,7 @@
% \section{Source code}
% \begin{macrocode}
%<*package>
-\ProvidesPackage{reptheorem}[2024-10-07 v1.3 Reptheorem package]
+\ProvidesPackage{reptheorem}[2025-08-15 v1.4 Reptheorem package]
% \end{macrocode}
% \begin{macro}{\theoremfile}
% Using |\theoremfile| will output all saved theorems into an output file.
@@ -369,12 +372,15 @@
% \end{macrocode}
% \end{macro}
% \begin{macro}{\loadtheorems}
+% \changes{v1.4}{2025/04/15}{Now makes @ catcode 11 to fix incompatibility.}
% If you have exported saved theorems to a file, you can load them
% into another file using the macro |\loadtheorems|.
% \begin{macrocode}
\NewDocumentCommand{\loadtheorems}{ m }{
\IfFileExists{#1}{
+ \makeatletter
\input{#1}
+ \makeatother
}{
\PackageWarning{reptheorem}{%
File #1 not found. I will not import any theorems.%
@@ -382,6 +388,8 @@
}
}
% \end{macrocode}
+% The |\makeatletter| is included here to assure that any macros that are
+% expanded into macros that contain an |@| are interpreted correctly.
% \end{macro}
% \begin{environment}{makethm}
% \changes{v1.1}{2024/05/03}{Now saves theorem environment type, breaking backwards compatibility.}
@@ -388,6 +396,7 @@
% \changes{v1.2}{2024/09/21}{Environment end moved to fix vertical spacing.}
% \changes{v1.2}{2024/09/22}{Theorem name is only saved if it exists.}
% \changes{v1.2}{2024/09/22}{Renamed theorem output variable to be unique for each theorem.}
+% \changes{v1.4}{2025/08/15}{Added theorem label to aux file.}
% On to defining the actual theorems to be saved.
% \begin{macrocode}
\NewDocumentEnvironment{makethm}{ m m o +b }
@@ -404,6 +413,7 @@
}
% \begin{theorem}
#4
+ \providecommand{\label}[1]{}
\expandafter\gdef\csname thmtype@#2\endcsname{#1}%
\expandafter\long\expandafter\gdef\csname thm@#2\endcsname{#4}%
\IfValueT{#3}{% Only save theorem name if it exists
@@ -416,11 +426,14 @@
^^J%
\string\expandafter\string\long\string\expandafter%
\string\gdef\noexpand\csname thm@#2\string\endcsname{#4}%
- \IfValueT{#3}{
+ \IfValueT{#3}{%
^^J%
\string\expandafter\string\gdef\noexpand%
\csname thmdesc@#2\string\endcsname{#3}%
- }
+ }%
+ ^^J%
+ \string\expandafter\string\gdef\noexpand%
+ \csname thmlabel@#2\string\endcsname{\getrefnumber{#2}}%
}
\write\@auxout{\csname thmoutput@#2\endcsname}
\if\reptheorem at theoremfile\relax
@@ -437,34 +450,64 @@
% \begin{macro}{\repthm}
% \changes{v1.1}{2024/05/03}{Now saves theorem environment type, breaking backwards compatibility.}
% \changes{v1.2}{2024/09/22}{Fixed bug where theorems got a name even if undefined.}
-% \changes{v1.3}{2024/10/07}{Added hyperref named destination compatibility by setting counter to very low value}
+% \changes{v1.3}{2024/10/07}{Added hyperref named destination compatibility by setting counter to very low value.}
% \changes{v1.3}{2024/10/07}{Changed thetheorem to csname to fix compatibility with theorem types not called ``theorem''.}
-% To repeat a theorem, use the |\repthm| command.
+% \changes{v1.4}{2024/11/05}{Added warnings for unknown counter and unknown theorem type.}
+% \changes{v1.4}{2025/08/15}{If reference doesn't exist, saved label is now used instead of ??. Added star option.}
+% To repeat a theorem, use the |\repthm| command.\par
+% If the theorem type shares its counter with another theorem type,
+% e.g., |lemma| having the same counter as |thoerem|, make sure you
+% have |thmtools| imported. Its |\@counteralias| macro is essential
+% for the counters to work.
% \begin{macrocode}
\newcounter{old at counter}
-\NewDocumentCommand{\repthm}{ m +o }{
+\NewDocumentCommand{\repthm}{ s m +o }{
+ % s: optional star to add to theorem environment
% m: the name of the theorem
% o: alt text
\begingroup
% Check if thmtype is given
- \ifcsname thmtype@#1\endcsname%
- \expandafter\let\expandafter\@@thmtype\csname thmtype@#1\endcsname%
+ \ifcsname thmtype@#2\endcsname%
+ \expandafter\let\expandafter\@@thmtype\csname thmtype@#2\endcsname%
\else%
\def\@@thmtype{theorem}%
+ \PackageWarning{reptheorem}{%
+ Theorem '#2' has unknown theorem type. Assuming it is of
+ type 'theorem'.%
+ }
\fi%
+ \edef\@@thmcounter{\@@thmtype}
+ \IfBooleanT{#1}{\edef\@@thmtype{\@@thmtype*}}
%
% Save theorem counter so we don't increase it
- \setcounter{old at counter}{\value{\@@thmtype}}
- \setcounter{\@@thmtype}{-900}
- \expandafter\def\csname the\@@thmtype\endcsname{\ref{#1}}
+ \ifcsname c@\@@thmcounter\endcsname
+ \else
+ \PackageWarning{reptheorem}{%
+ Counter '\@@thmcounter' not defined; if theorem
+ '\@@thmcounter' shares its counter with another
+ theorem, make sure thmtools is imported.%
+ }
+ \fi
+ \setcounter{old at counter}{\value{\@@thmcounter}}
+ \setcounter{\@@thmcounter}{-900}
+ %
+ % Set label number
+ \ifcsname r@#2\endcsname
+ % Reference exists: set number as reference
+ \expandafter\def\csname the\@@thmtype\endcsname{\ref{#2}}
+ \else
+ % Force label number as saved
+ \expandafter\def\csname the\@@thmtype\endcsname{\csname thmlabel@#2\endcsname}
+ \fi
+ %
\let\@@theoremnotdefined\relax
%
- \ifcsname thm@#1\endcsname% Check if theorem is even defined
+ \ifcsname thm@#2\endcsname% Check if theorem is even defined
% Theorem is defined
- \expandafter\let\expandafter\@@thm\csname thm@#1\endcsname
+ \expandafter\let\expandafter\@@thm\csname thm@#2\endcsname
% Output theorem
- \ifcsname thmdesc@#1\endcsname % Check if theorem has name
- \begin{\@@thmtype}[\csname thmdesc@#1\endcsname]
+ \ifcsname thmdesc@#2\endcsname % Check if theorem has name
+ \begin{\@@thmtype}[\csname thmdesc@#2\endcsname]
\@@thm
\end{\@@thmtype}
\else % No optionals
@@ -474,22 +517,22 @@
\fi
\else
% Theorem undefined
- \IfValueTF{#2}{
+ \IfValueTF{#3}{
\begin{\@@thmtype}
- #2
+ #3
\end{\@@thmtype}
}{% No theorem or alt text provided: throw warning
\begin{\@@thmtype}
\end{\@@thmtype}
\PackageWarning{reptheorem}{%
- Theorem #1 not defined; rebuild your project.
+ Theorem '#2' not defined; rebuild your project.
If the issue persists, create the theorem using
\begin{makethm} or consider adding alt text to \repthm
- using the optional parameter%
+ using the optional parameter.%
}
}
\fi
- \setcounter{\@@thmtype}{\value{old at counter}}
+ \setcounter{\@@thmcounter}{\value{old at counter}}
% Reset theorem counter back to original
\endgroup
}
Modified: trunk/Master/texmf-dist/source/latex/reptheorem/reptheorem.ins
===================================================================
--- trunk/Master/texmf-dist/source/latex/reptheorem/reptheorem.ins 2025-08-15 21:25:17 UTC (rev 76065)
+++ trunk/Master/texmf-dist/source/latex/reptheorem/reptheorem.ins 2025-08-15 21:25:27 UTC (rev 76066)
@@ -27,7 +27,7 @@
\input docstrip.tex
\Msg{************************************************************************}
\Msg{* Installation}
-\Msg{* Package: reptheorem 2024-10-07 v1.3}
+\Msg{* Package: reptheorem 2025-08-15 v1.4}
\Msg{************************************************************************}
\keepsilent
@@ -66,7 +66,7 @@
\Msg{* To finish the installation you have to move the following}
\Msg{* file into a directory searched by TeX:}
\Msg{*}
-\Msg{* repthm.sty}
+\Msg{* reptheorem.sty}
\Msg{*}
\Msg{* To produce the documentation run the file `reptheorem.dtx'}
\Msg{* through LaTeX.}
Modified: trunk/Master/texmf-dist/tex/latex/reptheorem/reptheorem.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/reptheorem/reptheorem.sty 2025-08-15 21:25:17 UTC (rev 76065)
+++ trunk/Master/texmf-dist/tex/latex/reptheorem/reptheorem.sty 2025-08-15 21:25:27 UTC (rev 76066)
@@ -25,7 +25,7 @@
%% reptheorem.sty, reptheorem.pdf, reptheorem.ins
%%
-\ProvidesPackage{reptheorem}[2024-10-07 v1.3 Reptheorem package]
+\ProvidesPackage{reptheorem}[2025-08-15 v1.4 Reptheorem package]
\def\reptheorem at theoremfile{\relax}
\NewDocumentCommand{\theoremfile}{ O{\jobname.thm} }{
\def\reptheorem at theoremfile{#1}
@@ -34,7 +34,9 @@
}
\NewDocumentCommand{\loadtheorems}{ m }{
\IfFileExists{#1}{
+\makeatletter
\input{#1}
+\makeatother
}{
\PackageWarning{reptheorem}{%
File #1 not found. I will not import any theorems.%
@@ -49,6 +51,7 @@
\begin{#1}\label{#2}
}
#4
+\providecommand{\label}[1]{}
\expandafter\gdef\csname thmtype@#2\endcsname{#1}%
\expandafter\long\expandafter\gdef\csname thm@#2\endcsname{#4}%
\IfValueT{#3}{% Only save theorem name if it exists
@@ -60,12 +63,15 @@
^^J%
\string\expandafter\string\long\string\expandafter%
\string\gdef\noexpand\csname thm@#2\string\endcsname{#4}%
-\IfValueT{#3}{
+\IfValueT{#3}{%
^^J%
\string\expandafter\string\gdef\noexpand%
\csname thmdesc@#2\string\endcsname{#3}%
+}%
+^^J%
+\string\expandafter\string\gdef\noexpand%
+\csname thmlabel@#2\string\endcsname{\getrefnumber{#2}}%
}
-}
\write\@auxout{\csname thmoutput@#2\endcsname}
\if\reptheorem at theoremfile\relax
\else
@@ -74,21 +80,39 @@
\end{#1}
}{}
\newcounter{old at counter}
-\NewDocumentCommand{\repthm}{ m +o }{
+\NewDocumentCommand{\repthm}{ s m +o }{
\begingroup
-\ifcsname thmtype@#1\endcsname%
-\expandafter\let\expandafter\@@thmtype\csname thmtype@#1\endcsname%
+\ifcsname thmtype@#2\endcsname%
+\expandafter\let\expandafter\@@thmtype\csname thmtype@#2\endcsname%
\else%
\def\@@thmtype{theorem}%
+\PackageWarning{reptheorem}{%
+Theorem '#2' has unknown theorem type. Assuming it is of
+type 'theorem'.%
+}
\fi%
-\setcounter{old at counter}{\value{\@@thmtype}}
-\setcounter{\@@thmtype}{-900}
-\expandafter\def\csname the\@@thmtype\endcsname{\ref{#1}}
+\edef\@@thmcounter{\@@thmtype}
+\IfBooleanT{#1}{\edef\@@thmtype{\@@thmtype*}}
+\ifcsname c@\@@thmcounter\endcsname
+\else
+\PackageWarning{reptheorem}{%
+Counter '\@@thmcounter' not defined; if theorem
+'\@@thmcounter' shares its counter with another
+theorem, make sure thmtools is imported.%
+}
+\fi
+\setcounter{old at counter}{\value{\@@thmcounter}}
+\setcounter{\@@thmcounter}{-900}
+\ifcsname r@#2\endcsname
+\expandafter\def\csname the\@@thmtype\endcsname{\ref{#2}}
+\else
+\expandafter\def\csname the\@@thmtype\endcsname{\csname thmlabel@#2\endcsname}
+\fi
\let\@@theoremnotdefined\relax
-\ifcsname thm@#1\endcsname% Check if theorem is even defined
-\expandafter\let\expandafter\@@thm\csname thm@#1\endcsname
-\ifcsname thmdesc@#1\endcsname % Check if theorem has name
-\begin{\@@thmtype}[\csname thmdesc@#1\endcsname]
+\ifcsname thm@#2\endcsname% Check if theorem is even defined
+\expandafter\let\expandafter\@@thm\csname thm@#2\endcsname
+\ifcsname thmdesc@#2\endcsname % Check if theorem has name
+\begin{\@@thmtype}[\csname thmdesc@#2\endcsname]
\@@thm
\end{\@@thmtype}
\else % No optionals
@@ -97,22 +121,22 @@
\end{\@@thmtype}
\fi
\else
-\IfValueTF{#2}{
+\IfValueTF{#3}{
\begin{\@@thmtype}
-#2
+#3
\end{\@@thmtype}
}{% No theorem or alt text provided: throw warning
\begin{\@@thmtype}
\end{\@@thmtype}
\PackageWarning{reptheorem}{%
-Theorem #1 not defined; rebuild your project.
+Theorem '#2' not defined; rebuild your project.
If the issue persists, create the theorem using
\begin{makethm} or consider adding alt text to \repthm
-using the optional parameter%
+using the optional parameter.%
}
}
\fi
-\setcounter{\@@thmtype}{\value{old at counter}}
+\setcounter{\@@thmcounter}{\value{old at counter}}
\endgroup
}
\endinput
More information about the tex-live-commits
mailing list.