diff --git a/build/labels.py b/build/labels.py index 9978e55..d896ba9 100644 --- a/build/labels.py +++ b/build/labels.py @@ -1,7 +1,7 @@ # Auto-generate labels and version numbers def generate_labels(): data = "" - reset_func = "\\newcommand{\\newsectionNoPB}{" + reset_func = "\\newcommand{\\resetNumbering}{" for label in [ "definition", diff --git a/janishutz-helpers.tex b/janishutz-helpers.tex index 2414119..59f9127 100644 --- a/janishutz-helpers.tex +++ b/janishutz-helpers.tex @@ -159,6 +159,8 @@ \newcommand{\usagenumbering}{default} \newcommand{\recallnumbering}{default} \newcommand{\propertiesnumbering}{default} +\newcommand{\tablenumbering}{default} +\newcommand{\figurenumbering}{default} % ┌ ┐ @@ -449,7 +451,7 @@ \renewcommand{\thecombineparagraph}{\theparagraph.\arabic{combineparagraph}} \newcommand{\inlinecombine}[1][NONAME]{\inline[#1]{combine}}\newcommand{\shortcombine}[1][NONAME]{\short[#1]{combine}} -\newcommand{\newsectionNoPB}{ +\newcommand{\resetNumbering}{ \setcounter{definitionnone}{0} \setcounter{definitionsection}{0} \setcounter{definitionsubsection}{0} @@ -595,6 +597,27 @@ } +% ___ _ _____ _ _ +% ( _ \ _( ) (_ _) ( ) ( ) +% | (_) )_) |_ | | __ \ \/ / +% | _ (| | _ \ | | / __ \ ) ( +% | (_) ) | |_) ) | | ( ___// /\ \ +% (____/(_)_ __/ (_) \____)_) (_) + +% Configs if you want to use BibTeX + +\newcommand{\setupBibtex}[1]{ + \usepackage{biblatex} + \usepackage[nottoc, numbib]{tocbibind} + \addbibresource{#1} +} + +\newcommand{\printbib}{ + \addcontentsline{toc}{section}{\translate{Sources}{Quellen}} + \printbibliography[title=\translate{Sources}{Quellen}] +} + + % ┌ ┐ % │ Math │ % └ ┘ @@ -790,6 +813,170 @@ } +% ── Label generator ───────────────────────────────────────────────── +\newcommand{\printNumberingConfigForDescriptor}[1]{\csname #1numbering\endcsname} +\newcommand{\printCounter}[1]{\refstepcounter{#1}\csname the#1\endcsname} + +\newcommand{\printLabel}[1]{% + \ifthenelse{\boolean{numberingDisabled}}{}{ + \ifcsdef{#1numbering}{% Extra config present + \ifthenelse{\equal{\printNumberingConfigForDescriptor{#1}}{default}}{% + \labelPrintBackendRoutine{#1}% + }{% + \ifthenelse{\equal{\printNumberingConfigForDescriptor{#1}}{separate}}{% + \printCounter{#1\subsectionnumbering}% + }{% + \ifthenelse{\equal{\printNumberingConfigForDescriptor{#1}}{combined}}{% + \printCounter{combined\subsectionnumbering}% + }{}% + }% + }% + }{% + \labelPrintBackendRoutine{#1}% + }% + }% +} + +\newcommand{\labelPrintBackendRoutine}[1]{% + \ifthenelse{\equal{\numberingpreset}{combined}}{% + \printCounter{combined\subsectionnumbering}% + }{ + \ifthenelse{\equal{\numberingpreset}{separate}}{% + \printCounter{#1\subsectionnumbering}% + }{}% + }% +} + +% ── Set the current number of a label ─────────────────────────────── +\newcommand{\setLabelNumber}[2]{% + \setcounter{#1none}{#2}% + \addtocounter{#1none}{-1}% + \setcounter{#1section}{#2}% + \addtocounter{#1section}{-1}% + \setcounter{#1subsection}{#2}% + \addtocounter{#1subsection}{-1}% + \setcounter{#1subsubsection}{#2}% + \addtocounter{#1subsubsection}{-1}% + \setcounter{#1paragraph}{#2}% + \addtocounter{#1paragraph}{-1}% +} + +\newcommand{\stepLabelNumber}[1]{% + \stepcounter{#1none}% + \stepcounter{#1section}% + \stepcounter{#1subsection}% + \stepcounter{#1subsubsection}% + \stepcounter{#1paragraph}% +} + +% ┌ ┐ +% │ Counter numbering │ +% └ ┘ +\newcommand{\preEnvHook}[1]{% + \ifthenelse{\boolean{numberingDisabled}}{}{ + \ifthenelse{\equal{\numberingpreset}{combined} \AND \equal{\printNumberingConfigForDescriptor{#1}}{default}}{% + \stepLabelNumber{combined}% + }{% + \ifthenelse{\equal{\printNumberingConfigForDescriptor{#1}}{combined}}{% + \stepLabelNumber{combined}% + }{}% + }% + }% +} + +% Decides on the numbering to use (combined or not) +\newcommand{\tableAndFigureNumberingHelper}[1]{% + \ifthenelse{\boolean{numberingDisabled}}{}{ + \ifthenelse{\equal{\printNumberingConfigForDescriptor{#1}{default}}}{% Using default + \ifthenelse{\equal{\numberingpreset}{combined}}{% + \tableAndFigureSubsectionPrinting{\value{combined\subsectionnumbering}}% + }{% + \ifthenelse{\equal{\numberingpreset}{separate}}{% + \tableAndFigureSubsectionPrinting{\value{#1}}% + }{}% + }% + }{% if we get here, default has been changed + \ifthenelse{\equal{\printNumberingConfigForDescriptor{#1}{combined}}}{% + \tableAndFigureSubsectionPrinting{\value{combined\subsectionnumbering}}% + }{% + \ifthenelse{\equal{\printNumberingConfigForDescriptor{#1}{separate}}}{% + \tableAndFigureSubsectionPrinting{\value{#1}}% + }{}% + }% + }% + }% +} + +% Prints the preceding subsection numbers +\newcommand{\tableAndFigureSubsectionPrinting}[1]{% + \ifthenelse{\equal{\subsectionnumbering}{section}}{% + \thesection.#1% + }{% + \ifthenelse{\equal{\subsectionnumbering}{subsection}}{% + \thesubsection.#1% + }{% + \ifthenelse{\equal{\subsectionnumbering}{subsubsection}}{% + \thesubsubsection.#1% + }{% + \ifthenelse{\equal{\subsectionnumbering}{paragraph}}{% + \theparagraph.#1 + }{% + #1 + }% + }% + }% + }% +} + +\renewcommand{\thetable}{\tableAndFigureNumberingHelper{table}} +\renewcommand{\thefigure}{\tableAndFigureNumberingHelper{figure}} + +\AtBeginEnvironment{table}{\preEnvHook{table}} +\AtBeginEnvironment{figure}{\preEnvHook{figure}} + + +\newcommand{\newsection}{% + \newpage + \newsectionNoPB +} + +\newcommand{\newsectionNoPB}{ + \ifthenelse{\equal{\numberingpreset}{off}}{}{% + \resetNumbering% + }% +} + +\newcommand{\resetTableAndFigureNumbering}{% + \ifthenelse{\equal{\printNumberingConfigForDescriptor{table}}{combined} \OR \equal{\printNumberingConfigForDescriptor{table}{default}}}{% + \setcounter{table}{0} + }{}% + \ifthenelse{\equal{\printNumberingConfigForDescriptor{figure}}{combined} \OR \equal{\printNumberingConfigForDescriptor{figure}{default}}}{% + \setcounter{figure}{0} + }{}% +} + + +% Numbering toggling +\newboolean{numberingDisabled} +\setboolean{numberingDisabled}{false} +\newcommand{\numberingOff}{\setboolean{numberingDisabled}{true}} +\newcommand{\numberingOn}{\setboolean{numberingDisabled}{false}} + + +% Add glossaries functionality + +\newcommand{\setupGlossary}{ + \usepackage[nonumberlist, toc]{glossaries} + \usepackage[nottoc, numbib]{tocbibind} + \makenoidxglossaries +} + +\newcommand{\printGlossary}{ + \glsaddall + \printnoidxglossaries +} + + % ┌ ┐ % │ Translation │ % └ ┘ @@ -943,6 +1130,24 @@ \newcommand{\proven}{$\hspace{17cm}\square$} +% ── Inline environments ───────────────────────────────────────────── +\newcommand{\inline}[2][NONAME]{% + \ifthenelse{\equal{NONAME}{#1}}{% + \anonymousInlineDescriptorTemplate{#2}{\printLabel{#2}}% + }{% + \inlineDescriptorTemplate{#2}{\printLabel{#2}}{#1}% + } +} + +\newcommand{\short}[2][NONAME]{% + \ifthenelse{\equal{NONAME}{#1}}{% + \anonymousShortDescriptorTemplate{#2}{\printLabel{#2}}% + }{% + \shortDescriptorTemplate{#2}{\printLabel{#2}}{#1}% + } +} + + % ┌ ┐ % │ STYLE: Common tcolorboxes │ % └ ┘ @@ -1001,105 +1206,6 @@ \newtcolorbox{simplebox}[2][]{colback=#2!5!white,colframe=#2!75!black,#1} -% ── Label generator ───────────────────────────────────────────────── -\newcommand{\printNumberingConfigForDescriptor}[1]{\csname #1numbering\endcsname} -\newcommand{\printCounter}[1]{\refstepcounter{#1}\csname the#1\endcsname} - -\newcommand{\printLabel}[1]{% - \ifcsdef{#1numbering}{% Extra config present - \ifthenelse{\equal{\printNumberingConfigForDescriptor{#1}}{default}}{% - \printCounter{#1\subsectionnumbering}% - }{% - \ifthenelse{\equal{\printNumberingConfigForDescriptor{#1}}{separate}}{% - \printCounter{#1\subsectionnumbering}% - }{% - \ifthenelse{\equal{\printNumberingConfigForDescriptor{#1}}{combined}}{% - \printCounter{combined\subsectionnumbering}% - }{}% - }% - }% - }{% - \labelPrintBackendRoutine{#1}% - }% -} -\newcommand{\labelPrintBackendRoutine}[1]{ - \ifthenelse{\equal{\numberingpreset}{combined}}{ - \printCounter{combined\subsectionnumbering}% - }{ - \ifthenelse{\equal{\numberingpreset}{separate}}{ - \printCounter{#1\subsectionnumbering}% - }{} - } -} - -% Inline environments (inline) -\newcommand{\inline}[2][NONAME]{% - \ifthenelse{\equal{NONAME}{#1}}{% - \anonymousInlineDescriptorTemplate{#2}{\printLabel{#2}}% - }{% - \inlineDescriptorTemplate{#2}{\printLabel{#2}}{#1}% - } -} - -\newcommand{\short}[2][NONAME]{% - \ifthenelse{\equal{NONAME}{#1}}{% - \anonymousShortDescriptorTemplate{#2}{\printLabel{#2}}% - }{% - \shortDescriptorTemplate{#2}{\printLabel{#2}}{#1}% - } -} - -% ── Set the current number of a label ─────────────────────────────── -\newcommand{\setLabelNumber}[2]{% - \setcounter{#1none}{#2}% - \addtocounter{#1none}{-1}% - \setcounter{#1section}{#2}% - \addtocounter{#1section}{-1}% - \setcounter{#1subsection}{#2}% - \addtocounter{#1subsection}{-1}% - \setcounter{#1subsubsection}{#2}% - \addtocounter{#1subsubsection}{-1}% - \setcounter{#1paragraph}{#2}% - \addtocounter{#1paragraph}{-1}% -} - -\newcommand{\stepLabelNumber}[1]{% - \stepcounter{#1none}% - \stepcounter{#1section}% - \stepcounter{#1subsection}% - \stepcounter{#1subsubsection}% - \stepcounter{#1paragraph}% -} - -% ┌ ┐ -% │ Counter numbering │ -% └ ┘ -% TODO: Update -\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 - \fi - \renewcommand{\thetable}{\arabic{table}} - \renewcommand{\thefigure}{\arabic{figure}} -} -\AtBeginEnvironment{table}{\preTableAndFigHook{table}} -\AtBeginEnvironment{figure}{\preTableAndFigHook{figure}} - - -\newcommand{\newsection}{ - \newpage - \newsectionNoPB -} - - % ┌ ┐ % │ STYLE: Computer Science │ % └ ┘ diff --git a/src/config/numbering.sty b/src/config/numbering.sty index de62377..cfb9e71 100644 --- a/src/config/numbering.sty +++ b/src/config/numbering.sty @@ -35,3 +35,5 @@ \newcommand{\usagenumbering}{default} \newcommand{\recallnumbering}{default} \newcommand{\propertiesnumbering}{default} +\newcommand{\tablenumbering}{default} +\newcommand{\figurenumbering}{default} diff --git a/src/core/bib.sty b/src/core/bib.sty new file mode 100644 index 0000000..66418fd --- /dev/null +++ b/src/core/bib.sty @@ -0,0 +1,19 @@ +% ___ _ _____ _ _ +% ( _ \ _( ) (_ _) ( ) ( ) +% | (_) )_) |_ | | __ \ \/ / +% | _ (| | _ \ | | / __ \ ) ( +% | (_) ) | |_) ) | | ( ___// /\ \ +% (____/(_)_ __/ (_) \____)_) (_) + +% Configs if you want to use BibTeX + +\newcommand{\setupBibtex}[1]{ + \RequirePackage{biblatex} + \RequirePackage[nottoc, numbib]{tocbibind} + \addbibresource{#1} +} + +\newcommand{\printbib}{ + \addcontentsline{toc}{section}{\translate{Sources}{Quellen}} + \printbibliography[title=\translate{Sources}{Quellen}] +} diff --git a/src/core/counters.sty b/src/core/counters.sty new file mode 100644 index 0000000..c885a32 --- /dev/null +++ b/src/core/counters.sty @@ -0,0 +1,148 @@ +% ── Label generator ───────────────────────────────────────────────── +\newcommand{\printNumberingConfigForDescriptor}[1]{\csname #1numbering\endcsname} +\newcommand{\printCounter}[1]{\refstepcounter{#1}\csname the#1\endcsname} + +\newcommand{\printLabel}[1]{% + \ifthenelse{\boolean{numberingDisabled}}{}{ + \ifcsdef{#1numbering}{% Extra config present + \ifthenelse{\equal{\printNumberingConfigForDescriptor{#1}}{default}}{% + \labelPrintBackendRoutine{#1}% + }{% + \ifthenelse{\equal{\printNumberingConfigForDescriptor{#1}}{separate}}{% + \printCounter{#1\subsectionnumbering}% + }{% + \ifthenelse{\equal{\printNumberingConfigForDescriptor{#1}}{combined}}{% + \printCounter{combined\subsectionnumbering}% + }{}% + }% + }% + }{% + \labelPrintBackendRoutine{#1}% + }% + }% +} + +\newcommand{\labelPrintBackendRoutine}[1]{% + \ifthenelse{\equal{\numberingpreset}{combined}}{% + \printCounter{combined\subsectionnumbering}% + }{ + \ifthenelse{\equal{\numberingpreset}{separate}}{% + \printCounter{#1\subsectionnumbering}% + }{}% + }% +} + +% ── Set the current number of a label ─────────────────────────────── +\newcommand{\setLabelNumber}[2]{% + \setcounter{#1none}{#2}% + \addtocounter{#1none}{-1}% + \setcounter{#1section}{#2}% + \addtocounter{#1section}{-1}% + \setcounter{#1subsection}{#2}% + \addtocounter{#1subsection}{-1}% + \setcounter{#1subsubsection}{#2}% + \addtocounter{#1subsubsection}{-1}% + \setcounter{#1paragraph}{#2}% + \addtocounter{#1paragraph}{-1}% +} + +\newcommand{\stepLabelNumber}[1]{% + \stepcounter{#1none}% + \stepcounter{#1section}% + \stepcounter{#1subsection}% + \stepcounter{#1subsubsection}% + \stepcounter{#1paragraph}% +} + +% ┌ ┐ +% │ Counter numbering │ +% └ ┘ +\newcommand{\preEnvHook}[1]{% + \ifthenelse{\boolean{numberingDisabled}}{}{ + \ifthenelse{\equal{\numberingpreset}{combined} \AND \equal{\printNumberingConfigForDescriptor{#1}}{default}}{% + \stepLabelNumber{combined}% + }{% + \ifthenelse{\equal{\printNumberingConfigForDescriptor{#1}}{combined}}{% + \stepLabelNumber{combined}% + }{}% + }% + }% +} + +% Decides on the numbering to use (combined or not) +\newcommand{\tableAndFigureNumberingHelper}[1]{% + \ifthenelse{\boolean{numberingDisabled}}{}{ + \ifthenelse{\equal{\printNumberingConfigForDescriptor{#1}{default}}}{% Using default + \ifthenelse{\equal{\numberingpreset}{combined}}{% + \tableAndFigureSubsectionPrinting{\value{combined\subsectionnumbering}}% + }{% + \ifthenelse{\equal{\numberingpreset}{separate}}{% + \tableAndFigureSubsectionPrinting{\value{#1}}% + }{}% + }% + }{% if we get here, default has been changed + \ifthenelse{\equal{\printNumberingConfigForDescriptor{#1}{combined}}}{% + \tableAndFigureSubsectionPrinting{\value{combined\subsectionnumbering}}% + }{% + \ifthenelse{\equal{\printNumberingConfigForDescriptor{#1}{separate}}}{% + \tableAndFigureSubsectionPrinting{\value{#1}}% + }{}% + }% + }% + }% +} + +% Prints the preceding subsection numbers +\newcommand{\tableAndFigureSubsectionPrinting}[1]{% + \ifthenelse{\equal{\subsectionnumbering}{section}}{% + \thesection.#1% + }{% + \ifthenelse{\equal{\subsectionnumbering}{subsection}}{% + \thesubsection.#1% + }{% + \ifthenelse{\equal{\subsectionnumbering}{subsubsection}}{% + \thesubsubsection.#1% + }{% + \ifthenelse{\equal{\subsectionnumbering}{paragraph}}{% + \theparagraph.#1 + }{% + #1 + }% + }% + }% + }% +} + +\renewcommand{\thetable}{\tableAndFigureNumberingHelper{table}} +\renewcommand{\thefigure}{\tableAndFigureNumberingHelper{figure}} + +\AtBeginEnvironment{table}{\preEnvHook{table}} +\AtBeginEnvironment{figure}{\preEnvHook{figure}} + + +\newcommand{\newsection}{% + \newpage + \newsectionNoPB +} + +\newcommand{\newsectionNoPB}{ + \ifthenelse{\equal{\numberingpreset}{off}}{}{% + \resetNumbering% + }% +} + +\newcommand{\resetTableAndFigureNumbering}{% + \ifthenelse{\equal{\printNumberingConfigForDescriptor{table}}{combined} \OR \equal{\printNumberingConfigForDescriptor{table}{default}}}{% + \setcounter{table}{0} + }{}% + \ifthenelse{\equal{\printNumberingConfigForDescriptor{figure}}{combined} \OR \equal{\printNumberingConfigForDescriptor{figure}{default}}}{% + \setcounter{figure}{0} + }{}% +} + + +% Numbering toggling +\newboolean{numberingDisabled} +\setboolean{numberingDisabled}{false} +\newcommand{\numberingOff}{\setboolean{numberingDisabled}{true}} +\newcommand{\numberingOn}{\setboolean{numberingDisabled}{false}} diff --git a/src/core/glossary.sty b/src/core/glossary.sty new file mode 100644 index 0000000..6345f21 --- /dev/null +++ b/src/core/glossary.sty @@ -0,0 +1,12 @@ +% Add glossaries functionality + +\newcommand{\setupGlossary}{ + \RequirePackage[nonumberlist, toc]{glossaries} + \RequirePackage[nottoc, numbib]{tocbibind} + \makenoidxglossaries +} + +\newcommand{\printGlossary}{ + \glsaddall + \printnoidxglossaries +} diff --git a/src/style/counters.sty b/src/style/counters.sty deleted file mode 100644 index 2f31b03..0000000 --- a/src/style/counters.sty +++ /dev/null @@ -1,97 +0,0 @@ -% ── Label generator ───────────────────────────────────────────────── -\newcommand{\printNumberingConfigForDescriptor}[1]{\csname #1numbering\endcsname} -\newcommand{\printCounter}[1]{\refstepcounter{#1}\csname the#1\endcsname} - -\newcommand{\printLabel}[1]{% - \ifcsdef{#1numbering}{% Extra config present - \ifthenelse{\equal{\printNumberingConfigForDescriptor{#1}}{default}}{% - \printCounter{#1\subsectionnumbering}% - }{% - \ifthenelse{\equal{\printNumberingConfigForDescriptor{#1}}{separate}}{% - \printCounter{#1\subsectionnumbering}% - }{% - \ifthenelse{\equal{\printNumberingConfigForDescriptor{#1}}{combined}}{% - \printCounter{combined\subsectionnumbering}% - }{}% - }% - }% - }{% - \labelPrintBackendRoutine{#1}% - }% -} -\newcommand{\labelPrintBackendRoutine}[1]{ - \ifthenelse{\equal{\numberingpreset}{combined}}{ - \printCounter{combined\subsectionnumbering}% - }{ - \ifthenelse{\equal{\numberingpreset}{separate}}{ - \printCounter{#1\subsectionnumbering}% - }{} - } -} - -% Inline environments (inline) -\newcommand{\inline}[2][NONAME]{% - \ifthenelse{\equal{NONAME}{#1}}{% - \anonymousInlineDescriptorTemplate{#2}{\printLabel{#2}}% - }{% - \inlineDescriptorTemplate{#2}{\printLabel{#2}}{#1}% - } -} - -\newcommand{\short}[2][NONAME]{% - \ifthenelse{\equal{NONAME}{#1}}{% - \anonymousShortDescriptorTemplate{#2}{\printLabel{#2}}% - }{% - \shortDescriptorTemplate{#2}{\printLabel{#2}}{#1}% - } -} - -% ── Set the current number of a label ─────────────────────────────── -\newcommand{\setLabelNumber}[2]{% - \setcounter{#1none}{#2}% - \addtocounter{#1none}{-1}% - \setcounter{#1section}{#2}% - \addtocounter{#1section}{-1}% - \setcounter{#1subsection}{#2}% - \addtocounter{#1subsection}{-1}% - \setcounter{#1subsubsection}{#2}% - \addtocounter{#1subsubsection}{-1}% - \setcounter{#1paragraph}{#2}% - \addtocounter{#1paragraph}{-1}% -} - -\newcommand{\stepLabelNumber}[1]{% - \stepcounter{#1none}% - \stepcounter{#1section}% - \stepcounter{#1subsection}% - \stepcounter{#1subsubsection}% - \stepcounter{#1paragraph}% -} - -% ┌ ┐ -% │ Counter numbering │ -% └ ┘ -% TODO: Update -\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 - \fi - \renewcommand{\thetable}{\arabic{table}} - \renewcommand{\thefigure}{\arabic{figure}} -} -\AtBeginEnvironment{table}{\preTableAndFigHook{table}} -\AtBeginEnvironment{figure}{\preTableAndFigHook{figure}} - - -\newcommand{\newsection}{ - \newpage - \newsectionNoPB -} diff --git a/src/style/environments.sty b/src/style/environments.sty new file mode 100644 index 0000000..28baab2 --- /dev/null +++ b/src/style/environments.sty @@ -0,0 +1,16 @@ +% ── Inline environments ───────────────────────────────────────────── +\newcommand{\inline}[2][NONAME]{% + \ifthenelse{\equal{NONAME}{#1}}{% + \anonymousInlineDescriptorTemplate{#2}{\printLabel{#2}}% + }{% + \inlineDescriptorTemplate{#2}{\printLabel{#2}}{#1}% + } +} + +\newcommand{\short}[2][NONAME]{% + \ifthenelse{\equal{NONAME}{#1}}{% + \anonymousShortDescriptorTemplate{#2}{\printLabel{#2}}% + }{% + \shortDescriptorTemplate{#2}{\printLabel{#2}}{#1}% + } +} diff --git a/src/style/common-tcb.sty b/src/style/tcb.sty similarity index 100% rename from src/style/common-tcb.sty rename to src/style/tcb.sty