From 8234f362780b6aabe27a0d59b0afdfa95fa29f4c Mon Sep 17 00:00:00 2001 From: Andreas Tsouchlos Date: Sat, 1 Apr 2023 19:22:16 +0200 Subject: [PATCH] Added command to allow pausing and continuing numbering in listing environments --- latex/thesis/common.tex | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/latex/thesis/common.tex b/latex/thesis/common.tex index 5138244..857c79b 100644 --- a/latex/thesis/common.tex +++ b/latex/thesis/common.tex @@ -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