diff --git a/docs/docs.pdf b/docs/docs.pdf index a1231b0..acff65a 100644 Binary files a/docs/docs.pdf and b/docs/docs.pdf differ diff --git a/docs/parts/reference/style/descriptors.tex b/docs/parts/reference/style/descriptors.tex index 1ea9986..e692284 100644 --- a/docs/parts/reference/style/descriptors.tex +++ b/docs/parts/reference/style/descriptors.tex @@ -66,9 +66,21 @@ See \ref{sec:counters} for a guide on how to change the current number. \label{sec:counters} \textit{Included in \texttt{most} and up} +\textit{Starting from the version of October 18, 2025, the counter numbers need to be $<$number$>$ - 1} + You may set the current number for the elements by setting their corresponding counter to the selected number. You can do this using \verb|\setcounter|\{\textit{name of the counter}\}\{\textit{number}\}, where you replace \textit{name of the counter} with one of the following: \texttt{definitions}, \texttt{lemmas}, \texttt{theorems}, \texttt{corollaries}, \texttt{propositions}, \texttt{facts}, \texttt{axioms}, \texttt{examples}, \texttt{remarks} This only applies if you have set numberingConfig to $1$ (for all of them) and $2$ (only for \texttt{definitions}). To change the combined numbering, set \texttt{all} to your desired number. + + +\subsubsection{Referencing counters} +\textit{Included in \texttt{most} and up} + +If you wish to reference a counter, you can do so by writing + +\verb|\ref{:
---}|, + +or of course, if you do not label subsections and / or subsubsection, dropping them. diff --git a/docs/parts/reference/style/tcolorbox/counter.tex b/docs/parts/reference/style/tcolorbox/counter.tex index 376c226..590f37e 100644 --- a/docs/parts/reference/style/tcolorbox/counter.tex +++ b/docs/parts/reference/style/tcolorbox/counter.tex @@ -3,7 +3,7 @@ These ones also have two settings, namely, you can change the counter behaviour and the inclusion of subsections in the numbering. See \ref{sec:perFileConf}. -See \ref{sec:counters} for a guide on how to change the current number. +See \ref{sec:counters} for a guide on how to change the current number and how to reference them. \begin{definition}[]{Title here} \begin{minted}{latex} diff --git a/docs/parts/troubleshooting.tex b/docs/parts/troubleshooting.tex index cba1102..06c9eb5 100644 --- a/docs/parts/troubleshooting.tex +++ b/docs/parts/troubleshooting.tex @@ -13,6 +13,10 @@ You have most likely forgotten about the second argument. Then, the first letter \subsection{pgfkeys: Don't know mainboxstyle} You have most likely forgotten about \verb|\usetcolorboxes| after \verb|\startDocument|. +\subsection{Numbering incorrect after numberingOn} +Check the start of the document and make sure you have used \verb|\setNumberingStyle| to set the numbering style and not +\verb|\setcounter{numberingConfig}| + \subsection{Undefined commands} diff --git a/main/style/counters.tex b/main/style/counters.tex index a44ff9d..c0ad602 100644 --- a/main/style/counters.tex +++ b/main/style/counters.tex @@ -7,57 +7,100 @@ \usepackage{xstring} % tcolorbox and other stylistic elements (i.e. inline versions of them) that have counters -\newcounter{lemmas} -\newcounter{definitions} -\newcounter{corollaries} -\newcounter{theorems} -\newcounter{axioms} -\newcounter{examples} -\newcounter{facts} -\newcounter{propositions} -\newcounter{formulas} -\newcounter{remarks} -\newcounter{all} +\newcounter{lemmas}[section] +\newcounter{definitions}[section] +\newcounter{corollaries}[section] +\newcounter{theorems}[section] +\newcounter{axioms}[section] +\newcounter{examples}[section] +\newcounter{facts}[section] +\newcounter{propositions}[section] +\newcounter{formulas}[section] +\newcounter{remarks}[section] +\newcounter{all}[section] % ┌ ┐ -% │ Numbering of sections │ +% │ Counter numbering │ % └ ┘ -\newcommand{\subsectionRendering}[1]{% +\newcommand{\setSubsectionRendering}{ + \renewcommand{\thelemmas}{\sectionNumbering.\arabic{lemmas}} + \renewcommand{\thedefinitions}{\sectionNumbering.\arabic{definitions}} + \renewcommand{\thecorollaries}{\sectionNumbering.\arabic{corollaries}} + \renewcommand{\thetheorems}{\sectionNumbering.\arabic{theorems}} + \renewcommand{\theaxioms}{\sectionNumbering.\arabic{axioms}} + \renewcommand{\theexamples}{\sectionNumbering.\arabic{examples}} + \renewcommand{\thefacts}{\sectionNumbering.\arabic{facts}} + \renewcommand{\thepropositions}{\sectionNumbering.\arabic{propositions}} + \renewcommand{\theformulas}{\sectionNumbering.\arabic{formulas}} + \renewcommand{\theremarks}{\sectionNumbering.\arabic{remarks}} + \renewcommand{\theall}{\sectionNumbering.\arabic{all}} +} + +% ── Picks the correct subsection numbering ────────────────────────── +\newcommand{\sectionNumbering}{% \ifnum\value{numberSubsections}=1 - \arabic{section}#1\arabic{subsection}% + \thesubsection \else \ifnum\value{numberSubsections}=2 - \arabic{section}#1\arabic{subsection}#1\arabic{subsubsection}% + \thesubsubsection + \else + \thesection + \fi + \fi +} +\setSubsectionRendering + + +% ── 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}\edef\tempLabel{\genLabel{#1}{\arabic{#1}}}\label{\tempLabel}} +\newcommand{\genLabel}[2]{#1:\labelSectionGeneration-#2} + +% TODO: Add support for subsection counter reset and subsubsection as well +% -> The way is to use a counter for each mode and then concatenate + + +% ┌ ┐ +% │ Number the counters appropriately │ +% └ ┘ +\newcommand{\printcounter}[1]{% + \csname the#1\endcsname +} + \newcommand{\usenumberArabic}[1]{% \ifnum\value{numberingConfig}=1 - \edef\tempLabel{\genLabel{#1}{\arabic{#1}}}\label{\tempLabel} - \subsectionRendering{.}.\arabic{#1}\stepcounter{#1}% + \labelIt{#1} + \printcounter{#1}\stepcounter{#1}% \else \ifnum\value{numberingConfig}=2 \ifthenelse{\equal{#1}{definitions}}{% - \edef\tempLabel{\genLabel{#1}{\arabic{definitions}}}\label{\tempLabel} - \subsectionRendering{.}.\arabic{definitions}\stepcounter{definitions}% + \labelIt{definitions} + \thedefinitions% }{% - \edef\tempLabel{\genLabel{#1}{\arabic{all}}}\label{\tempLabel} - \subsectionRendering{.}.\arabic{all}\stepcounter{all}% + \labelIt{all} + \theall% }% \else \ifnum\value{numberingConfig}=3 - \edef\tempLabel{\genLabel{#1}{\arabic{all}}}\label{\tempLabel} - \subsectionRendering{.}.\arabic{all}\stepcounter{all}% + \labelIt{all} + \theall% \else \relax% \fi \fi \fi} -\newcommand{\genLabel}[2]{#1:\subsectionRendering{-}-#2} % ──────────────────────────────────────────────────────────────────── @@ -77,27 +120,27 @@ \setcounter{numberingConfig}{\value{numberingConfigStore}} } -% Reset definition, lemma, etc counters, add a new page +% ── Reset definition, lemma, etc counters, add a new page ─────────── \newcommand{\newsection}{ \newpage \newsectionNoPB } -% Reset definitions, lemma, etc counters, do not add new page +% ── Reset definitions, lemma, etc counters, do not add new page ───── \newcommand{\newsectionNoPB}{ - \setcounter{lemmas}{1} - \setcounter{definitions}{1} - \setcounter{corollaries}{1} - \setcounter{theorems}{1} - \setcounter{axioms}{1} - \setcounter{examples}{1} - \setcounter{facts}{1} - \setcounter{propositions}{1} - \setcounter{formulas}{1} - \setcounter{remarks}{1} - \setcounter{all}{1} + \setcounter{lemmas}{0} + \setcounter{definitions}{0} + \setcounter{corollaries}{0} + \setcounter{theorems}{0} + \setcounter{axioms}{0} + \setcounter{examples}{0} + \setcounter{facts}{0} + \setcounter{propositions}{0} + \setcounter{formulas}{0} + \setcounter{remarks}{0} + \setcounter{all}{0} } -\newsectionNoPB +\newsectionNoPB % Initializes % ────────────────────────────────────────────────────────────────────