diff options
author | Karl Berry <karl@freefriends.org> | 2024-03-27 20:49:59 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2024-03-27 20:49:59 +0000 |
commit | e6b06cfc077ab36d07f53a3be0021c21c89fb71c (patch) | |
tree | 5d2a05e8315e2be304d72b3f3e6d6b5de0535dce /Master/texmf-dist/tex | |
parent | a3adb7360b7f7f061c26a157fc88ed04f81df4f1 (diff) |
reptheorem (27mar24)
git-svn-id: svn://tug.org/texlive/trunk@70789 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/reptheorem/reptheorem.sty | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/reptheorem/reptheorem.sty b/Master/texmf-dist/tex/latex/reptheorem/reptheorem.sty new file mode 100644 index 00000000000..2d12f462221 --- /dev/null +++ b/Master/texmf-dist/tex/latex/reptheorem/reptheorem.sty @@ -0,0 +1,108 @@ +%% +%% This is file `reptheorem.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% reptheorem.dtx (with options: `package') +%% +%% Copyright (c) 2024- Jesse Straat +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3 +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% https://www.latex-project.org/lppl.txt +%% and version 1.3c or later is part of all distributions of LaTeX +%% version 2008 or later. +%% +%% This work has the LPPL maintenance status `maintained'. +%% +%% The Current Maintainer of this work is Jesse Sraat. +%% +%% This work consists of the main file reptheorem.dtx +%% and the derived files +%% reptheorem.sty, reptheorem.pdf, reptheorem.ins +%% + +\ProvidesPackage{reptheorem}[2024-03-27 v1.0 Reptheorem package] +\def\reptheorem@theoremfile{\relax} +\NewDocumentCommand{\theoremfile}{ O{\jobname.thm} }{ + \def\reptheorem@theoremfile{#1} +\newwrite\@thmlist +\immediate\openout\@thmlist=#1 +} +\NewDocumentCommand{\loadtheorems}{ m }{ +\IfFileExists{#1}{ +\input{#1} +}{ +\PackageWarning{reptheorem}{% +File #1 not found. I will not import any theorems.% +} +} +} +\NewDocumentEnvironment{makethm}{ m m o +b } +{% +\IfValueTF{#3}{% Check if theorem has optional arguments +\begin{#1}[#3]\label{#2} +}{ +\begin{#1}\label{#2} +} +#4 +\end{#1} +\expandafter\long\expandafter\gdef\csname thm@#2\endcsname{#4}% +\expandafter\gdef\csname thmdesc@#2\endcsname{#3}% +\long\gdef\@thmoutput{% +\string\expandafter\string\long\string\expandafter% +\string\gdef\noexpand\csname thm@#2\string\endcsname{#4}% +^^J% +\string\expandafter\string\expandafter% +\string\gdef\noexpand\csname thmdesc@#2\string\endcsname{#3}% +} +\write\@auxout{\@thmoutput} +\if\reptheorem@theoremfile\relax +\else +\write\@thmlist{\@thmoutput} +\fi +}{} +\newcounter{old@counter} +\NewDocumentCommand{\repthm}{ m m +o }{ +\begingroup +\setcounter{old@counter}{\value{#1}} + \def\thetheorem{\ref{#2}} +\let\@@theoremnotdefined\relax +\ifcsname thm@#2\endcsname% Check if theorem is even defined +\expandafter\edef\expandafter\@@thmdesc{\csname thmdesc@#2\endcsname}% +\expandafter\let\expandafter\@@thm\csname thm@#2\endcsname +\IfValueTF{\@@thmdesc}{% Check if theorem has name +\begin{#1}[\@@thmdesc] +\@@thm +\end{#1} +}{% No optionals +\begin{#1} +\@@thm +\end{#1} +} +\else +\IfValueTF{#3}{ +\begin{#1} +#3 +\end{#1} +}{% No theorem or alt text provided: throw warning +\begin{#1} +\end{#1} +\PackageWarning{reptheorem}{% +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% +} +} +\fi +\setcounter{#1}{\value{old@counter}} + \endgroup +} + +\endinput +%% +%% End of file `reptheorem.sty'. |