Re: label on the left side of minted or listings

Liste des GroupesRevenir à ct tex 
Sujet : Re: label on the left side of minted or listings
De : peter (at) *nospam* silmaril.ie (Peter Flynn)
Groupes : comp.text.tex
Date : 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

Date Sujet#  Auteur
3 Mar 25 * label on the left side of minted or listings5Jinsong Zhao
3 Mar 25 +* Re: label on the left side of minted or listings2Denis Bitouzé
3 Mar 25 i`- Re: label on the left side of minted or listings1Jinsong Zhao
3 Mar 25 `* Re: label on the left side of minted or listings2Peter Flynn
10 Mar 25  `- Re: label on the left side of minted or listings1Jinsong Zhao

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal