[Counters] Finish up refs
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
% ────────────────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user