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
0answers
4 views

Highlight numbers (not in-text numbers) in Python using `lstlistings`

The problem: Is it possible to highlight just the - numerical type - numbers when highlighting numbers in lstlistings ? I'm trying to get something like this: What I have tried: I've managed to get ...
2
votes
1answer
21 views

Problem with listing numbering in caption

When I want to put a simple caption to my listing, tex puts the number of the subheading to the listing and not the actual listing number. \begin{lstlisting}[language=Python, caption=Listing 1: ...
1
vote
0answers
24 views

How can color of a default parameter in call, be changed like PyCharm?

I am working on a document that contains some Python codes. I use the following template in Overleaf. \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{listings} \usepackage{xcolor} %...
0
votes
0answers
19 views

Is it possible to use \lstdefinestyle (listings package) whith language=latex inside?

Using this setup: \usepackage[utf8]{inputenc} \usepackage{amsmath} \usepackage{xcolor} \pagecolor[rgb]{0,0,0} %black, you can reset to white setting all values to 1 \color[rgb]{0.8,0.8, 0.8} % set ...
0
votes
1answer
15 views

lstlisting url broken by line wrapping

I have a URL which get's broken by the line break. Ideally I'd like it to be possible to copy the whole wget command and paste it into a terminal. Unfortunately I am ending with an overflowing box and ...
0
votes
0answers
28 views

Listings doesn't highlight everything

I'm having an issue with a custom \listings enviroment: \begin{document} \lstdefinestyle{mystyle}{ backgroundcolor=\color{backcolour}, commentstyle=\color{codegreen}, numberstyle=\tiny\...
1
vote
1answer
18 views

Allow page breaks inside figures

I am currently writing a paper that has lots of code snippets in it, which I would like to treat as figures. Because the examples can be very long it would be convenient to allow page breaks inside of ...
0
votes
0answers
24 views

How to make two different environments next to each other?

I wrote a piece of code in the listing form. Then I want to put its running result graph below this code. But in Latex, although I write them next to each other, sometimes they are distributed on ...
1
vote
1answer
16 views

Use the nomencl and listing packages to include a command summary

I am writing a document related to computer science and I want to include a short summary of the commands that appear through the text at the end. I am using the listing package to handle the code and ...
0
votes
0answers
15 views

Broken dash output in listings (noto font)

I'm trying to use the "noto-sans" font found in the LaTeX Font Catalog, unfortunately each dash (-) produces a tombstone (▯) as output. Here is an MWE: %!TEX program = xelatex \documentclass{...
5
votes
2answers
104 views

Annotate listing with overlays

I'd like to visually divide a listing containing a hex dump into regions and provide a label for them. Here's what I got so far: The code for this uses tcolorbox for the overlays and textpos to make ...
1
vote
2answers
35 views

Why error is coming when using listings in polyglossia package?

The complete file is here. MWE: \documentclass[11pt,fancy,authoryear,twoside]{elegantbook} %-------------------------------------------------- %Bengali Font in Document %--------------------------...
1
vote
1answer
16 views

Styling lstinline separately from listings in preamble?

I use pandoc, so I'm a bit limited in the tex hacks I can apply. However, here is an example: I have this document, test.md, in pandoc Markdown: --- listings: true # see also https://stackoverflow....
0
votes
1answer
22 views

Package `listings`: add counter to custom-defined language

I am using the listings package to include some Julia code, however the Julia language is not yet supported by the listings package. As a result I had to make my own (basic) set of rules, inspired by ...
3
votes
1answer
48 views

How to put lstlisting in a minipage

I had a problem creating a new environment that would let me put a lstlisting inside a minipage. I could create a new environment that sets up the minipage, then in the document put a lstlisting ...
0
votes
0answers
20 views

Problem with listings and overset

I don't understand why listings doesn't render the overset well. \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{graphicx} \usepackage{listings} \usepackage{xcolor} \usepackage{amsmath,...
2
votes
1answer
27 views

Flatfile comma and semicolon hightlight in lstlisting?

How do I create a lstlisting language handling Comman and Semicolon separated list. Would like to highlight the keywords "STOP, START, ATTEMPT" as well as ", , :" (actual comma and ...
0
votes
1answer
43 views

MATLAB script with accented characters does not work correctly with UTF-8 listing

I am truly desperate. I need accented characters in the MATLAB script. I wouldn't mind with comments, but accents are also in Figures, which does actually matter. Both .tex file and .m file are saved ...
0
votes
0answers
31 views

lstlisting error: Package inputenc Error: Invalid UTF-8 byte sequence

I am writing code with: \begin{lstlisting} \end{lstlisting} and \lstset{language=Matlab,% %basicstyle=\color{red}, breaklines=true,% morekeywords={matlab2tikz}, keywordstyle=\color{...
1
vote
1answer
24 views

Reduce space between multiple minted inputs in a single listing

I've created a listing with multiple code blocks using the \inputminted command And want to reduce the space between the blocks. A minimal working example is given here: \documentclass[11pt,oneside]{...
1
vote
0answers
18 views

Invalid numbers and output on listing when using linerange on lstinputlisting

I'm trying to use linerange inside a lstinputlisting. The command is able to read the file but omitts the content of the first line. I would expect if I use the following code to see the last line of ...
2
votes
0answers
32 views

How to customize \lstset for each \lstinputlisting environment in my document?

These are the settings of my overleaf project (they were given to me by my Professor): % Listings and related stuff \usepackage[hyper]{listings} %%%%%%%%%%%%%%%%%%%%%%%% pacchetto caricato da G....
0
votes
1answer
16 views

How to caption a listing(?) environment, custom Python syntax highlighting environment

I am using this answer to add syntax-highlighted Python snippets to my document \documentclass[a4paper,12pt]{article} \usepackage[utf8]{inputenc} \usepackage{newtxtt} % Custom colors \usepackage{...
3
votes
1answer
55 views

Add Insertion Sort's costs in lstlisting

I'm trying to add the costs for each part of the Insertion Sort (that are marked in blue in the picture below) At the moment the code I wrote is this: \begin{lstlisting}[escapeinside=`'] ...
4
votes
2answers
54 views

Show return symbol on listings line breaks

I was wondering if it was possible to make the listings package show a return symbol like "⮑" when a line break occurs. With default line numbering settings this is not needed, as the line ...
2
votes
0answers
22 views

Keyword lists for OpenMP and OpenACC for listings

Has anybody produced a dialect for the C, C++, and Fortran languages in the listings package to highlight OpenMP and OpenACC directives in code that include these pragmas (C/C++) or sentinels (Fortran)...
0
votes
0answers
42 views

How to correctly display 〈 and 〉 in a listing's listing?

This question is a continuation of The 'listings' package and UTF-8. I'm trying to display the characters 〈 and 〉 in a listing (from the listings package). Thanks to Ulrike's answer, I added ...
1
vote
1answer
24 views

How can I create cross-references to 'lstlsting' environments?

I'd like to know if it is possible to use the command \ref (that I use for images and equations) or a similar one to create cross-references to `lstlisting? environments. Doing so, I want to ...
1
vote
1answer
24 views

How to specify settings for each command \lstinputlisting?

I use the following command in my document different times to include matlab codes: \lstinputlisting[caption = listato 1]{Chap_1/Listings/code.m} I've have defined settings for this command in a ...
0
votes
1answer
23 views

Using listings package, can I display line numberings in paretheses?

I want to achieve the following effect for line numbers using lstlisting: (1) public constructor(value?: number) { (2) if (value > 0xff) { (3) throw new Error('Value should not be greater ...
0
votes
0answers
35 views

Parameter settings in listing?

How to modify the font of the code in the listing. I tried basicstyle = \sffamily and it didn't seem to work. Now I can change the font type. But How to modify the spacing between codes. For example, ...
0
votes
1answer
37 views

How to divide lstlisting into multiple tables

I want to use lstlisting to describe two pieces of code. But how can it be divided like this? In addition, can such a list use if else or for statements? What command controls (a) and (b) above the ...
2
votes
1answer
58 views

Latex 'lstlisting' environments ending with unwanted “:” (colon) symbols — how to get rid of them?

I am using lstlisting environments (code provided by the listings package) in my PhD Thesis; after each instance of this environment, an unexpected and unwanted ":" symbol appears on a line ...
1
vote
1answer
36 views

Problem adding a label for cleveref in a double listings/minted scenario

I would need \cref to use the same counter for two different kind of code blocks in my document (one using listings, another using minted). With listings I've defined a new language and a new style, ...
3
votes
1answer
27 views

listings dot and slash chars appearance weird

Say below document: \documentclass[a4paper]{article} \usepackage{listings} \begin{document} \lstset{} \begin{lstlisting} system/etc/selinux/ +-- selinux/ +-- mapping/ | |-- 28.0.cil [94042] | ...
1
vote
1answer
50 views

Box around the code?

I have a piece of code written as: \begin{lstlisting} code \end{lstlisting} I want to put a box, around the code. I have already read this question Source code listing with frame around code? But I ...
5
votes
1answer
112 views

Minted: alternate (zebra) background color lines

despite my precarious knowledge of the environment, I have been able to style listings to my taste (which is nothing fancy) for modern JavaScript. The show-stopper is that I need to syntax-highlight ...
0
votes
1answer
48 views

Source Code styling trespassing to other parts of the document

I'm learning LaTex and searching for ways to insert my c# code into a LaTex document, I found this style from github gists, that formats it pretty good, but the font color is still affected outside ...
2
votes
2answers
33 views

\newtcblisting with multiple optional arguments and defaults

I have a custom environment for code like this (it is a modified version of the code here): \documentclass[12pt,a4paper]{report} \usepackage[many]{tcolorbox} \tcbuselibrary{minted,skins} \definecolor{...
1
vote
0answers
10 views

Changing the pretty-printing of delimiters in a listings language

In my listings language I have commentstyle=\color{red} morecomment = [n][commentstyle]{(*}{*)} So comments are written (* df *) in the tex file and they turn out like . These thick, centred asterisks ...
2
votes
2answers
56 views

How to make tilde symbol in the center on the line text?

\documentclass{article} \usepackage[left=3cm,right=2cm,top=2cm,bottom=2cm]{geometry} \usepackage{listings} \lstset{basicstyle=\ttfamily\footnotesize,breaklines=true,numbers=left,mathescape} \begin{...
1
vote
0answers
29 views

Tcolorbox, minted and listing without caption

I'm trying to have a non-captionned listing using tcolorbox and minted. I've made a macro that automates the task, with the title of the snippet as optional argument. My goal is, when the optional ...
1
vote
0answers
29 views

Unicode characters with lstlisting [duplicate]

In UTF-8 it should be possible to use ä and ö. But actually in my code listing I use the package listings I receive by this example \lstset{language=HTML} % Set your language (you can change the ...
0
votes
1answer
61 views

listings - ! Package inputenc Error: Invalid UTF-8 byte

I have to use unicode char in listings package, but error reported in below example: ! Package inputenc Error: Invalid UTF-8 byte "94. How to resolve this error: \documentclass{standalone} \...
0
votes
1answer
33 views

Missing number, treated as zero within beamer and lstcustom

I am using the package lstcustom, it's a kind of listings. And I get a confusing error "Missing number, treated as zero". I cannot find what I am doing wrong.. :/ Do you have any ...
1
vote
1answer
42 views

Latex lstinputlisting line highlighting

I am using lstinputlisting to reference a piece of source code, for which has a caption and label, as shown below. \lstinputlisting[caption={Caption}, label={code:arbitrary}]{directory/arbitrary} My ...
0
votes
0answers
25 views

Create custom listing for PowerShell. Colouring variables and parameters

I want to create a custom listing for Powershell. Example of what my listing looks like at the moment But I cant figure out, how to colour the variables and parameters. These starts with '$' or '-'! ...
3
votes
1answer
37 views

Numbering the columns in a lstlisting environment

I'm trying to write some commentary about data that is formatted to a very old standard (ARINC 424) in which each record is a 132-column line and data fields are identified by the columns they occupy. ...
1
vote
2answers
60 views

Different rendering of µ (micro) and other unicode symbols when compiling with XeTeX

This is not a "how-to" question but rathe a "why" question. I'm working on re-writing a MS Word document in LaTeX to be compiled with XeTex. I noticed some symbols not showing, ...
0
votes
0answers
11 views

Using tab in lstlistoflistings for long captions

I have a problem with my listoflistings, because when the listing has a long caption about two lines, there is no tab in the listoflistings. For example: \documentclass[ngerman,12pt,listof=entryprefix,...

1
2 3 4 5
65