Sujet : Re: label on the left side of minted or listings
De : peter (at) *nospam* silmaril.ie (Peter Flynn)
Groupes : comp.text.texDate : 03. Mar 2025, 22:45:32
Autres entêtes
Organisation : Usenet Labs Bozon Detector Facility
Message-ID : <m2mm7sF6iifU2@mid.individual.net>
References : 1
User-Agent : Mozilla Thunderbird
On 03/03/2025 04:03, Jinsong Zhao wrote:
Hi there,
Hi there,
I am typesetting code using minted or listings package. It works fine. Now I am hoping to add a label, similar to equation label, on the left side of the code block, looks like following. (%o1) is the label.
(%o1) code here here here
code here here
code here
code
However, I can't find a way to do this. Any hint will be appreciated.
I would think the simplest is to put the code listing in a list item, eg
\usepackage{enumitem,listings}
...
\begin{enumerate}[label={(\%ol)}]
\item \begin{lstlisting}
foo
bar
\end{lstlisting}
\end{enumerate}
That way (enumitem) you have good control over the label and the spacing.
Peter