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