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
1 vote
0 answers
22 views

Missing Listing number in caption

My problem is that I don't have automatic listing numbers in the caption. (I thought they would be included by default and can't seem to find a way to include them) \begin{lstlisting}[caption={test}, ...
user avatar
  • 11
1 vote
1 answer
19 views

Curly quotes in lstlistings get moved to the start of words

I have a code snippet that uses the unicode character ’ (u2019), also known as right single quotation mark in the middle of a word. Unfortunately, it seems the lstlistings environment causes this ...
user avatar
  • 11
1 vote
1 answer
36 views

How do you automatically wrap text in the \verb||-like environment -- that is, in-line, and without requiring a line break before and after?

This is my first question on any StackExchange site, so please bear with me. I am writing code for a paragraph of normal English with little bits of code spliced in. Initially I wrote something like: ...
user avatar
1 vote
0 answers
36 views

Arabic text in python code in listings at latex

I'm writing python code in my latex file, but it contain some Arabic texts when I write it using listings in python the Arabic words don't appear! \documentclass{article} \usepackage{listings} \begin{...
user avatar
  • 59
1 vote
0 answers
22 views

subscriptcorrection in newtxmath + listings + subscript in literate = 🗲

Feeding \documentclass{article} \usepackage{newtxtext} \usepackage[subscriptcorrection]{newtxmath}% subscriptcorrection not really needed for this minimal example but is helpful in general \usepackage{...
user avatar
  • 1,119
0 votes
1 answer
32 views

Main font of the fontspec package interfering with the escapechar in the listings environment

Output Before Setting Main Font Before setting the main font using the fontspec package, the escapechar was working properly. Below is the output picture: and below is my MWE: \documentclass{memoir} ...
user avatar
  • 311
0 votes
1 answer
27 views

lstlistoflistings for different counters

I'm using the lstlisting environment to show code, ubuntu terminal inputs and outputs. I have them defined as in the code example, using different counters named Code, TerminalIn and TerminalOut. When ...
user avatar
1 vote
0 answers
37 views

Same literate defination causes different behaviour

The code of following two examples has the same literate defination. The literate A! is used to emphasize some code by color and size. The literate !A is used to restore the color. In the first ...
user avatar
  • 2,435
2 votes
2 answers
120 views

Troubles with listings and polish characters (lualatex)

How I can display properly polish characters in code of programming language using listings package and lualatex compiler? main.cpp: //Zażółć gęślą jaźń #include <iostream> int main() { std::...
user avatar
0 votes
0 answers
20 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{...
user avatar
  • 2,435
0 votes
1 answer
40 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} \...
user avatar
  • 2,435
-1 votes
0 answers
50 views

How to draw a figure like the following? [duplicate]

I want to draw figures like the following: Furthermore, I have to add color in a customized way: I am able to build a similar listing using the following snippet: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%...
user avatar
  • 365
0 votes
1 answer
29 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 ...
user avatar
0 votes
1 answer
23 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 ...
user avatar
  • 1,424
2 votes
1 answer
36 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} \...
user avatar
  • 18.4k
3 votes
1 answer
52 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 ...
user avatar
  • 31
0 votes
0 answers
26 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 ...
user avatar
1 vote
1 answer
31 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 ...
user avatar
  • 2,435
0 votes
0 answers
22 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 ...
user avatar
0 votes
1 answer
19 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,...
user avatar
  • 1,424
0 votes
0 answers
19 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 ...
user avatar
0 votes
1 answer
93 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 ...
user avatar
  • 311
2 votes
1 answer
35 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 ...
user avatar
  • 3,896
1 vote
1 answer
26 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 ...
user avatar
0 votes
0 answers
17 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 ...
user avatar
  • 211
1 vote
1 answer
40 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 ...
user avatar
  • 11
0 votes
0 answers
16 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 ...
user avatar
0 votes
0 answers
14 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 ...
user avatar
0 votes
0 answers
18 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 ...
user avatar
0 votes
0 answers
22 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 (...
user avatar
  • 1
0 votes
1 answer
28 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. ...
user avatar
  • 159
0 votes
1 answer
39 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 ...
user avatar
  • 151
1 vote
0 answers
40 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{...
user avatar
0 votes
1 answer
32 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 ...
user avatar
2 votes
1 answer
38 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, ...
user avatar
  • 23
0 votes
1 answer
28 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 ...
user avatar
1 vote
0 answers
28 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 ...
user avatar
  • 111
0 votes
0 answers
22 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....
user avatar
0 votes
0 answers
13 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 ...
user avatar
0 votes
0 answers
36 views

Package inputenc Error: Invalid UTF-8 byte sequence using listings in Overleaf with PHP code

I am writing a document on OverLeaf with blocks of code in PHP that I inserted using lslistings. In the whole document I have 9 errors, always the same one repeated 9 times. The error is: Package ...
user avatar
  • 31
0 votes
0 answers
45 views

How put listing or verb contents inside box within a tikz node

I try to write a command to mimic the tcolorbox to draw a frame and background on some contents in the document. (I know this is probably no sense to do this, why not just use the tcolorbox. I am just ...
user avatar
  • 4,763
0 votes
0 answers
54 views

Copy paste mistakes while listing code

I have noticed that the lstlisting environment produces many errors that must be corrected if you try to copy-paste the code and compile it. Other environments such as minted produces way fewer errors,...
user avatar
  • 1,042
0 votes
0 answers
53 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} ...
user avatar
1 vote
2 answers
40 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 ...
user avatar
  • 21
0 votes
1 answer
52 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: \...
user avatar
  • 1,724
1 vote
1 answer
26 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 ...
user avatar
  • 18.4k
1 vote
1 answer
38 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 --...
user avatar
1 vote
1 answer
31 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, ...
user avatar
1 vote
1 answer
64 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 ...
user avatar
1 vote
1 answer
28 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 ...
user avatar
  • 279

1
2 3 4 5
69