Fixed algorithm numbering

This commit is contained in:
Andreas Tsouchlos 2023-04-09 23:21:29 +02:00
parent 65214feb01
commit 74df3502d1

View File

@ -156,13 +156,13 @@
% %
% defines algorithm counter for chapter-level % defines algorithm counter for chapter-level
\newcounter{nalg} \newcounter{genericAlgorithmCounter}
\let\OldChapter\chapter \let\OldChapter\chapter
\renewcommand{\chapter}{\setcounter{nalg}{1}\OldChapter} \renewcommand{\chapter}{\setcounter{genericAlgorithmCounter}{1}\OldChapter}
%defines appearance of the algorithm counter %defines appearance of the algorithm counter
\renewcommand{\thenalg}{\thechapter .\arabic{nalg}} \renewcommand{\thegenericAlgorithmCounter}{\thechapter .\arabic{genericAlgorithmCounter}}
% defines a new caption label as Algorithm x.y % defines a new caption label as Algorithm x.y
\DeclareCaptionLabelFormat{algocaption}{Algorithm \thenalg} \DeclareCaptionLabelFormat{algocaption}{Algorithm \thegenericAlgorithmCounter}
\lstnewenvironment{genericAlgorithm}[1][] \lstnewenvironment{genericAlgorithm}[1][]
{ {
@ -185,7 +185,7 @@
#1 % This is to add custom settings #1 % This is to add custom settings
} }
} }
{} {\addtocounter{genericAlgorithmCounter}{1}}
% %
% Allows for pausing and resuming the numbering in an lstlisting environment % Allows for pausing and resuming the numbering in an lstlisting environment