[Counters] Add flexible table and figure numbering
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
% ·▀▀▀ ▀█▄▀▪ ▀▀▀ ▀▀ █▪ ▀▀▀ ▀▀▀ .▀ ▀
|
||||
|
||||
\usepackage{xstring}
|
||||
\usepackage{etoolbox}
|
||||
% tcolorbox and other stylistic elements (i.e. inline versions of them) that have counters
|
||||
\newcounter{lemma}[section]
|
||||
\newcounter{definition}[section]
|
||||
@@ -69,6 +70,47 @@
|
||||
% ┌ ┐
|
||||
% │ 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
|
||||
@@ -90,6 +132,8 @@
|
||||
\typeout{Numbering as section.number}
|
||||
\fi
|
||||
\fi
|
||||
\applyTableAndFigureNumbering
|
||||
|
||||
\renewcommand{\thelemma}{\sectionNumbering.\arabic{lemma}}
|
||||
\renewcommand{\thedefinition}{\sectionNumbering.\arabic{definition}}
|
||||
\renewcommand{\thecorollary}{\sectionNumbering.\arabic{corollary}}
|
||||
@@ -185,14 +229,17 @@
|
||||
\ifthenelse{\equal{#1}{0}}{}{
|
||||
\setcounter{numberingConfigStore}{#1}
|
||||
}
|
||||
\applyTableAndFigureNumbering
|
||||
}
|
||||
|
||||
% Enable / disable numbering
|
||||
\newcommand{\numberingOff}{
|
||||
\setcounter{numberingConfig}{0}
|
||||
\applyTableAndFigureNumbering
|
||||
}
|
||||
\newcommand{\numberingOn}{
|
||||
\setcounter{numberingConfig}{\value{numberingConfigStore}}
|
||||
\applyTableAndFigureNumbering
|
||||
}
|
||||
|
||||
% ────────────────────────────────────────────────────────────────────
|
||||
@@ -242,6 +289,10 @@
|
||||
\setcounter{formulasss}{0}
|
||||
\setcounter{remarksss}{0}
|
||||
\setcounter{allsss}{0}
|
||||
|
||||
% Tables & Figures
|
||||
\setcounter{table}{0}
|
||||
\setcounter{figure}{0}
|
||||
}
|
||||
\newsectionNoPB % Initializes
|
||||
|
||||
|
||||
Reference in New Issue
Block a user