Added command to allow pausing and continuing numbering in listing environments

This commit is contained in:
Andreas Tsouchlos 2023-04-01 19:22:16 +02:00
parent aa57b252bb
commit 8234f36278

View File

@ -163,6 +163,7 @@
\captionsetup{labelformat=algocaption,labelsep=colon}
\lstset{
mathescape=true,
escapeinside=||,
frame=tB,
numbers=left,
numberstyle=\tiny,
@ -178,5 +179,26 @@
}
{}
%
% Allows for pausing and resuming the numbering in an lstlisting environment
% Taken from https://tex.stackexchange.com/q/215697
%
\let\origthelstnumber\thelstnumber
\makeatletter
\newcommand*\Suppressnumber{%
\lst@AddToHook{OnNewLine}{%
\let\thelstnumber\relax%
\advance\c@lstnumber-\@ne\relax%
}%
}
\newcommand*\Reactivatenumber{%
\lst@AddToHook{OnNewLine}{%
\let\thelstnumber\origthelstnumber%
\advance\c@lstnumber\@ne\relax}%
}
\makeatother
% For a way to add custom endings to acronyms see https://tex.stackexchange.com/a/268225