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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
12 views

How to define a special escape sequence for a listings block which bold italicizes the text it surrounds?

I currently have a listings set up which uses !> and <! as an escape sequence. The main purpose I use this for is to make the text in a listings stand out by bold-italicizing them when writing ...
user41177's user avatar
  • 167
0 votes
0 answers
14 views

Background for Listings with TeX escape, but caption outside

Listings does not play well with backgrounds and included math formulas (using mathescape) - there are white horizontal lines because Listings doesn't know how tall the lines are meant to be. You can ...
Alasdair's user avatar
  • 5,189
2 votes
1 answer
106 views

How to set monofont to Source Code Pro Light

I would like to know how to go about setting the monofont to Source Code Pro Light. With the code given below, the ttfamily gives this result: This is the code that I currently have: \documentclass{...
Joe's user avatar
  • 9,002
0 votes
0 answers
27 views

Integration of a Jupyter Notebook to Beamer [duplicate]

For my teaching efforts, I want to integrate some Jupyter-Notebooks to my Presentation, which is written in LaTeX. These Notebooks contain examples and assignments. And these examples/assignments I ...
Rivas's user avatar
  • 1
0 votes
0 answers
7 views

Custom lstlisting command changed verbatim font size

I've copied a custom lstlisting command that makes it look like Mathematica code. This is that code below: \usepackage{babel} \usepackage{beramono} \usepackage[T1]{fontenc} \usepackage{color} \...
Michael Adrian Javier's user avatar
1 vote
1 answer
22 views

Issues with making lstnumber two-digit with hyperref and tcolorbox

I'm trying to use tcolorbox and make all lstnumbers two digit. It seems like there is an error with hyperref. I've attached a working example below. \documentclass{scrartcl} \usepackage[utf8]{...
user41177's user avatar
  • 167
2 votes
3 answers
74 views

listings package in tex4ht. How to prevent listing code from wrapping long lines

This issue is for tex4ht only. Summary of the current problem I'd like to make the HTML page smaller width (so easier to read) using say max-width:700px; but at the same time, I do not want to have ...
Nasser's user avatar
  • 20.1k
1 vote
0 answers
22 views

Caption alignment issues with lstlistings environment inside lists

The alignment of the caption of the my lstlistings environment for code is not correct when inside lists. The code to generate the image is given in the working example... \documentclass{article} \...
user41177's user avatar
  • 167
0 votes
1 answer
52 views

How can I restyle the listings caption to a tcblistings environment?

I am trying to define a tcblistings environment that should work under the following syntax... \begin{code}{TITLE}{LANG}{CAPTION}{OPTS} code here \end{code} Everything but the language should be ...
user41177's user avatar
  • 167
0 votes
1 answer
33 views

problem with the trasposition symbol '

I'm new to latex and I should do an assignment with some matlab code. I wrote the latex file but when I make it into pdf there's a problem with the symbol ' which is the symbol of trasposition in ...
federica's user avatar
-2 votes
0 answers
38 views

Why does minted struggle so much with line breaks and page breaks, and not listings?

I have been trying both listings and minted to have a proper coloring of my code files in my document. The result spans over multiple page. I like to have at least a really light background just so ...
Diamondemon's user avatar
0 votes
0 answers
34 views

"Issue with Line Breaks in URLs within lstlisting Environment

The line breaks within lstlisting environments do not function properly for URLs, even though breaklines and breakatwhitespace are both set to true. The URLs are not being broken, and the text exceeds ...
anas's user avatar
  • 1
-1 votes
1 answer
46 views

Listing error on overleaf [closed]

I have copied below code in my source file. Code does not appear in proper format(as it is). All text mix up (without any gap). No caption at the bottom. Getting error message "environment ...
pian ke's user avatar
3 votes
1 answer
33 views

How do I cross reference an equation in lstlisting?

Suppose we have the following code: \documentclass[reqno]{amsart} \usepackage{geometry} \geometry{margin=2in,top=3cm} \usepackage{microtype} \usepackage{listings} \usepackage{hyperref} \begin{...
Arbuja's user avatar
  • 209
0 votes
0 answers
22 views

How to load keywords from two languages in lstlisting? [duplicate]

I know how to define two different styles for two different languages in lstlisting package. I want to include keywords from Lua as well as LaTeX in the same style. Is it possible? \lstdefinestyle{...
user61681's user avatar
  • 1,729
0 votes
0 answers
18 views

lstlisting: Configuring it to support Julia type code

I was writing my report, which uses notations from Julia, specifically Catlab.jl. This contains a lot of category theory related symbols. I read the documentation for lstlisting and it does not ...
Nikit's user avatar
  • 1
0 votes
0 answers
23 views

Prevent LaTeX listings from line breaking before comas and dots

I have a PostgreSQL script that I insert in article using the listings package and I constantly run into two problems trying to format the style of the code: Line breaks before dots and comas or ...
Tristan Benoit's user avatar
0 votes
0 answers
13 views

latexdiff produces non-compilable file in presence of \lstMakeShortInline

I'm using latexdiff on a file that uses the listings package, and more specifically its lstMakeShortInline macro, that allows writing inline code in a concise way. If I start with the following orig....
Virgile's user avatar
  • 235
1 vote
0 answers
41 views

Wrapping inserted code from MATLAB

I am attempting to insert a very long code that I wrote in MATLAB into my thesis document written on Overleaf. Several of the lines have long equations or comments that extend beyond the page and I ...
Jah's user avatar
  • 11
0 votes
2 answers
91 views

How to fix spacing after multicols with lstlisting?

When combining lstlisting with multicols inside a minipage or tcolorbox, the vertical spacing of lstlisting changes. The spacing on top can be fixed by using \topskip = 0pt (see this answer with a ...
Sam's user avatar
  • 168
0 votes
0 answers
36 views

How to get the specific line on LATEX to show properly for copy and pasting?

How can I show this line properly for my Latex document? I am trying to put in code statements but when I try to copy from LATEX and post in the terminal, it does not paste the whole line. The code ...
NevMthw's user avatar
1 vote
0 answers
24 views

How to set program outcomes like listings and algorithms

I have the following settings for the listing package and need to print program outcomes in the same manner, but with its own numbering and removing "Listing" in a caption), i.e., "...
vua72's user avatar
  • 11
1 vote
1 answer
37 views

Using lstinputlisting with tex4ht hides all ASCII characters in the caption?

I'm using tex4ht to build my LaTex source to EPUB. Currently I'm having problems with lstinputlisting, where the caption (in Vietnamese) isn't showing up correctly. \lstinputlisting[float,language=C++,...
Giang's user avatar
  • 13
0 votes
0 answers
20 views

How to print quotation mark glyphs inside the verbatim, minted, listings & texttt?

Assuming the desired quotation marks in the code are called glyphs, how to print the left & the right quotes as desired, as it's printed in `monster' inside the verbatim, minted, listings ...
Lars Malmsteen's user avatar
3 votes
1 answer
255 views

Does lstlisting support Rust?

When I define the Rust language in TeX Live 2023’s lstlisting like this: \begin{lstlisting}[language=Rust] let config_redis_string: String = env::var("REDIS_URL").expect("redis url ...
Dolphin's user avatar
  • 581
1 vote
1 answer
52 views

Cannot List documentclass Using the Listings Package

I'm using XeLaTeX and Overleaf as my editor. I want to use the listings package to list my LaTeX codes. I can properly list most normal codes using the my style below, but when I try to list some ...
E. Huang's user avatar
  • 201
2 votes
0 answers
51 views

Argument of � has an extra } error from listings + hyperref

I'm merging two previously working documents and came across this error (several instances of it, actually). I've reduced it into the following MWE, and it seems to be caused by some interaction ...
bruno cuconato's user avatar
1 vote
1 answer
38 views

color of string in lstdefinelanguage

I have a latex document like this, where I define my own lstlsting language: \documentclass{article} \usepackage{listings} \usepackage{xcolor} \definecolor{backcolour}{rgb}{0.95,0.95,0.92} \...
Maarten-vd-Sande's user avatar
0 votes
2 answers
57 views

How to mix markup for straight apostrophes and accented letters in a lstlisting environment?

I have a document, formatted with luatex, beginning \documentclass[b4paper]{article} \usepackage{expl3} \usepackage{hyperref} \usepackage{listings} %Requires luatex engine to handle UTF-8 ...
shmuel's user avatar
  • 1,367
0 votes
0 answers
16 views

Caption not Wrapping according to column width in lstlisting

I'm trying to wrap the caption text according to the column width. Here is the lstset \lstset{ basicstyle=\scriptsize\ttfamily, breaklines=true, %backgroundcolor=\color{grey}, frame=...
hkny's user avatar
  • 1
8 votes
1 answer
121 views

Creating a `regex` language for listings

A coworker is currently writing a long document with a focus on regular expressions. We would like to be able to format the regular expressions as a listings language, with syntax highlighting and ...
olirwin's user avatar
  • 295
0 votes
0 answers
34 views

How can I make an \if conditional reusable?

This is related to a previous question of mine, how to use listings in conditionals. I'm using the answer kindly provided there to include different code snippets when their library of origin is ...
serval's user avatar
  • 97
2 votes
1 answer
54 views

How can I use listings in conditionals?

I have a library that contains code snippets formatted with the listings package. This library is used in two different documents, with slight variations depending on the document. I've been using ...
serval's user avatar
  • 97
1 vote
2 answers
32 views

Undefined control sequence. \begin{lstlisting} when using custom cls file

when I compile this document in texstudio using xelatex: \documentclass{dolphinbook} \usepackage{xeCJK} \usepackage{subfiles} \usepackage{listings} \usepackage[bookmarksopen,bookmarksdepth=4]{...
Dolphin's user avatar
  • 581
2 votes
0 answers
29 views

Set Python's decorators in some colour but keep @ as an operator unchanged

I am using listings for code formatting and colouring in a document I'm working on, including a lot of Python code. I would like for decorators to be displayed in a specific colour but for the @ ...
Bermudes's user avatar
  • 121
0 votes
0 answers
17 views

Custom font size for listing [duplicate]

I have a listing as follows: \begin{lstlisting}[basicstyle=\scriptsize] ... \end{lstlisting} The listing is quite long (71 lines + caption), and I want it to fit on a single page. However, I ...
bys1's user avatar
  • 1
0 votes
0 answers
12 views

Confused by minted failures - line numbers not pointing to error

I'm making a book using minted but I spend (too much) time debugging minted issues. For example, this sample fails to build for me. I get the following error: % rubber --module xelatex --shell-escape ...
Matt Harrison's user avatar
1 vote
1 answer
30 views

\lstnewenvironment does not work with \minipage

I am writing a document with loads of code snippets, and page breaks make it hard to read. I would like to prevent those if possible. I saw in Avoid page breaks in \lstlistings that one of the ...
Aisteru Firë's user avatar
0 votes
1 answer
25 views

How do I change the formatting of listing captions to follow the structure of figure/table captions?

I need to add a lot of listing environments to a report, and I want to have the numbering of the listing captions to follow the same structure as the captions of figures or tables (eg Listing 1.1, ...
simong's user avatar
  • 3
0 votes
1 answer
45 views

Error between microtype, hyperref, and listings when setting oldstylenums for listings

I am using the listings package for displaying source code, and want to reformat the numbering to use the oldstylenums. The problem comes when using microtype, as it throws errors for every line of ...
asbjos's user avatar
  • 23
0 votes
1 answer
40 views

Justify text lstlisting

I would like to justify text in lstlisting. If the line gets too long, there doesn't seem to be any way to automatically add a new line. Is there a way to justify text?
Dunno's user avatar
  • 317
0 votes
0 answers
32 views

In lstlisting, how to forbid the upper/lower frame bars on another page?

Running pdflatex on \documentclass{article} \usepackage{listings} \begin{document} \vspace*{121ex}% writing 122ex instead of 121ex leads to breaking just after the upper bar. \begin{lstlisting}[frame=...
AlMa0's user avatar
  • 439
0 votes
0 answers
18 views

Help with code presentation in a particular format

How can I place the code into the format shown in the picture ? \usepackage{xcolor} \usepackage{caption} \lstset{ language=csh, basicstyle=\footnotesize\ttfamily, numbers=left, ...
khaled guizani's user avatar
0 votes
0 answers
22 views

Listings XML highlighting problems - values between tags

I'm using a custom style to get syntax highlighting for XML in Listings from this thread but I'm having issues in regards to values between tags getting wrongly targeted. The styling I have is \...
Zaxvert's user avatar
0 votes
1 answer
19 views

The listings package is rendering an empty frame

The markup \documentclass[draft]{article} \usepackage{fontspec} \usepackage{hyperref} \usepackage{listings} \begin{document} \lstset{language=Rexx, extendedchars=true, frame=trbl} \section{Statement ...
shmuel's user avatar
  • 1,367
4 votes
1 answer
243 views

Curly brace with arrows pointing to specific code

I would like to use horizontal brackets within a code environment like in the following example: That's as far as what I have. \documentclass{article} \usepackage{tikz} \usetikzlibrary{arrows.meta} \...
wayne's user avatar
  • 601
0 votes
1 answer
39 views

breakline is not working for lstlisting package while none option in hyphenat package used

The below code is the tex file content, which has listings package. \documentclass[12pt,a4paper]{report} \usepackage{hyperref} \usepackage[english]{babel} \usepackage{xcolor} \usepackage{listings} % ...
Nandy's user avatar
  • 33
0 votes
1 answer
36 views

Use arrows to point to specific blocks of code and assign background colors to keywords

How do I get background colors assigned to certain words and punctuation marks? I want it like in the following picture: Here is my code: \documentclass[a4paper]{article} \usepackage{tikz} \...
wayne's user avatar
  • 601
0 votes
0 answers
31 views

Define a dialect and change default dialect

\documentclass{article} \usepackage{listings} \lstdefinelanguage[3]{Python}[]{Python}{morekeywords={yield,goto}} \lstset{ defaultdialect=[3]Python % Line A } \begin{document} \begin{lstlisting}[...
Gqqnbig's user avatar
  • 482
0 votes
0 answers
20 views

How can minted (or something similar) work with automatic alignment of code? [duplicate]

I typeset Lisp code in a proportional typeface, and it relies on alignment. An example of the typesetting can be seen here: If I ignore font selection, it was typeset using this code: \begin{tabbing} ...
matj1's user avatar
  • 109

1
2 3 4 5
70