%% %% 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.3c %% 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 Straat. %% %% This work consists of the main file reptheorem.dtx %% and the derived files %% reptheorem.sty, reptheorem.pdf, reptheorem.ins %% \ProvidesPackage{reptheorem}[2024-10-07 v1.3 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 \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 \expandafter\gdef\csname thmdesc@#2\endcsname{#3}% } \expandafter\long\expandafter\gdef\csname thmoutput@#2\endcsname{% \string\expandafter\string\gdef\noexpand% \csname thmtype@#2\string\endcsname{#1}% ^^J% \string\expandafter\string\long\string\expandafter% \string\gdef\noexpand\csname thm@#2\string\endcsname{#4}% \IfValueT{#3}{ ^^J% \string\expandafter\string\gdef\noexpand% \csname thmdesc@#2\string\endcsname{#3}% } } \write\@auxout{\csname thmoutput@#2\endcsname} \if\reptheorem@theoremfile\relax \else \write\@thmlist{\csname thmoutput@#2\endcsname} \fi \end{#1} }{} \newcounter{old@counter} \NewDocumentCommand{\repthm}{ m +o }{ \begingroup \ifcsname thmtype@#1\endcsname% \expandafter\let\expandafter\@@thmtype\csname thmtype@#1\endcsname% \else% \def\@@thmtype{theorem}% \fi% \setcounter{old@counter}{\value{\@@thmtype}} \setcounter{\@@thmtype}{-900} \expandafter\def\csname the\@@thmtype\endcsname{\ref{#1}} \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] \@@thm \end{\@@thmtype} \else % No optionals \begin{\@@thmtype} \@@thm \end{\@@thmtype} \fi \else \IfValueTF{#2}{ \begin{\@@thmtype} #2 \end{\@@thmtype} }{% No theorem or alt text provided: throw warning \begin{\@@thmtype} \end{\@@thmtype} \PackageWarning{reptheorem}{% Theorem #1 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{\@@thmtype}{\value{old@counter}} \endgroup } \endinput %% %% End of file `reptheorem.sty'.