% ▄▄· ▄• ▄▌ ▐ ▄ ▄▄▄▄▄▄▄▄ .▄▄▄ % ▐█ ▌▪ ▄█▀▄ █▪██▌•█▌▐█•██ ▀▄.▀·▀▄ █· % ██ ▄▄▐█▌.▐▌█▌▐█▌▐█▐▐▌ ▐█.▪▐▀▀▪▄▐▀▀▄ % ▐███▌▐█▌.▐▌▐█▄█▌██▐█▌ ▐█▌·▐█▄▄▌▐█•█▌ % ·▀▀▀ ▀█▄▀▪ ▀▀▀ ▀▀ █▪ ▀▀▀ ▀▀▀ .▀ ▀ \usepackage{xstring} \usepackage{etoolbox} % tcolorbox and other stylistic elements (i.e. inline versions of them) that have counters \newcounter{lemma}[section] \newcounter{definition}[section] \newcounter{corollary}[section] \newcounter{theorem}[section] \newcounter{axiom}[section] \newcounter{example}[section] \newcounter{fact}[section] \newcounter{proposition}[section] \newcounter{formula}[section] \newcounter{remark}[section] \newcounter{all}[section] \newcounter{lemmass}[subsection] \newcounter{definitionss}[subsection] \newcounter{corollaryss}[subsection] \newcounter{theoremss}[subsection] \newcounter{axiomss}[subsection] \newcounter{exampless}[subsection] \newcounter{factss}[subsection] \newcounter{propositionss}[subsection] \newcounter{formulass}[subsection] \newcounter{remarkss}[subsection] \newcounter{allss}[subsection] \newcounter{lemmasss}[subsubsection] \newcounter{definitionsss}[subsubsection] \newcounter{corollarysss}[subsubsection] \newcounter{theoremsss}[subsubsection] \newcounter{axiomsss}[subsubsection] \newcounter{examplesss}[subsubsection] \newcounter{factsss}[subsubsection] \newcounter{propositionsss}[subsubsection] \newcounter{formulasss}[subsubsection] \newcounter{remarksss}[subsubsection] \newcounter{allsss}[subsubsection] % Set the current number of a label \newcommand{\setLabelNumber}[2]{% \setcounter{#1}{#2}% \addtocounter{#1}{-1}% \setcounter{#1ss}{#2}% \addtocounter{#1ss}{-1}% \setcounter{#1sss}{#2}% \addtocounter{#1sss}{-1}% } \newcommand{\stepLabelNumber}[1]{% \stepcounter{#1}% \stepcounter{#1ss}% \stepcounter{#1sss}% } \newcommand{\printcounter}[1]{% \csname the#1\endcsname } \newcommand{\suffix}{ss} \newcommand{\sectionNumbering}{\thesection} % ┌ ┐ % │ Counter numbering │ % └ ┘ \newcommand{\preTableAndFigHook}[1]{% \ifnum\value{numberingConfig}>1 \ifnum\value{numberSubsections}=1 \stepcounter{allss} \else \ifnum\value{numberSubsections}=2 \stepcounter{allsss} \else \stepcounter{all} \fi \fi } \AtBeginEnvironment{table}{\preTableAndFigHook{table}} \AtBeginEnvironment{figure}{\preTableAndFigHook{figure}} \newcommand{\applyTableAndFigureNumbering}{ % Tables & Figures \ifnum\value{numberingConfig}=0 \renewcommand{\thetable}{} \renewcommand{\thefigure}{} \else \ifnum\value{numberingConfig}=1 \renewcommand{\thetable}{\sectionNumbering.\arabic{table}} \renewcommand{\thefigure}{\sectionNumbering.\arabic{figure}} \else \ifnum\value{numberSubsections}=1 \renewcommand{\thetable}{\sectionNumbering.\arabic{allss}} \renewcommand{\thefigure}{\sectionNumbering.\arabic{allss}} \else \ifnum\value{numberSubsections}=2 \renewcommand{\thetable}{\refstepcounter{allsss}\sectionNumbering.\arabic{allsss}} \renewcommand{\thefigure}{\sectionNumbering.\arabic{allsss}} \else \renewcommand{\thetable}{\sectionNumbering.\arabic{all}} \renewcommand{\thefigure}{\sectionNumbering.\arabic{all}} \fi \fi \fi \fi } \newcommand{\setSubsectionNumbering}[1]{ \setcounter{numberSubsections}{#1} \applySubsectionNumbering } \newcommand{\applySubsectionNumbering}{ \ifnum\value{numberSubsections}=1 \renewcommand{\sectionNumbering}{\thesubsection} \renewcommand{\suffix}{ss} \typeout{Numbering as section.subsection.number} \else \ifnum\value{numberSubsections}=2 \renewcommand{\sectionNumbering}{\thesubsubsection} \renewcommand{\suffix}{sss} \typeout{Numbering as section.subsection.subsubsection.number} \else \renewcommand{\sectionNumbering}{\thesection} \renewcommand{\suffix}{} \typeout{Numbering as section.number} \fi \fi \applyTableAndFigureNumbering \renewcommand{\thelemma}{\sectionNumbering.\arabic{lemma}} \renewcommand{\thedefinition}{\sectionNumbering.\arabic{definition}} \renewcommand{\thecorollary}{\sectionNumbering.\arabic{corollary}} \renewcommand{\thetheorem}{\sectionNumbering.\arabic{theorem}} \renewcommand{\theaxiom}{\sectionNumbering.\arabic{axiom}} \renewcommand{\theexample}{\sectionNumbering.\arabic{example}} \renewcommand{\thefact}{\sectionNumbering.\arabic{fact}} \renewcommand{\theproposition}{\sectionNumbering.\arabic{proposition}} \renewcommand{\theformula}{\sectionNumbering.\arabic{formula}} \renewcommand{\theremark}{\sectionNumbering.\arabic{remark}} \renewcommand{\theall}{\sectionNumbering.\arabic{all}} \renewcommand{\thelemmass}{\sectionNumbering.\arabic{lemmass}} \renewcommand{\thedefinitionss}{\sectionNumbering.\arabic{definitionss}} \renewcommand{\thecorollaryss}{\sectionNumbering.\arabic{corollaryss}} \renewcommand{\thetheoremss}{\sectionNumbering.\arabic{theoremss}} \renewcommand{\theaxiomss}{\sectionNumbering.\arabic{axiomss}} \renewcommand{\theexampless}{\sectionNumbering.\arabic{exampless}} \renewcommand{\thefactss}{\sectionNumbering.\arabic{factss}} \renewcommand{\thepropositionss}{\sectionNumbering.\arabic{propositionss}} \renewcommand{\theformulass}{\sectionNumbering.\arabic{formulass}} \renewcommand{\theremarkss}{\sectionNumbering.\arabic{remarkss}} \renewcommand{\theallss}{\sectionNumbering.\arabic{allss}} \renewcommand{\thelemmasss}{\sectionNumbering.\arabic{lemmasss}} \renewcommand{\thedefinitionsss}{\sectionNumbering.\arabic{definitionsss}} \renewcommand{\thecorollarysss}{\sectionNumbering.\arabic{corollarysss}} \renewcommand{\thetheoremsss}{\sectionNumbering.\arabic{theoremsss}} \renewcommand{\theaxiomsss}{\sectionNumbering.\arabic{axiomsss}} \renewcommand{\theexamplesss}{\sectionNumbering.\arabic{examplesss}} \renewcommand{\thefactsss}{\sectionNumbering.\arabic{factsss}} \renewcommand{\thepropositionsss}{\sectionNumbering.\arabic{propositionsss}} \renewcommand{\theformulasss}{\sectionNumbering.\arabic{formulasss}} \renewcommand{\theremarksss}{\sectionNumbering.\arabic{remarksss}} \renewcommand{\theallsss}{\sectionNumbering.\arabic{allsss}} } \applySubsectionNumbering % ── Label generation ──────────────────────────────────────────────── \newcommand{\labelSectionGeneration}{% \ifnum\value{numberSubsections}=1 \arabic{section}-\arabic{subsection}% \else \ifnum\value{numberSubsections}=2 \arabic{section}-\arabic{subsection}-\arabic{subsubsection}% \else \arabic{section}% \fi \fi} \newcommand{\labelIt}[1]{\refstepcounter{#1\suffix}\edef\tempLabel{\genLabel{#1}{\arabic{#1\suffix}}}\label{\tempLabel}} \newcommand{\genLabel}[2]{#1:\labelSectionGeneration-#2} % ┌ ┐ % │ Number the counters appropriately │ % └ ┘ \newcommand{\usenumberArabic}[1]{% \ifnum\value{numberingConfig}=1 \labelIt{#1} \printcounter{#1\suffix}% \else \ifnum\value{numberingConfig}=2 \ifthenelse{\equal{#1}{definitions}}{% \labelIt{definition} \printcounter{definition\suffix}% }{% \labelIt{all} \printcounter{all\suffix}% }% \else \ifnum\value{numberingConfig}=3 \labelIt{all} \printcounter{all\suffix}% \else \relax% \fi \fi \fi} % ──────────────────────────────────────────────────────────────────── % ┌ ┐ % │ Enable or disable numbering │ % └ ┘ % Initialize with config file \newcounter{numberingConfigStore} \setcounter{numberingConfigStore}{\value{numberingConfig}} % For later change \newcommand{\setNumberingStyle}[1]{ \typeout{Setting NumberingStyle to #1} \setcounter{numberingConfig}{#1} \ifthenelse{\equal{#1}{0}}{}{ \setcounter{numberingConfigStore}{#1} } \applyTableAndFigureNumbering } % Enable / disable numbering \newcommand{\numberingOff}{ \setcounter{numberingConfig}{0} \applyTableAndFigureNumbering } \newcommand{\numberingOn}{ \setcounter{numberingConfig}{\value{numberingConfigStore}} \applyTableAndFigureNumbering } % ──────────────────────────────────────────────────────────────────── % ╭────────────────────────────────────────────────╮ % │ Reset definition, lemma, etc counters, add a │ % │ new page │ % ╰────────────────────────────────────────────────╯ \newcommand{\newsection}{ \newpage \newsectionNoPB } % ── Reset definitions, lemma, etc counters, do not add new page ───── \newcommand{\newsectionNoPB}{ \setcounter{lemma}{0} \setcounter{definition}{0} \setcounter{corollary}{0} \setcounter{theorem}{0} \setcounter{axiom}{0} \setcounter{example}{0} \setcounter{fact}{0} \setcounter{proposition}{0} \setcounter{formula}{0} \setcounter{remark}{0} \setcounter{all}{0} \setcounter{lemmass}{0} \setcounter{definitionss}{0} \setcounter{corollaryss}{0} \setcounter{theoremss}{0} \setcounter{axiomss}{0} \setcounter{exampless}{0} \setcounter{factss}{0} \setcounter{propositionss}{0} \setcounter{formulass}{0} \setcounter{remarkss}{0} \setcounter{allss}{0} \setcounter{lemmasss}{0} \setcounter{definitionsss}{0} \setcounter{corollarysss}{0} \setcounter{theoremsss}{0} \setcounter{axiomsss}{0} \setcounter{examplesss}{0} \setcounter{factsss}{0} \setcounter{propositionsss}{0} \setcounter{formulasss}{0} \setcounter{remarksss}{0} \setcounter{allsss}{0} % Tables & Figures \setcounter{table}{0} \setcounter{figure}{0} } \newsectionNoPB % Initializes % ──────────────────────────────────────────────────────────────────── % ╭────────────────────────────────────────────────╮ % │ Tcolorboxes │ % ╰────────────────────────────────────────────────╯ % ──────────────────────────────────────────────────────────────────── % Definitions \newtcolorbox{definition}[2][]{mainboxstyle,colback=blue!5!white,colframe=blue!75!black,colbacktitle=blue!75!black,title={\large #2},overlay={\node[overlaystyle,draw=blue!75!black,fill=blue!75!black] at (frame.north east) {\large Definition\usenumberArabic{definition}};},#1} % Theorems \newtcolorbox{theorem}[2][]{mainboxstyle,colback=ForestGreen!5!white,colframe=ForestGreen!75!black,colbacktitle=ForestGreen!75!black,title={\large #2}, overlay={\node[overlaystyle,draw=ForestGreen!75!black,fill=ForestGreen!75!black] at (frame.north east) {\large \translate{Theorem}{\theoremde}\usenumberArabic{theorem}};},#1} % Lemmas \newtcolorbox{lemma}[2][]{mainboxstyle,colback=Aquamarine!5!white,colframe=Aquamarine!75!black,colbacktitle=Aquamarine!75!black,title={\large #2}, overlay={\node[overlaystyle,draw=Aquamarine!75!black,fill=Aquamarine!75!black] at (frame.north east) {\large Lemma\usenumberArabic{lemma}};},#1} % Corollaries \newtcolorbox{corollary}[2][]{mainboxstyle,colback=teal!5!white,colframe=teal!75!black,colbacktitle=teal!75!black,title={\large #2}, overlay={\node[overlaystyle,draw=teal!75!black,fill=teal!75!black] at (frame.north east) {\large \translate{Corollary}{Korollar}\usenumberArabic{corollary}};},#1} % Axioms \newtcolorbox{axiom}[2][]{mainboxstyle,colback=JungleGreen!5!white,colframe=JungleGreen!75!black,colbacktitle=JungleGreen!75!black,title={\large #2}, overlay={\node[overlaystyle,draw=JungleGreen!75!black,fill=JungleGreen!75!black] at (frame.north east) {\large Axiom\usenumberArabic{axiom}};},#1} % Facts \newtcolorbox{fact}[2][]{mainboxstyle,colback=SeaGreen!5!white,colframe=SeaGreen!75!black,colbacktitle=SeaGreen!75!black,title={\large #2}, overlay={\node[overlaystyle,draw=SeaGreen!75!black,fill=SeaGreen!75!black] at (frame.north east) {\large \translate{Fact}{Fakt}\usenumberArabic{fact}};},#1} % Propositions \newtcolorbox{proposition}[2][]{mainboxstyle,colback=Cyan!5!white,colframe=Cyan!75!black,colbacktitle=Cyan!75!black,title={\large #2}, overlay={\node[overlaystyle,draw=Cyan!75!black,fill=Cyan!75!black] at (frame.north east) {\large Proposition\usenumberArabic{proposition}};},#1} % Examples \newtcolorbox{example}[2][]{mainboxstyle,colback=gray!5!white,colframe=gray!75!black,colbacktitle=gray!75!black,title={\large #2}, overlay={\node[overlaystyle,draw=gray!75!black,fill=gray!75!black] at (frame.north east) {\large \translate{Example}{Beispiel}\usenumberArabic{example}};},#1} % Formula \newtcolorbox{formula}[2][]{mainboxstyle,colback=red!5!white,colframe=red!75!black,colbacktitle=red!75!black,title={\large #2}, overlay={\node[overlaystyle,draw=red!75!black,fill=red!75!black] at (frame.north east) {\large \translate{Formula}{Formel}\usenumberArabic{formula}};},#1} % Remark \newtcolorbox{remark}[2][]{mainboxstyle,colback=green!5!white,colframe=green!75!black,colbacktitle=green!75!black,title={\large #2}, overlay={\node[overlaystyle,draw=green!75!black,fill=green!75!black] at (frame.north east) {\large \translate{Remark}{Bemerkung} \usenumberArabic{remark}};},#1} % ──────────────────────────────────────────────────────────────────── % ╭────────────────────────────────────────────────╮ % │ Inline environments │ % ╰────────────────────────────────────────────────╯ % ──────────────────────────────────────────────────────────────────── % Inline environments (inline) \newcommand{\inlineex}{\bg{gray}{\translate{Example}{Beispiel}\usenumberArabic{example}:}} \newcommand{\inlinedef}{\bg{blue}{Definition\usenumberArabic{definition}:}} \newcommand{\inlineformula}{\bg{red}{\translate{Formula}{Formel}\usenumberArabic{formula}:}} \newcommand{\inlinelemma}{\bg{Aquamarine}{Lemma\usenumberArabic{lemma}:}} \newcommand{\inlinetheorem}{\bg{ForestGreen}{\translate{Theorem}{\theoremde}\usenumberArabic{theorem}:}} \newcommand{\inlineaxiom}{\bg{JungleGreen}{Axiom\usenumberArabic{axiom}:}} \newcommand{\inlinecorollary}{\bg{teal}{\translate{Corollary}{Korollar}\usenumberArabic{corollary}:}} \newcommand{\inlinefact}{\bg{SeaGreen}{\translate{Fact}{Fakt}\usenumberArabic{fact}:}} \newcommand{\inlineproposition}{\bg{Cyan}{Proposition\usenumberArabic{proposition}:}} \newcommand{\inlineremark}{\bg{green}{\translate{Remark}{Bemerkung}\usenumberArabic{remark}:}} \newcommand{\inlineproof}{\bg{magenta}{\translate{Proof}{Beweis}:}} % Enhanced inline environments \newcommand{\fancyex}[1]{\bg{gray}{\translate{Example}{Beispiel}\usenumberArabic{example}:} \textit{(#1)}} \newcommand{\fancydef}[1]{\bg{blue}{Definition\usenumberArabic{definition}:} \textit{(#1)}} \newcommand{\fancyformula}[1]{\bg{red}{\translate{Formula}{Formel}\usenumberArabic{formula}:} \textit{(#1)}} \newcommand{\fancylemma}[1]{\bg{Aquamarine}{Lemma\usenumberArabic{lemma}:} \textit{(#1)}} \newcommand{\fancytheorem}[1]{\bg{ForestGreen}{\translate{Theorem}{\theoremde}\usenumberArabic{theorem}:} \textit{(#1)}} \newcommand{\fancyaxiom}[1]{\bg{JungleGreen}{Axiom\usenumberArabic{axiom}:} \textit{(#1)}} \newcommand{\fancycorollary}[1]{\bg{teal}{\translate{Corollary}{Korollar}\usenumberArabic{corollary}:} \textit{(#1)}} \newcommand{\fancyfact}[1]{\bg{SeaGreen}{\translate{Fact}{Fakt}\usenumberArabic{fact}:} \textit{(#1)}} \newcommand{\fancyproposition}[1]{\bg{Cyan}{Proposition\usenumberArabic{proposition}:} \textit{(#1)}} \newcommand{\fancyremark}[1]{\bg{green}{\translate{Remark}{Bemerkung}\usenumberArabic{remark}:} \textit{(#1)}} \newcommand{\fancyproof}[1]{\bg{magenta}{\translate{Proof}{Beweis}: \textit{(#1)}}} % short environments (abbreviated) \newcommand{\shortex}{\bg{gray}{\translate{Ex}{Bsp}\usenumberArabic{example}:}} \newcommand{\shortdef}{\bg{blue}{D\usenumberArabic{definition}:}} \newcommand{\short}{\bg{red}{F\usenumberArabic{formula}:}} \newcommand{\shortlemma}{\bg{Aquamarine}{L\usenumberArabic{lemma}:}} \newcommand{\shorttheorem}{\bg{ForestGreen}{\translate{T}{\StrMid{\theoremde}{1}{1}}\usenumberArabic{theorem}:}} \newcommand{\shortaxiom}{\bg{JungleGreen}{A\usenumberArabic{axiom}:}} \newcommand{\shortcorollary}{\bg{teal}{\translate{C}{K}\usenumberArabic{corollary}:}} \newcommand{\shortfact}{\bg{SeaGreen}{F\usenumberArabic{fact}:}} \newcommand{\shortproposition}{\bg{Cyan}{P\usenumberArabic{proposition}:}} \newcommand{\shortremark}{\bg{green}{\tr{R}{B}\usenumberArabic{remark}:}} \newcommand{\shortproof}{\bg{magenta}{\translate{Proof}{Beweis}:}} % Enhanced short environments (abbreviated) \newcommand{\compactex}[1]{\bg{gray}{\translate{Ex}{Bsp}\usenumberArabic{example}:} \textit{(#1)}} \newcommand{\compactdef}[1]{\bg{blue}{D\usenumberArabic{definition}:} \textit{(#1)}} \newcommand{\compactformula}[1]{\bg{red}{F\usenumberArabic{formula}:} \textit{(#1)}} \newcommand{\compactlemma}[1]{\bg{Aquamarine}{L\usenumberArabic{lemma}:} \textit{(#1)}} \newcommand{\compacttheorem}[1]{\bg{ForestGreen}{\translate{T}{\StrMid{\theoremde}{1}{1}} \usenumberArabic{theorem}:} \textit{(#1)}} \newcommand{\compactaxiom}[1]{\bg{JungleGreen}{A\usenumberArabic{axiom}:} \textit{(#1)}} \newcommand{\compactcorollary}[1]{\bg{teal}{\translate{C}{K}\usenumberArabic{corollary}:} \textit{(#1)}} \newcommand{\compactfact}[1]{\bg{SeaGreen}{F\usenumberArabic{fact}:} \textit{(#1)}} \newcommand{\compactproposition}[1]{\bg{Cyan}{P\usenumberArabic{proposition}:} \textit{(#1)}} \newcommand{\compactremark}[1]{\bg{green}{\tr{R}{B}\usenumberArabic{remark}:} \textit{(#1)}} \newcommand{\compactproof}[1]{\bg{magenta}{\translate{Proof}{Beweis}: \textit{(#1)}}}