2021-08-26 13:41:40 +02:00
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mkessler-fancythm}[2021/04/27 - Theorem-Environment Package]
%%%%%%%%m
%Provides fancy theorem-like-environments usedd in the write-ups of my lecture nots
2021-09-12 12:36:36 +02:00
\RequirePackage{xkeyval}
2021-08-26 13:41:40 +02:00
\newif\ifenglish\englishtrue
\newif\ifshowstars\showstarstrue
\newif\ifshowdaggers\showdaggerstrue
\newif\ifincludestars\includestarstrue
\newif\ifincludeoral\includeoraltrue
\newif\ifmarkoral\markoraltrue
\newif\iflecturenumbers\lecturenumberstrue
\newif\ifnumbersmallenvironmentswiththeorem\numbersmallenvironmentswiththeoremfalse
\newif\ifnumbersmallenvironments\numbersmallenvironmentsfalse
\newcommand{\fancythmlinewidth}{2pt}
2021-09-12 12:36:36 +02:00
\newcommand{\fancythm}{8pt}
2021-08-26 13:41:40 +02:00
\define@choicekey*{mkesslerfancythm}{numbersmallenvironments}[\val\nr]{no,section,theorem}{%
\ifcase\nr\relax
\numbersmallenvironmentsfalse
\or
\numbersmallenvironmentstrue
%numbering small environments within sections is forbidden whilst using lecturenumbes
\iflecturenumbers
\numbersmallenvironmentswiththeoremtrue
\else
\numbersmallenvironmentswiththeoremfalse
\fi
\or
\numbersmallenvironmentstrue
\numbersmallenvironmentswiththeoremtrue
\fi
}
\define@choicekey*{mkesslerfancythm}{lecturenumbers}[\val\nr]{true,false}{%
\ifcase\nr\relax
\lecturenumberstrue
\else
\lecturenumbersfalse
\fi
}
\define@choicekey*{mkesslerfancythm}{showdaggers}[\val\nr]{true,false}{%
\ifcase\nr\relax
\showdaggerstrue
\else
\showdaggersfalse
\fi
}
\define@choicekey*{mkesslerfancythm}{ownenvironments}[\val\nr]{on, natural, off}{%
\ifcase\nr\relax
\includestarstrue
\showstarstrue
\or
\includestarstrue
\showstarsfalse
\or
\includestarsfalse
\showstarsfalse
\fi
}
\define@choicekey*{mkesslerfancythm}{oralremarks}[\val\nr]{on,natural,off}{%
\ifcase\nr\relax
\includeoraltrue
\markoraltrue
\or
\includeoraltrue
\markoralfalse
\or
\includeoralfalse
\fi
}
2021-09-12 12:36:36 +02:00
%%%%% Option section
2021-08-26 13:41:40 +02:00
\DeclareOptionX{english}{\englishtrue}
\DeclareOptionX{german}{\englishfalse}
\DeclareOptionX{showdaggers}{\setkeys{mkesslerfancythm}{showdaggers=#1}}
\DeclareOptionX{ownenvironments}{\setkeys{mkesslerfancythm}{ownenvironments=#1}}
\DeclareOptionX{oralremarks}{\setkeys{mkesslerfancythm}{oralremarks=#1}}
\DeclareOptionX{lecturenumbers}{\setkeys{mkesslerfancythm}{lecturenumbers=#1}}
\DeclareOptionX{numbersmallenvironments}{\setkeys{mkesslerfancythm}{numbersmallenvironments=#1}}
\DeclareOptionX*{\PackageWarning{mkesslerfancythm}{Unknown X \CurrentOption}}% For unknown options
\ProcessOptionsX*\relax
2021-09-12 12:36:36 +02:00
%%%% Implementation section
2021-08-26 13:41:40 +02:00
%Required Packages
\RequirePackage{amsmath}
\RequirePackage{amsthm}
\RequirePackage{mdframed}
\RequirePackage{thmtools}
\RequirePackage[skins]{tcolorbox}
2021-09-12 12:36:36 +02:00
\RequirePackage{mkessler-thmstyle}
2021-08-26 13:41:40 +02:00
%%Environments that are numbered by default have 3 versions:
% - 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
% - 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
%Theorem
\RequirePackage{mfirstuc}
\RequirePackage{xifthen}
\RequirePackage{xparse}
2021-09-12 12:36:36 +02:00
%Taken from
% https://github.com/gillescastel/university-setup/blob/master/preamble.tex
% Make boxes breakable
\tcbuselibrary{breakable}
2021-08-26 13:41:40 +02:00
\declaretheorem[numberwithin=section]{dummy}
\declaretheorem[numberwithin=dummy]{smalldummy}
\NewDocumentCommand{\declarebigtheorem}{O{} O{} m m O{}}{
%First, store the name of the theorem in \theoremname
\ifenglish
\ifthenelse{\isempty{#2}}{\def\theoremname{#4}}{\def\theoremname{#2}}
\else
\ifthenelse{\isempty{#1}}{\def\theoremname{#4}}{\def\theoremname{#1}}
\fi
%Define the mane version of the theorem
\ifthenelse{\isempty{#5}}{\declaretheorem[style = #3, name = \makefirstuc{\expandafter\theoremname}, sibling = dummy]{#4}}{}
%Define the versions theorem*, theorem**, dtheorem
\iflecturenumbers
\ifnumbersmallenvironments
\declaretheorem[style = #3, name = \makefirstuc{\expandafter\theoremname}, sibling=smalldummy]{#4*}
\declaretheorem[style = #3, name = \makefirstuc{\expandafter\theoremname}\ifshowstars *\else\fi, sibling=smalldummy]{#4**}
\declaretheorem[style = #3, name = \makefirstuc{\expandafter\theoremname}\ifshowdaggers $^{\dagger}$\else\fi, sibling=smalldummy]{d#4}
\else
\declaretheorem[style = #3, name = \makefirstuc{\expandafter\theoremname}, numbered=no]{#4*}
\declaretheorem[style = #3, name = \makefirstuc{\expandafter\theoremname}\ifshowstars *\else\fi, numbered = no]{#4**}
\declaretheorem[style = #3, name = \makefirstuc{\expandafter\theoremname}\ifshowdaggers $^{\dagger}$\else\fi, numbered = no]{d#4}
\fi
\else
\declaretheorem[style = #3, name = \makefirstuc{\expandafter\theoremname}, sibling=dummy]{#4*}
\declaretheorem[style = #3, name = \makefirstuc{\expandafter\theoremname}\ifshowstars *\else\fi, sibling=dummy]{#4**}
\declaretheorem[style = #3, name = \makefirstuc{\expandafter\theoremname}\ifshowdaggers $^{\dagger}$\else\fi, sibling=dummy]{d#4}
\fi
\ifincludestars\else\renewenvironment{#4**}{\comment}{\endcomment}\fi
}
\NewDocumentCommand{\declaresmalltheorem}{O{} O{} m m}{
%Get the name of the theorem and store it in \theoremname
\ifenglish
\ifthenelse{\isempty{#2}}{\def\theoremname{#4}}{\def\theoremname{#2}}
\else
\ifthenelse{\isempty{#1}}{\def\theoremname{#4}}{\def\theoremname{#1}}
\fi
\ifnumbersmallenvironments
\ifnumbersmallenvironmentswiththeorem
\declaretheorem[style=#3,name=\makefirstuc{\expandafter\theoremname}, sibling = smalldummy]{#4}
\declaretheorem[style=#3,name=\makefirstuc{\expandafter\theoremname}\ifshowstars *\else\fi, sibling=smalldummy]{#4*}
\declaretheorem[style=#3,name=\makefirstuc{\expandafter\theoremname}\ifshowdaggers $^{\dagger}$\else\fi, sibling=smalldummy]{d#4}
\else
\declaretheorem[style=#3,name=\makefirstuc{\expandafter\theoremname}, sibling=dummy]{#4}
\declaretheorem[style=#3,name=\makefirstuc{\expandafter\theoremname}\ifshowstars *\else\fi, sibling=dummy]{#4*}
\declaretheorem[style=#3,name=\makefirstuc{\expandafter\theoremname}\ifshowdaggers $^{\dagger}$\else\fi, sibling=dummy]{d#4}
\fi
\else
\declaretheorem[style=#3,name=\makefirstuc{\expandafter\theoremname}, numbered = no]{#4}
\declaretheorem[style=#3,name=\makefirstuc{\expandafter\theoremname}\ifshowstars *\else\fi, numbered = no]{#4*}
\declaretheorem[style=#3,name=\makefirstuc{\expandafter\theoremname}\ifshowdaggers $^{\dagger}$\else\fi, numbered = no]{d#4}
\fi
\declaretheorem[style=#3,name=\makefirstuc{\expandafter\theoremname}, sibling=dummy]{n#4}
\ifincludestars\else\renewenvironment{#4*}{\comment}{\endcomment}\fi
}
2021-09-12 12:36:36 +02:00
\declarebigtheorem[Satz][Theorem]{thmredmarginandfill}{theorem}
2021-08-26 13:41:40 +02:00
\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}
2021-08-26 17:43:37 +02:00
\declarebigtheorem[zuSatz][Addition to Theorem]{thmredmarginandfill}{additiontheorem}
2021-08-26 13:41:40 +02:00
%%%Environments that are not numbered by default (notation, question, example, remark etc) have two forms:
% - normal form: won't be numbered unless 'numbersmallenvironments' is set
% - having an asterisk: will be displayed with an asterisk, will be numbered if 'numbersmallenvironments' is set
%Notation
\declaresmalltheorem[Notationsmissbrauch][Abuse of Notation]{thmvioletmargin}{abuse}
\declaresmalltheorem[Beispiel]{thmgreenmargin}{example}
\declaresmalltheorem[Bemerkung]{thmyellowmargin}{remark}
2021-08-27 10:48:22 +02:00
\declaresmalltheorem[Lob]{thmgoldmargin}{praise}
2021-08-26 13:41:40 +02:00
\declaresmalltheorem[Trivial Nonsense][Trivial Nonsense]{thmyellowmargin}{trivial}
\declaresmalltheorem[Frage]{thmblackmarginandfill}{question}
\declaresmalltheorem[Organisatorisches][Organisational stuff]{thmblackmargin}{orga}
\declaresmalltheorem[Fakt]{thmredmargin}{fact}
2021-09-12 12:36:36 +02:00
%%%% Specially treated stuff
2021-08-26 13:41:40 +02:00
\declaresmalltheorem[\ifmarkoral Mündliche Anmerkung\else Bemerkung\fi][\ifmarkoral Oral remark\else remark\fi]{thmyellowmargin}{oral}
2021-09-12 12:36:36 +02:00
% Option to remove oral remarks when needed
2021-08-26 13:41:40 +02:00
\ifincludeoral\else
\renewenvironment{oral}{\comment}{\endcomment}
\renewenvironment{oral*}{\comment}{\endcomment}
\renewenvironment{doral}{\comment}{\endcomment}
\fi
2021-09-12 12:36:36 +02:00
%%%%%%%% Other mdframed style boxes
2021-08-26 13:41:40 +02:00
\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 = {
\draw[gray, line width = 2pt] (frame.north west) -- ++(0.5cm, 0pt);
\draw[gray, line width=2pt] (frame.south east) -- ++(-0.5cm, 0pt);
\draw[gray, line width=2pt] (frame.north west) -- ++ (0pt, -0.5cm);
\draw[gray, line width=2pt] (frame.south east) -- ++(0pt, 0.5cm);
}}
2021-09-12 12:36:36 +02:00
\newenvironment{moral}{%
\begin{mdframed}[linecolor=green!70!black]%
\bfseries\color{green!50!black}}%
{\end{mdframed}}
\newenvironment{antimoral}{%
\begin{mdframed}[linecolor=red!70!black]%
\bfseries\color{red!50!black}}%
{\end{mdframed}}
%%%%%%%%%%%% Non-mdframed theorems
2021-08-26 13:41:40 +02:00
\theoremstyle{plain}
2021-09-12 10:50:59 +02:00
\newtheorem{variant}{\ifenglish Variant\else Variante\fi}
2021-08-26 13:41:40 +02:00
\newtheorem{assumption}{\ifenglish Assumption\else Annahme\fi}
2021-09-12 10:50:59 +02:00
2021-08-26 13:41:40 +02:00
\theoremstyle{definition}
2021-09-12 10:50:59 +02:00
\newtheorem*{note}{\ifenglish Note\else Anmerkung\fi}
2021-08-26 13:41:40 +02:00
\newtheorem*{warning}{\color{red}\ifenglish Warning \else Warnung\fi}
2021-09-12 10:50:59 +02:00
\newtheorem*{goal}{\ifenglish Goal \else Ziel\fi}
2021-08-26 13:41:40 +02:00
\newtheorem*{strategy}{\ifenglish Proof Strategy \else Beweisstrategie\fi}
\newtheorem*{goal*}{\ifenglish Goal* \else Ziel*\fi}
\newtheorem*{problem}{Problem}
2021-09-12 10:50:59 +02:00
\newtheorem*{info}{Information}
2021-09-12 12:36:36 +02:00
2021-08-26 13:41:40 +02:00
2021-09-12 10:50:59 +02:00
\newtheorem*{answer}{\ifenglish Answer\else Antwort\fi}
2021-08-26 13:41:40 +02:00
\newtheorem{observe}[theorem]{\ifenglish Observe\else Beobachte\fi}
2021-09-12 10:50:59 +02:00
\newtheorem*{property}{\ifenglish Property\else Eigenschaft\fi}
\newtheorem*{intuition}{Intuition}
\newtheorem*{recall}{\ifenglish Recall\else Erinnerung\fi}
2021-08-26 13:41:40 +02:00
\newtheorem*{idea}{\ifenglish Idea\else Idee\fi}
2021-09-12 10:50:59 +02:00
\newtheorem{exercise}{\ifenglish Exercise\else Aufgabe\fi}[section]
2021-08-26 13:41:40 +02:00
\newtheorem{reminder}{\ifenglish Reminder\else Erinnerung\fi}