Path: ...!weretis.net!feeder8.news.weretis.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Peter Flynn Newsgroups: comp.text.tex Subject: Re: label on the left side of minted or listings Date: Mon, 3 Mar 2025 21:45:32 +0000 Organization: Usenet Labs Bozon Detector Facility Lines: 30 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: individual.net /BoG2gZ60Ak4R7FTuDI4EQ4vB3oZfjeG+lzhM+qvefECXgi/z5 Cancel-Lock: sha1:XdE//rf+EGx04ozCdnAjkmUkhfg= sha256:uN3jgK0Jk/PJGCIr7OyJtWYKi8AmrKa2rGlzVFH50WU= User-Agent: Mozilla Thunderbird Content-Language: en-US In-Reply-To: Bytes: 1648 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