integrate pytex for docstrip

This commit is contained in:
Maximilian Keßler 2022-01-24 01:05:29 +01:00
parent cbcebe18bd
commit 6849b1e36c
4 changed files with 97 additions and 192 deletions

2
PyTeX

@ -1 +1 @@
Subproject commit 6277050e22b395eef5f554f3106aacd76562b3d2 Subproject commit c1e206e0d46ff2096ad34e6098f18f4c5739808d

View file

@ -375,8 +375,6 @@
% %
% %
% %
%
%
% \begin{macrocode} % \begin{macrocode}
\keys_define:nn { fancythm / fancytheorem } \keys_define:nn { fancythm / fancytheorem }
{ {

View file

@ -1,7 +1,4 @@
sty: clean-sty all: clean pdf
pdflatex groupthm.ins
all: clean pdf sty
pdf: pdf:
pdflatex groupthm.dtx pdflatex groupthm.dtx

View file

@ -1,100 +1,6 @@
__HEADER__(Theorem-Environment Package) __HEADER__(Theorem-Environment Package)
%Provides fancy theorem-like-environments used in the write-ups of my lecture notes %Provides fancy theorem-like-environments used in the write-ups of my lecture notes
\ExplSyntaxOn
\RequirePackage{xkeyval}
__NEW_IF__(showstars,true)
__NEW_IF__(showdaggers,true)
__NEW_IF__(includestars,true)
__NEW_IF__(includeoral,true)
__NEW_IF__(markoral,true)
__NEW_IF__(lecturenumbers,true)
__NEW_IF__(numbersmallenvironmentswiththeorem,false)
__NEW_IF__(numbersmallenvironments,false)
__NEW_IF__(defaulttheorems,true)
\define@choicekey*{__PACKAGE_NAME__}{__PACKAGE_PREFIX__numbersmallenvironments}[\val\nr]{no,section,theorem}{%
\ifcase\nr\relax
__SET_IF__(numbersmallenvironments,false)
\or
__SET_IF__(numbersmallenvironments,true)
%numbering small environments within sections is forbidden whilst using lecturenumbes
__IF__(lecturenumbers)
__SET_IF__(numbersmallenvironmentswiththeorem,true)
\else
__SET_IF__(numbersmallenvironmentswiththeorem,false)
\fi
\or
__SET_IF__(numbersmallenvironments,true)
__SET_IF__(numbersmallenvironmentswiththeorem,true)
\fi
}
\define@choicekey*{__PACKAGE_NAME__}{__PACKAGE_PREFIX__lecturenumbers}[\val\nr]{true,false}{%
\ifcase\nr\relax
__SET_IF__(lecturenumbers,true)
\else
__SET_IF__(lecturenumbers,false)
\fi
}
\define@choicekey*{__PACKAGE_NAME__}{__PACKAGE_PREFIX__defaulttheorems}[\val\nr]{true,false}{%
\ifcase\nr\relax
__SET_IF__(defaulttheorems,true)
\else
__SET_IF__(defaulttheorems,false)
\fi
}
\define@choicekey*{__PACKAGE_NAME__}{__PACKAGE_PREFIX__showdaggers}[\val\nr]{true,false}{%
\ifcase\nr\relax
__SET_IF__(showdaggers,true)
\else
__SET_IF__(showdaggers,false)
\fi
}
\define@choicekey*{__PACKAGE_NAME__}{ownenvironments}[\val\nr]{on, natural, off}{%
\ifcase\nr\relax
__SET_IF__(includestars,true)
__SET_IF__(showstars,true)
\or
__SET_IF__(includestars,true)
__SET_IF__(showstars,false)
\or
__SET_IF__(includestars,false)
__SET_IF__(showstars,false)
\fi
}
\define@choicekey*{__PACKAGE_NAME__}{oralremarks}[\val\nr]{on,natural,off}{%
\ifcase\nr\relax
__SET_IF__(includeoral,true)
__SET_IF__(markoral,true)
\or
__SET_IF__(includeoral,true)
__SET_IF__(markoral,true)
\or
__SET_IF__(includeoral,false)
\fi
}
%%%%% Option section
__LANGUAGE_OPTIONS_X__
\DeclareOptionX{showdaggers}{\setkeys{__PACKAGE_NAME__}{__PACKAGE_PREFIX__showdaggers=#1}}
\DeclareOptionX{ownenvironments}{\setkeys{__PACKAGE_NAME__}{ownenvironments=#1}}
\DeclareOptionX{oralremarks}{\setkeys{__PACKAGE_NAME__}{oralremarks=#1}}
\DeclareOptionX{lecturenumbers}{\setkeys{__PACKAGE_NAME__}{__PACKAGE_PREFIX__lecturenumbers=#1}}
\DeclareOptionX{numbersmallenvironments}{\setkeys{__PACKAGE_NAME__}{__PACKAGE_PREFIX__numbersmallenvironments=#1}}
\DeclareOptionX{defaulttheorems}{\setkeys{__PACKAGE_NAME__}{__PACKAGE_PREFIX__defaulttheorems=#1}}
__END_OPTIONS_X__
%%%%%%%% Implementation section
%Required Packages and setup %Required Packages and setup
\RequirePackage{amsmath} \RequirePackage{amsmath}
@ -102,121 +8,125 @@ __END_OPTIONS_X__
\RequirePackage{mdframed} \RequirePackage{mdframed}
\RequirePackage{thmtools} \RequirePackage{thmtools}
\RequirePackage[skins]{tcolorbox} \RequirePackage[skins]{tcolorbox}
\RequirePackage{mfirstuc}
\RequirePackage{xifthen} \RequirePackage{xifthen}
\RequirePackage{xparse} \RequirePackage{xparse}
\RequirePackage{groupthm}
\tcbuselibrary{breakable} \tcbuselibrary{breakable}
% Dummy counters
\declaretheorem[numberwithin=section]{__PACKAGE_PREFIX__dummy}
\declaretheorem[numberwithin=__PACKAGE_PREFIX__dummy]{__PACKAGE_PREFIX__smalldummy}
%%%%% Main part, i.e. providing macros for defining new theorems % Counter management
\cs_set_eq:NN \arabic:n \arabic
\cs_set_eq:NN \counter_new:n \newcounter
\cs_set_eq:NN \counter_within:nn \counterwithin
\cs_new:Npn \counter_new:nn #1 #2
{
\counter_new:n { #1 }
\counter_within:nn { #1 } { #2 }
}
\cs_set_eq:Nc \counter_alias:nn { @counteralias } % this is from thmtools
\cs_set_eq:Nc \counter_undefined_error:n { @nocounterr }
%%Environments that are numbered by default have 3 versions: \cs_new:Npn \counter_if_exist_p:n #1
% - the standard one, for numbering {
% - one asterisk, to exclude them from numbering (because they were not numbered in the lecture) -> they will be numbered if 'truenmubers' option is set \cs_if_exist_p:c { c@ #1 }
% - two asterisks, for marking them as self-added, so they will not be numbered, but will receive a visual asterisk. -> They will be numbered if 'truenumbers' option is set }
\cs_new:Npn \counter_if_exist:nT #1
{
\cs_if_exist:cT { c@ #1 }
\NewDocumentCommand{\declarebigtheorem}{O{} O{} m m O{}}{ }
%First, store the name of the theorem in \theoremname \cs_new:Npn \counter_if_exist:nF #1
__IF__(english) {
\ifthenelse{\isempty{#2}}{\def\theoremname{#4}}{\def\theoremname{#2}} \cs_if_exist:cF { c@ #1 }
\else }
\ifthenelse{\isempty{#1}}{\def\theoremname{#4}}{\def\theoremname{#1}} \cs_new:Npn \counter_if_exist:nTF #1
\fi {
\cs_if_exist:cTF { c@ #1 }
%Define the mane version of the theorem
\ifthenelse{\isempty{#5}}{\declaretheorem[style = #3, name = \makefirstuc{\expandafter\theoremname}, sibling = __PACKAGE_PREFIX__dummy]{#4}}{}
%Define the versions theorem*, theorem**, dtheorem
__IF__(lecturenumbers)
__IF__(numbersmallenvironments)
\declaretheorem[style = #3, name = \makefirstuc{\expandafter\theoremname}, sibling=__PACKAGE_PREFIX__smalldummy]{#4*}
\declaretheorem[style = #3, name = \makefirstuc{\expandafter\theoremname}__IF__(showstars) *\else\fi, sibling=__PACKAGE_PREFIX__smalldummy]{#4**}
\declaretheorem[style = #3, name = \makefirstuc{\expandafter\theoremname}__IF__(showdaggers) $^{\dagger}$\else\fi, sibling=__PACKAGE_PREFIX__smalldummy]{d#4}
\else
\declaretheorem[style = #3, name = \makefirstuc{\expandafter\theoremname}, numbered=no]{#4*}
\declaretheorem[style = #3, name = \makefirstuc{\expandafter\theoremname}__IF__(showstars) *\else\fi, numbered = no]{#4**}
\declaretheorem[style = #3, name = \makefirstuc{\expandafter\theoremname}__IF__(showdaggers) $^{\dagger}$\else\fi, numbered = no]{d#4}
\fi
\else
\declaretheorem[style = #3, name = \makefirstuc{\expandafter\theoremname}, sibling=__PACKAGE_PREFIX__dummy]{#4*}
\declaretheorem[style = #3, name = \makefirstuc{\expandafter\theoremname}__IF__(showstars) *\else\fi, sibling=__PACKAGE_PREFIX__dummy]{#4**}
\declaretheorem[style = #3, name = \makefirstuc{\expandafter\theoremname}__IF__(showdaggers) $^{\dagger}$\else\fi, sibling=__PACKAGE_PREFIX__dummy]{d#4}
\fi
__IF__(includestars)\else\renewenvironment{#4**}{\comment}{\endcomment}\fi
} }
\NewDocumentCommand{\declaresmalltheorem}{O{} O{} m m}{ \cs_new:Npn \counter_ensure_exist:n #1
%Get the name of the theorem and store it in \theoremname {
__IF__(english) \counter_if_exist:nF { #1 }
\ifthenelse{\isempty{#2}}{\def\theoremname{#4}}{\def\theoremname{#2}} {
\else \counter_undefined_error:n { #1 }
\ifthenelse{\isempty{#1}}{\def\theoremname{#4}}{\def\theoremname{#1}}
\fi
__IF__(numbersmallenvironments)
__IF__(numbersmallenvironmentswiththeorem)
\declaretheorem[style=#3,name=\makefirstuc{\expandafter\theoremname}, sibling = __PACKAGE_PREFIX__smalldummy]{#4}
\declaretheorem[style=#3,name=\makefirstuc{\expandafter\theoremname}__IF__(showstars) *\else\fi, sibling=__PACKAGE_PREFIX__smalldummy]{#4*}
\declaretheorem[style=#3,name=\makefirstuc{\expandafter\theoremname}__IF__(showdaggers) $^{\dagger}$\else\fi, sibling=__PACKAGE_PREFIX__smalldummy]{d#4}
\else
\declaretheorem[style=#3,name=\makefirstuc{\expandafter\theoremname}, sibling=__PACKAGE_PREFIX__dummy]{#4}
\declaretheorem[style=#3,name=\makefirstuc{\expandafter\theoremname}__IF__(showstars) *\else\fi, sibling=__PACKAGE_PREFIX__dummy]{#4*}
\declaretheorem[style=#3,name=\makefirstuc{\expandafter\theoremname}__IF__(showdaggers) $^{\dagger}$\else\fi, sibling=__PACKAGE_PREFIX__dummy]{d#4}
\fi
\else
\declaretheorem[style=#3,name=\makefirstuc{\expandafter\theoremname}, numbered = no]{#4}
\declaretheorem[style=#3,name=\makefirstuc{\expandafter\theoremname}__IF__(showstars) *\else\fi, numbered = no]{#4*}
\declaretheorem[style=#3,name=\makefirstuc{\expandafter\theoremname}__IF__(showdaggers) $^{\dagger}$\else\fi, numbered = no]{d#4}
\fi
\declaretheorem[style=#3,name=\makefirstuc{\expandafter\theoremname}, sibling=__PACKAGE_PREFIX__dummy]{n#4}
__IF__(includestars)\else\renewenvironment{#4*}{\comment}{\endcomment}\fi
} }
}
\cs_new:Npn \counter_the:n #1
{
\use:c { the #1 }
}
\cs_new:Npn \counter_set_the:nn #1 #2
{
\counter_ensure_exist:n { #1 }
\exp_args:Nc \renewcommand { the #1 } { #2 }
}
\cs_new:Npn \counter_sub:nn #1 #2
{
\counter_within:nn { #1 } { #2 }
\counter_set_the:nn { #1 }
{
\counter_the:n { #2 } . \arabic:n { #1 }
}
}
\cs_new:Npn \@@_counter_sub_if_exist:n #1
{
\counter_if_exist:nT { #1 }
{
\counter_sub:nn { in #1 } { #1 }
}
}
\counter_new:n { indocument }
\counter_new_sub:nn { insection } { section }
\counter_new_sub:nn { insubsection } { subsection }
\keys_define:nn { fancythm }
{
fancy .bool_set : \l_@@_key_fancy_bool,
fancy .default : { true },
number ~ in .choices:nn = { document, part, chapter, section, subsection }
}
\NewTheoremGroup
[
suffix = { * }
] { star }
\NewTheoremGroup
[
suffix = { $^{\dagger}$ }
] { dagger }
\NewTheoremGroup
[
] { big }
\NewTheoremGroup
{ small }
\NewTheoremGroup
{ tiny }
%%%% If requested, now define some default theoremstyles %%%% If requested, now define some default theoremstyles
__IF__(defaulttheorems) __IF__(defaulttheorems)
\RequirePackage[default styles]{mkessler-thmstyle} % Easy setup of mdframed styles \RequirePackage[default styles]{mkessler-thmstyle} % Easy setup of mdframed styles
\declarebigtheorem[Satz][Theorem]{thmredmarginandfill}{theorem} __IF__(english)\else\AtBeginDocument{\def\theoremautorefname{Satz}}\fi
\declarebigtheorem{thmredmarginandfill}{proposition}
\declarebigtheorem[Korollar]{thmredmarginandfill}{corollary}
\declarebigtheorem{thmorangemarginandfill}{lemma}
\declarebigtheorem[Lemma und Definition][Lemma and Definition]{thmorangemarginbluefill}{lemmadef}
\declarebigtheorem{thmbluemarginandfill}{definition}
\declarebigtheorem[Satz und Definition][Theorem and Definition]{thmredmarginbluefill}{theoremdef}
\declarebigtheorem[Proposition und Definition][Proposition and Definition]{thmredmarginbluefill}{propositiondef}
\declarebigtheorem{thmvioletmarginandfill}{notation} \declarebigtheorem{thmvioletmarginandfill}{notation}
\declarebigtheorem[zuSatz][Addition to Theorem]{thmredmarginandfill}{additiontheorem}
%%%Environments that are not numbered by default (notation, question, example, remark etc) have two forms: %%%Environments that are not numbered by default (notation, question, example, remark etc) have two forms:
% - normal form: won't be numbered unless '__PACKAGE_PREFIX__numbersmallenvironments' is set % - normal form: won't be numbered unless '__PACKAGE_PREFIX__numbersmallenvironments' is set
% - having an asterisk: will be displayed with an asterisk, will be numbered if 'numbersmallenvironments' is set % - having an asterisk: will be displayed with an asterisk, will be numbered if 'numbersmallenvironments' is set
%Notation %Notation
\declaresmalltheorem[Notationsmissbrauch][Abuse of Notation]{thmvioletmargin}{abuse}
\declaresmalltheorem[Beispiel]{thmgreenmargin}{example}
\declaresmalltheorem[Bemerkung]{thmyellowmargin}{remark}
\declaresmalltheorem[Lob]{thmgoldmargin}{praise}
\declaresmalltheorem[Trivial Nonsense][Trivial Nonsense]{thmyellowmargin}{trivial}
\declaresmalltheorem[Frage]{thmblackmarginandfill}{question}
\declaresmalltheorem[Organisatorisches][Organisational stuff]{thmblackmargin}{orga}
\declaresmalltheorem[Fakt]{thmredmargin}{fact}
%%%% Specially treated stuff %%%% Specially treated stuff
\declaresmalltheorem[__IF__(markoral) Mündliche Anmerkung\else Bemerkung\fi][__IF__(markoral) Oral remark\else remark\fi]{thmyellowmargin}{oral}
% Option to remove oral remarks when needed
__IF__(includeoral)\else
\renewenvironment{oral}{\comment}{\endcomment}
\renewenvironment{oral*}{\comment}{\endcomment}
\renewenvironment{doral}{\comment}{\endcomment}
\fi
%%%%%%%% Other mdframed style boxes %%%%%%%% Other mdframed style boxes
\newtcolorbox{recap}{before skip = 0.5cm, after skip = 0.5cm, enhanced, sharp corners = all, colback = white, colframe = gray, toprule=0pt, bottomrule=0pt, leftrule=0pt,rightrule=0pt, overlay = { \newtcolorbox{recap}{before skip = 0.5cm, after skip = 0.5cm, enhanced, sharp corners = all, colback = white, colframe = gray, toprule=0pt, bottomrule=0pt, leftrule=0pt,rightrule=0pt, overlay = {