Questions tagged [listings]
{listings} is a package that extends LaTeX's {verbatim} features. A variety of syntax highlighting options are available. For general questions about {verbatim} or {highlighting} use the respective tag. For the unrelated concept of list structures, use {lists} instead.
3,764 questions
0
votes
1
answer
50
views
Why does LaTeX suppress the numbering of my `lstlisting` environment when it spans more than one page?
I am using the listings package to display code in my document, configured as follows:
\documentclass[12pt,letterpaper,twoside]{book}
\usepackage{listings}
\usepackage{inconsolata}
\usepackage{xcolor}
...
0
votes
1
answer
67
views
How can I define a custom listings language for MusicBrainz Picard scripts that matches the editor’s syntax highlighting
I’m trying to define a custom language in LaTeX using \lstdefinelanguage so that keywords and variables in MusicBrainz Picard scripts are highlighted similarly to Picard’s built-in script editor (see ...
4
votes
1
answer
74
views
How to reproduce `listings` style features (right-side numbers, stepnumber) in `piton`?
In the listings package,
\lstset{numbers=right,stepnumber=3,numberfirstline}
gives right-aligned line numbers and numbering every third line.
I would like to achieve the same behavior using the piton ...
3
votes
1
answer
102
views
Enlarging rendered PDF in comment box
I've been looking for ways to exhibit exhaustive listings (for replicability) alongside cropped output. Here are the two solutions I've come up with. For the second, I'm unable to stretch the PDF to ...
1
vote
1
answer
26
views
Remove indent from escapeinside in listings
The following minimal working example latex shows a multi line latex macro running inside a listings environment:
\documentclass{article}
\usepackage{listings}
\lstset{
breaklines=true,
...
6
votes
0
answers
96
views
Hyphenation in slash constructions not working anymore
With the recent updates of the babel and the listings packages (for me that meant babel 25.14 --> 25.16 and listings 1.10c --> 1.11b), I encountered a change in the hyphenation behavior in my ...
1
vote
1
answer
115
views
Understanding and avoiding tagpdf warning caused by floating lstlisting environment
I started experimenting tagging and found that listings are a problem:
Compiling
\DocumentMetadata{lang=en-US,tagging=on,pdfversion=2.0,pdfstandard=a-4f}
\documentclass{article}
\usepackage{unicode-...
8
votes
2
answers
225
views
Randomize an enumerate list containing lstlisting
I would like to create a randomized enumerate list whose items may contain lstlisting environments. So far, I can successfully randomize ordinary items, but items containing a lstlisting environment ...
1
vote
0
answers
61
views
Help display code using lstlistings - getting tagpdf error in lualatex
I am trying to use listings package to show some code. I am compiling it with lualatex to get a tagged document.
Here is the minimal working example:
\DocumentMetadata{lang=en-UK,
tagging=on,
...
0
votes
0
answers
32
views
listings: `lstlisting` environment doesn't work when it's in the input to a macro
I have a macro that I'm using to format text in answer key different from the rest of the document. When my answers include the lstlisting environment, the macro fails, as in the following MWE:
\...
6
votes
1
answer
254
views
Number sign/hash (#) not allowed in environment defined with listings
The number sign ("#") raises an error in an environment defined with \lstnewenvironment of listings package. This is possibly related to the recent changes in LaTeX2e kernel ( 2025-11-01) ...
4
votes
0
answers
166
views
Listings - How to define a custom listings style using \lstdefinestyle to colour nested parentheses differently without using \lstdefinelanguage?
Let's assume, I have nested parentheses like shown in the picture:
I want to define a custom code style using the listings package and \lstdefinestyle command to highlight nested parentheses with ...
0
votes
1
answer
54
views
listings with zi4 narrow (inconsolata)
I am using the listings package and I would like to use zi4 narrow as font.
The font is loaded and I can use it with \texttt{} but in the lstlistings environement I have zi4 font but not narrow.
Is ...
1
vote
2
answers
90
views
How to make the code connected to the previous page
I am inserting a code sample, and It goes in to pages, I hope them to connect, not be divided by two figures.
\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts
% The preceding line is ...
10
votes
3
answers
515
views
What changed between the final TeXLive 2023 and the final TeXLive 2024 concerning an lstlisting inside a TikZ node?
Feeding
\documentclass{article}
\usepackage{listings}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node {%
\begin{lstlisting}
foo
\end{lstlisting}};
\end{tikzpicture}
\end{document}
to ...