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
2answers
48 views

ů ř do not appear in the listings

How to include ů and ř to the listings, please? \documentclass[12pt,a4paper]{article} \begin{filecontents*}[overwrite]{myscript.txt} script.txt # hello í ů ř á hello \end{filecontents*} \usepackage{...
0
votes
1answer
25 views

expand macro before using as param for listing in newcommand

I wanted to create a parametrized macro (using newcommand) for my listings: It works as long as I use text as input parameter. Once I switch to macros as parameter it doesn't work. I have the ...
1
vote
1answer
30 views

A case of code plot in C++

I am entering some C++ files inside my LateX main.tex, and it appears that LateX "writes" the space symbol when there's a space in a string inside listing. (I am using listingsutf8 package) ...
3
votes
1answer
169 views

How can I write letters like ř, í, á to listings?

How can I write letters like ř, í, á to listings? Why is zero in the name of the section? \documentclass[12pt,a4paper]{report} \usepackage[total={7in, 9in}]{geometry} \usepackage{enumitem} \usepackage[...
2
votes
1answer
39 views

Verbatim/Lstlisting environment with background color highlighting

Use case: Currently we are reporting security findings using MS Word. These findings contain large parts of code snippets, command outputs and HTML code. We highlight relevant parts of this code so ...
0
votes
0answers
12 views

Long CSV line not looping to next line [duplicate]

I have a problem with the lstdefinestyle. I'm not able to find a solution on why a long CSV line isn't looping to the next line. I have a basic lstdefinestyle that I've defined but I've also used ...
0
votes
1answer
31 views

Change reference name of listing

I would like to reference the listing like Codebeispiel 1. How can I do that? What I got is only ?? 1 \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{blindtext} \usepackage{titlesec} \...
2
votes
1answer
21 views

Listings + Tcolorbox page break resets color

I want to have a lstlisting environment in a tcolorbox. The problem is when there is a page break, with breakable, the colour component of the listings option basicstyle is reset after the page break, ...
0
votes
1answer
26 views

Force line break on url in listings

I want to list some python code in a file, but I have the problem, that url's are not getting split properly, line break does not seem to work for them. Also, how can I remove the word 'file' from ...
1
vote
1answer
35 views

Why is there a side effect of using `breaklines=true` inside longtable on the adjacent cell?

I noticed using breaklines=true option for lstlisting in one cell in a table, causes the text in the next cell in the same table row to shift down a little, even though the next cell does not use ...
1
vote
2answers
46 views

`\Block` does not accept `\lstinline`

I would like to typeset verbatim style commands from \lstinline in \Block command, but it does not seem to work \documentclass[a4paper,12pt]{article} \usepackage{nicematrix} \usepackage{listings} \...
1
vote
1answer
22 views

Listings show Quotation marks in italic - how to print them in Regular?

I use the listings package for showing source code. I just realized, that double and single quotation marks are printed in italic - they should be printed in regular instead ... Where is the issue? Is ...
0
votes
1answer
30 views

How can I use \lstdefinestyle in a subfile?

Assume that main.tex is my main compiled latex file. The rest of them (as sub.tex) includes the list of def ones in order to arrange each chapter, subchapter etc. How can I use defined style in main....
0
votes
0answers
37 views

How to get `\section` command to accept verbatim text with '\' inside it?

I am trying to define a verbatim style for LaTeX \lstdefinestyle{verbatim}{basicstyle=\ttfamily,language={[LaTeX]TeX}} Then I use the following command to typeset LaTeX commands as they appear in ...
0
votes
0answers
8 views

Redefine \lstinline{code} as \Colorbox{yellow}{\lstinline{code}} [duplicate]

I'm writing a cheat sheet where I'm using \lstinline{} for inline code. I want to highlight every inline code. I found a solution that I need to use \Colorbox{yellow}{\lstinline{code}} to highlight it....
1
vote
2answers
21 views

Tilda ups when use code cpp snippets

I use C++ code snippets with latex. I try to use verbatim, lstlisting and minted(imho which is the most beautiful). But they has one trouble. When I want to write code p->~T() I get tilda at the ...
1
vote
1answer
25 views

listings package doesn't render brackets correctly

I'm trying to list some code using the listings package, however if use ttfamily font, brackets don't render correctly. This is what it looks like
0
votes
1answer
16 views

Remove emphasized spaces on lstlisting with bash

I have the following code that prints my bash code on the document \begin{lstlisting}[language=bash, caption=Comandi per l'installazione dell'engine di Docker,captionpos=b] $ sudo apt-get update $ ...
2
votes
0answers
15 views

Remove spacing around lstlisting in beamer blocks

Consider the lstlisting in this MWE. (I have added normal text and itemize environment blocks for comparison.) \documentclass{beamer} \usetheme{Warsaw} \usepackage{listings} \begin{document} %\...
0
votes
1answer
32 views

Listing inside align environment doesn't work

I found a very specific formatting error: when I use lstinline[mathescape] inside an align environment, some of the basic math formatting like subscripting stops working. It does however work in e.g., ...
0
votes
0answers
23 views

listings : How to parse character sequences into math symbols

I'm trying to format code snippets using listings. The language I'm targeting (typed template Haskell) features the equivalent of double square brackets brackets [|| and ||]. These look quite poorly ...
0
votes
1answer
51 views

Put \lstinline inside \chapter, \section, etc. commands

How can I place \lstinline code inside commands like \chapter, \section, \subsection, etc.? Or it's a bad or tasteless practice?
2
votes
0answers
42 views

Put \lstinline inside a \item and automatically add \item content to glossary

I've implemented this solution to allow placing \lstinline code inside description \item command. I also want to automatically add the entire \item content as a glossary entry by placing it into name ...
0
votes
0answers
13 views

Highlight \lstinline, make it work with backtics

I have 2 related questions. In short, I want to make inline code snippets like in markdown: int c = 4;. The questions are: how to highlight text inside \lstinline (gray background)? is it possible to ...
0
votes
1answer
34 views

Indentation problem with wrapfigure and listings

I am having a problem with some indentation of paragraphs when displaying an image next to a block of lstlisting. I am using Overleaf online (and have found several weird quirks previously). Below is ...
0
votes
0answers
15 views

How to make listings package recognize strings of a specific form

The listing package provides literate command which allows replacing specific fragments of code with something else, like: literate={)}{{\textcolor{red}{)}}}{1} replaces the right bracket with its ...
1
vote
2answers
27 views

Set vertical spacing of custom new environments

I defined a code environment in which minted environments are put in order to span in multiple pages. The problem is that captions are too close to the text next to the code frames. How can I increase ...
1
vote
1answer
27 views

How can I add additional spacing between some lines in `minted`?

I would like to add a little separation between some lines of code for readibility. Consider this MWE: \documentclass{article} \usepackage{minted} \begin{document} \begin{minted}[linenos]{python} ...
0
votes
1answer
37 views

Listing too wide for colour box

I have the Latex code below to represent listings of C++ code, however the C++ code seems to be too wide for the greyed out box in the background. I would also like the listing too fit as it was ...
0
votes
0answers
117 views

Compilation in TeXworks: "LaTeX Error: File `listings-python.prf' not found."

I'm working on a collaborative LaTeX project. While compiling the pdf with Windows 10 and TeXworks, I noticed this issue: ! LaTeX Error: File `listings-python.prf' not found. Type X to quit or <...
0
votes
1answer
40 views

Custom new environment positioning and margins

How can I place the following custom new environment at the top of every page like figures (options [ht])? \usepackage[newfloat]{minted} \newenvironment{code}{\captionsetup{type=listing}}{} \...
0
votes
0answers
28 views

lstlisting collection of styles

I'm looking for a collection of different styles for the lstlisting package. I know there are some good ones for examples of tikz pictures and templates, but I couldn't find one for lstlistings. Does ...
6
votes
1answer
300 views

How to Assign the Numbers Automatically in This Enumerate Environment

Consider \documentclass{book} \usepackage{tcolorbox} \newtcbox{\blackbox}[1][]{nobeforeafter, notitle, %sharpcorners, colframe=black, colback=black, top=4pt, left=5pt, right=...
0
votes
1answer
25 views

\surroundwithmdframed does not sourround \lstinputlisting

I need to surround code listings with a customized gray mdframed. To do this I use the very convenient macro \surroundwithmdframed[options]{environment} to instruct that all lstlisting environments ...
0
votes
0answers
22 views

Multiple horizontally stacked side-by-side listings

I am using acmart. They define a full-text (two-column) listing environment listing*. If I put multiple minteds inside it, they are stacked vertically. I would like to have them side-by-side. Is that ...
1
vote
1answer
36 views

How to add color to numbers in the Listings package?

I am using the Listings package in Lyx. I can change the color of whatever word I want using \lstset{emph={word}} and \lstset{emphstyle={\color{green}}}. However this does not work with numbers. \...
0
votes
2answers
48 views

Highlighting code snippet in lstlisting with colorbox changes the character and breaks the border

I am using Texstudio with texlive 2021. To highlight some lines of the following code snippet in lstlisting, I am using colorbox \begin{lstlisting}[style=listing1] |\colorbox{yellow}{...
1
vote
0answers
21 views

How to color second words in blue with matlab-prettifier

I'm using the Matlab-prettifier package quite happy with it. Even if it can mimic almost perfectly the Matlab style it just doesn't color second words in blue (like MATLAB does). Somebody know how to ...
2
votes
1answer
44 views

How to add text before/to the left of \begin{lstlisting}?

I want to write exercises where the student must explain numbered pieces of code. To the left of each piece of code, I would like to add a letter, like a), or a number. I prefer to use \begin{...
1
vote
1answer
19 views

Unable to use listing with toptesi

Everytime I open a new listing the compiler complaints about it. Try to compile the following example % !TEX options = -shell-escape \documentclass[% corpo=12pt, twoside, oldstyle, tipotesi=...
1
vote
1answer
26 views

Why does the page number slightly move its position to the bottom line when a listing code is written on two pages?

I noticed that whenever I add a source code to my latex file, the numbers of the page where the code is added look displaced. I do not know if there is a reason in the listing configuration that ...
0
votes
1answer
27 views

How to align reference code?

I want to add reference to my c++ project, but it doesn't seem quite right. The code doesn't has any alignment, and it get cropped with the paper. It look like this: I use this to link my code to ...
1
vote
0answers
23 views

Listings - ignore keyword within String

I'm using Listings, and want keywords to be ignored if they are within Strings. For example, the code in my example highlights if within the String: \documentclass{article} \usepackage{listings} %...
1
vote
2answers
35 views

Can't get listings to behave at line endings despite use of breaklines parameter

I'm having trouble with getting listings to behave at line endings and respect the page margins. Consider the following code: \documentclass{article} \usepackage{listings} \usepackage[showframe,margin=...
0
votes
0answers
33 views

Unusual code listing box that's semi-split

I've been trying to figure out how to get LaTeX to make a rather unusual "code list" box. I was initially looking at the listings package, and then at tcolorbox. (minted also showed up in ...
1
vote
1answer
83 views

Putting a Code to the Right of an Item in a New Enumerate Environment

Consider I would like to present the string of 12 colored bullets a little to the right of the enumerated tcolorbox and vertically centered. The code which produces the above picture is \...
0
votes
1answer
28 views

No minted listings TOC page break when many listings

I am currently experiencing a problem with the toc for the minted package. I have so many listings, that the toc should split up onto two pages. However it does not do it. Now I need a solution on ...
4
votes
1answer
20 views

Problem when inserting an url inside lstlisting and compiling with make4ht

The following examples shows an error when an URL is inserted inside a lstlisting caption. \documentclass{article} \usepackage{listings} \usepackage{hyperref} \begin{document} \begin{lstlisting}[...
1
vote
2answers
52 views

Listings and Color change the position of a character

I try to setup listings using FiraCode with a blue color in my frames and sometimes I need another color in lstlisting environment. I do it defining another font family. The * are not at the same ...
2
votes
1answer
26 views

float placement for listings causes warnings in make4ht

The following examples compiles but creates warnings just when the float parameter is used. \documentclass{article} \usepackage{listings} \begin{document} \begin{lstlisting}[float, language=tex, label=...

1
2 3 4 5
67