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
34 views

\lstnewenvironment does not work

In the following codes, I try to make my lstlisting environment(named drenv) by \lstnewenvironment. It fails to pass compilation. I'd like to know why and how to make it work. code: \documentclass{...
lyl's user avatar
  • 2,667
0 votes
1 answer
118 views

Environment with lstlisting inside

Leaning from Macro with lstlisting inside, I construct my environment drenv with lstlisting inside. But it doesn't work. How to improve my code to make it work? Code: \documentclass{article} \...
lyl's user avatar
  • 2,667
0 votes
1 answer
40 views

Align three code blocks in different orientations

The above image is what I can generate with - \begin{figure*} \begin{subfigure}[b]{0.3\textwidth} \begin{lstlisting}[language=Java] ...java code... \end{lstlisting} \caption{Java source code that ...
Pratyush Das's user avatar
0 votes
1 answer
26 views

package 'caption' not adjusting captions from the 'listing' environment in 'minted'

It appears that package caption is not able to adjust the captions in listings from minted. In the example below, the captions for figure and table environments are affected by \captionsetup but ...
user32882's user avatar
  • 1,564
2 votes
1 answer
64 views

package mlmodern with lualatex changes single quote in listings to backquote. How to fix this? [duplicate]

I like to use \usepackage{mlmodern} but I noticed it changes ' in listings. Is there to tell it not to do this? I use lualatex. Here is MWE \documentclass[12pt]{article} \usepackage[T1]{fontenc} \...
Nasser's user avatar
  • 19.7k
3 votes
1 answer
75 views

Using a regular expression within listings : Incomplete \iffalse

I have used this pattern (found on this site) many times to animate listings in beamer. Unfortunately, it does not work anymore. This code comes from a solution to this issue : listings: highlight ...
Julien's user avatar
  • 31
0 votes
0 answers
54 views

Prevent listings from breaking pages in a more elegant way (pandoc/latex)?

I basically, I have a bunch of markdown files on my website. Whenever I add/update an entry, I have a script that builds a nice little PDF combining all these files.This works great, except that the ...
Yochai Gal's user avatar
1 vote
1 answer
49 views

Problem about wrapping lstlisting environment into another environment with etoolbox

In the following MWE, I tried to wrap an lstlisting environment(testlst) into another environment(test) by the pairs of macros \BeforeBeginEnvironment and \AfterEndEnvironment that come from the ...
lyl's user avatar
  • 2,667
0 votes
0 answers
24 views

Making listings package print a \newpage mid-import

I have a c++ source file that I am importing to Latex using the Listings package. I found an obscure mention of using formfeed to create a newpage mid-import. What I want to do: Shift the comment ...
Rahul Silva's user avatar
0 votes
1 answer
113 views

\setminted and \setmintedinline commands interfere with each other?

I'm trying to use the package minted to generate documents which contain language-agnostic inline code and language-aware block code (listing). Here's a minimal working example: \documentclass[a4paper,...
user32882's user avatar
  • 1,564
0 votes
0 answers
146 views

How do I reduce line spacing in listing using `\inputminted` command?

I use for listings minted package, and can reduce line spacing in case of using minted environment. But can't reduce listing line space in case of using external source code file via \inputminted ...
Konstantin's user avatar
0 votes
1 answer
112 views

Incorrect classification of multiple listings entries

My problem is as follows: I have 3 different listings environments namely List of Matlab Outputs, List of Matlab Code and List of Pseudocodes. However all listings are under List of Matlab Outputs ...
itc's user avatar
  • 602
2 votes
1 answer
46 views

Listings: indent to specific tab position after math mode

I'm having difficulty formatting code listings with embedded math, using lstlisting with mathescape=true. In particular I'm finding it difficult to lay out code using indentation when there is math to ...
Roly's user avatar
  • 4,080
1 vote
1 answer
53 views

How to skip newtcblisting from numbering if no title is provided

I have a custom newtcblisting defined, with an optional title. I would like to keep on the \lstlistoflistings only the ones with titles on it (this also affects numbering). Also, i have that unwanted ...
julianferres's user avatar
0 votes
0 answers
49 views

How to use listings with catchfilebetweentags?

Question When inserting a listing with the catchfilebetweentags package, I get the error job aborted, no legal \end found. How do I make these packages work together? If I can't, are there viable ...
cero's user avatar
  • 221
2 votes
1 answer
116 views

Typesetting batch files via listings in Overleaf project

The goal: I'm trying to make a project. I have a program which is compiled and executed by batch script (Windows Batch File). There are several of those. The problem: I would like to have them listed ...
janki3l's user avatar
  • 21
0 votes
0 answers
31 views

Dashed line on lstlisting page break

After looking at Horizontal dashed line on page break in listings environment (adding dashed line in pagebreak during listing) I couldn't manage to add the intended frame and at the same time having ...
julianferres's user avatar
0 votes
0 answers
18 views

Spacing Heading Listings

Could someone tell me how I can reduce the distance between the heading and the first entry in the source code directory? Strangely enough, the spacing is larger than for the list of figures. I use ...
user273388's user avatar
0 votes
0 answers
37 views

Listings package: What do the "morestring" style designators mean?

I am familiarizing myself with the listing package's morestring command. The manual describes this on page 47. The command requires a style parameter consisting of b, d, m, bd, or s. I cannot find ...
user2153235's user avatar
0 votes
0 answers
98 views

lstlisting color formatting constructor of a class (C++ style code)

I'm trying to color format the constructor of a class, so that the color of the class name, which has the same name as the class function (constructor) is different to the color of the class function (...
Thilo's user avatar
  • 101
0 votes
1 answer
53 views

Usage lstinline in longtable

I'd like to format special words within a table with monospace font formatting. I thought would work was the usage \lstinline{code}. Although, this seems not work within a table as the compiler fails. ...
Remo's user avatar
  • 159
0 votes
1 answer
73 views

Missing $ insert in \lstlistoflistings because of caption with underscore

I add code using this command \newcommand*{\addcode}[2]{ \lstinputlisting[caption={#1, (\detokenize{#2}.ml)}]{code/#2.ml} } Some of my .ml files contains underscores like Two_Opt.ml. So when I ...
Butanium's user avatar
  • 151
1 vote
0 answers
68 views

Very slow compilation when biolinum, tcolorbox's listings library, and multiple listings' dialects involved

The compilation of the following MCE is very slow: about 14 second on my “normal” computer. (Of course, my real use case does load different dialects, not the same one several times.) \documentclass{...
Denis Bitouzé's user avatar
0 votes
1 answer
34 views

Why (listings) ⟨language⟩s' ⟨dialect⟩s are taken in account with \lstset{alsolanguage=...} but not with \lstloadlanguages{...}?

A (listings) ⟨language⟩'s ⟨dialect⟩ is taken in account: with \lstset{alsolanguage=[⟨dialect⟩]⟨language⟩}, but not with \lstloadlanguages{[⟨dialect⟩]⟨language⟩}. This is shown by the following MCE ...
Denis Bitouzé's user avatar
2 votes
1 answer
79 views

listings Undefined control sequence \@dottedtocline #1#2#3->\scr@dottedtocline

I'm trying to use the 'listings' package for my project work in LaTex. This is my stripped down code for illustration: \documentclass[a4paper, 12pt, BCOR5mm, captions=tableheading, pointlessnumbers, ...
Zeus's user avatar
  • 23
0 votes
1 answer
126 views

How to change color in lstlisting (LaTeX) if the first symbol is $?

By formatting command-line snippets with LaTeX lstlisting, I want to separate input commands from their outputs as follows: In the command-line snippet: $date Sat Jun 1 14:31:01 CEST 2019 $date has ...
Dr. Andrey Belkin's user avatar
0 votes
0 answers
136 views

Adding Vertical Lines for Indents with lstlisting (or other package)

I have some code that is formatted with the lstlistings package in LaTeX, which looks like: However, when putting in longer code it can be difficult (especially on page breaks) to know how far ...
Frederik's user avatar
  • 103
0 votes
0 answers
23 views

LaTeX listing draws weird horizontal lines [duplicate]

I use this code to format my code snippets: \definecolor{white}{cmyk}{0,0,0,0} \definecolor{darkgrey}{cmyk}{0,0,0,0.97} \definecolor{green}{cmyk}{0.6,0,0.84,0} \definecolor{blue}{cmyk}{0....
vhd17627's user avatar
0 votes
0 answers
28 views

Customize lst index list list of listings

I would like to see if there is a way to make the same format like this to show figures but for lst listings. I would like to have something like: CODE 1. CODE 1 CODE 2. CODE 2 That is to say, add ...
user271863's user avatar
0 votes
0 answers
75 views

Replicate eclipse screen for java code

Hi there is a method to replicate the eclipse screen with keyword colors for a java code like this I tried this but it doesn't work \documentclass[a4paper, 11pt]{article} \usepackage{geometry} ...
SimoPape's user avatar
1 vote
2 answers
83 views

listings does not ignore comment character inside a string

I'm trying to insert a matlab code file in my tex document using listings but the output is messy because I'm using % inside a string with fprintf which is also a comment character. In the line ...
Midouj's user avatar
  • 21
-1 votes
1 answer
100 views

Error with `listings` and `tabularray` used together

I'm in the process of replacing tabular and array environments with tblr in some of my documents. It's already done for dozens of them, with no problem. But I hit a bump with the following MWE: \...
Miyase's user avatar
  • 2,388
1 vote
1 answer
37 views

tex4ht does not see listings style using \lstinputlisting[style=style_name]{file}

I am using the code from how to make tex4ht work with listings styles for only basic decoration? (frame and background coloring)? thanks to Michal.h2 which works great except that the style defined ...
Nasser's user avatar
  • 19.7k
1 vote
1 answer
141 views

lstlisting stops file from compiling

I'm writing a Latex file. But when I try to add the following code to the file, it just can't compile anymore: \begin{lstlisting}[language=bash,caption={bash version}] btcd --txindex --simnet --...
AidenFive's user avatar
1 vote
1 answer
41 views

Only highlight keyword if surrounded by whitespace

I defined a language as follows: \lstdefinelanguage{Z80}{ sensitive = true, keywords={a, hl, h, l, b, c, e, ix, sp, bc, af, d}, keywords = [2]{push, ld, and, pop, ret, sra, call, sla, cp, jp, ...
choreley's user avatar
1 vote
1 answer
66 views

Space before the "?", normally unbreakable with babel-french, breakable with listings' breaklines option

With babel-french, the space before the question mark is normally unbreakable. But, as shown by the MWE below (compiled with pdflatex, xelatex or lualatex), the breaklines option of the listings ...
Denis Bitouzé's user avatar
1 vote
1 answer
44 views

How to use two styles for the same listings language?

At the moment I have two global options defined for my listings language: color and monochrome (I have bundled the language as a package and so these are package options). However, now I find that I ...
IIM's user avatar
  • 289
0 votes
0 answers
51 views

autoref figure labels in tufte-book

This seems to be an issue with tufte-book figure labeling but I'm not sure whether it's something I can work around. \documentclass{tufte-book} \usepackage{listings}\lstloadlanguages{C} \usepackage{...
Mario Carneiro's user avatar
0 votes
1 answer
63 views

How can I remove extra white space of a caption when listing wrap inside a figure?

I want to wrap listing inside a figure. But when I do that there is plent white space in between its caption. How can I remove extra white space of Figure's caption when listing wrap inside a figure? ...
alper's user avatar
  • 1,256
0 votes
0 answers
38 views

nested use of listing options

The following code which is built by the lstlisting environment from the package listings, in my view, should typeset the text "aaa" with color red, but the real typeset remains black. I ...
lyl's user avatar
  • 2,667
0 votes
1 answer
130 views

Syntax highlighting of numeric literals with the listings package

I'm working on a document that contains a lot of python code snippets, many of which have numeric literals in them. For example, something like: var_a = 3 var_b = 20000 var_c = 1.75e12 var_d = 0.1415 ...
realityChemist's user avatar
1 vote
1 answer
188 views

Blank space after equal-sign in Python-Code-Section of LaTeX-Dokument-PDF by using packages "listings" and "pythonhighlight"

Does anybody know how to set the packages "listings" and "pythonhighlight" for displaying one blank space before (this already works) and after an "=" (and maybe other ...
DieTho's user avatar
  • 13
1 vote
0 answers
56 views

<replace> of “literate” option still on in tcblisting environment of tcolorbox

I set @ and | as <replace> of the literate option(from the package listings), and use it in tcblisting(from tocolorbox). They work all right except that in the text part of tcblisting, @ and | ...
lyl's user avatar
  • 2,667
2 votes
0 answers
79 views

Changing the color of numbers and special words in listings for a Python snippet

I'm using the listings package to write a report where I report some code in Python that I used. I am not very familiar with listings and am having several problems. Specifically: I would like to ...
Gianni Spear's user avatar
1 vote
1 answer
64 views

listings lstdefinestyle not work with custom defined command

I defined a new command named '\showLineNo', and used in '\lstdefinestyle', got an error: Package Listings Error: Numbers none unknown. \lstset{style=customstyleone} sample code: \documentclass{...
Art Journey's user avatar
1 vote
2 answers
228 views

How to render a long code listing in multiple pages with the package minted?

I'm using the package minted for formatting code in my paper. The package minted provides a "listing" environment, which treats the code inside it as a float. It works very well under most ...
Nicole Naumann's user avatar
2 votes
1 answer
114 views

Strange Autoref Countering of lstlisting

I made a new listtype called mycodes and want to autoref to them. The problem is, when using autoref to a lstlisting-block the number of the listing is wrong! The code \documentclass[]{article} \...
GURKE's user avatar
  • 65
0 votes
1 answer
699 views

How to write Octave code on LaTeX?

Here is an exemple of code I would like to write: clear all; close all; clc; X = Y = 0:0.1:1; for i=1:length(X) for j=1:length(Y) Z(i, j) = X(i) + Y(j); endfor endfor mesh(Y, X, Z) The ...
Emile Couzin's user avatar
3 votes
2 answers
147 views

Listings Inside Macro

I am trying to figure out a way to have a macro where I demonstrate the output of a command then show the command via a lstinline command. I have read that I need to escape out the special char's (...
Nebabon's user avatar
  • 115
1 vote
1 answer
121 views

KOMA-script list of listings and LOF have unequal space below heading

I observed some unexpected behaviour with scrbook class (xelatex) and the list of listings from the listings package. The spacing between the chapter headings of the LOF and list of listings and the ...
Daniel Stich's user avatar

1 2 3
4
5
72