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

Display package-specific commands with lst

I would like to display code similar to: \begin{tikzpicture}[scale=0.2] \draw[fill=blue!25] (-15,0) -- (-3,0) -- (-3,-12) -- (-15,-12) -- cycle; \draw[fill=blue!25] (8,1) -- (14,1) -- (14, -5) -- (8,...
0
votes
1answer
22 views

listlistings comment style not applied on language operators

I'm using the lstlistings package to typeset some Haskell and Scala code in my document, and I've defined a simple style named ttt. I set comments to be displayed in red for contrast, but the problem ...
0
votes
1answer
39 views

Problem with `listings`, `babel`, and `zref`:

[listings 1.8d] [zref 2.32] [babel 3.54] I spent an evening to reduce my real-world example to the following code. \documentclass{scrartcl} \usepackage{listings} \usepackage[ngerman]{babel} \...
0
votes
0answers
15 views

Putting listingsutf8 literate definitions in a separate file with \input

I have a set of literate options for the listings package that I would like to move to an external file, so I don't have to paste them in every time. (The eventual goal is to have LaTeX commands ...
0
votes
0answers
16 views

Indicating single quotes as delimiters in Listings

I'm using the Listings package and am having a bit of trouble properly highlighting a string such as string x = 'a' with single quotes. The issue is that in Latex the left single quote operator (`) ...
0
votes
0answers
24 views

Recommended style for (technical) listings and algorithms. When to use floating?

For figures, you usually would use some floating environment. I think this is in general the recommended way (right?). For algorithms, it is probably the same (via listings). E.g. I had some text like ...
1
vote
0answers
57 views

Strange result with package listings when a string literal presents

I'm using package listings to add code in a document. Almost everything works pretty well, until I write a string literal like this: \documentclass{article} \usepackage{listings} \begin{document} { \...
1
vote
1answer
41 views

lstlistoflistings is populated with XeLaTeX logs instead of actual code

I'm having a hard time with \lstlistings command as it does not generate a proper lol file with the list of listings but, for some reason, it gets populated with XeLaTeX execution logs; vice versa, ...
0
votes
0answers
50 views

Code listings of O'reilly books

What are the O'Reilly code listing configurations for their books about computer science? Following is an example of such code formatting.
1
vote
1answer
22 views

lstlisting: Unexpected newline/missing background color after trailing space in escape section

I'll start with a minimum failing example: \documentclass{article} \usepackage{listings} \usepackage{color} \lstdefinelanguage{x}{ escapechar={!} } \lstset{language=x, breaklines=true, ...
1
vote
2answers
70 views

Insert inline code block in Latex document

Hi i am trying to add an inline code block in a Latex document. I know how to add a separate code block using lstlisting but i want to instead add an inline code block. I am attaching the screenshot ...
0
votes
0answers
14 views

Listing package with language Matlab/Octave, & not appearing on the compilied file

Am trying to insert a code in my PDF file using the listing package. The code is a Matlab/Octave code but I found that & did not appear in the compiled pdf file. The code \documentclass[12pt]{...
0
votes
1answer
46 views

Using listing inside a custom command

Good afternoon, I am having the following problem: I have to describe a set of items that have all the same format, let's say property 1, property 2, ecc. For this reason I created a new command, so ...
0
votes
0answers
40 views

Create List of Listings like List of Figures

I'm trying to make a List of Listings that appears in the Table of Contents like List of Figures. I'm using a class that was provided for me, and I tried editing it but it isn't working. This is what ...
1
vote
1answer
22 views

Use listing for Matlab code from another file directory

I used the listingcode example from here What can I use to typeset MATLAB code in my document? to load a matlab code file directly into LaTeX, but I use different file directories as followed: \...
2
votes
0answers
16 views

Extended Latin characters appear out of place in \listings

I am trying to generate a PDF containing my XML file, which is UTF-8 encoded and contains extended Latin characters. However, there is an issue – Polish characters appear out of place in both listings ...
0
votes
0answers
33 views

Force to unindent default code

I want to unindent the default indent by mmacells. Here you can see the input and output are indented, and i want to force them to the left start. How to do that? Using \noindent and hspace*{-.5cm} ...
0
votes
1answer
28 views

How to add a font code with \lstinline?

Under LaTeX, I'm wanting to add the following R code between text. I'm searching for an appropriate font . I already tried: \documentclass[notitlepage]{article} \usepackage{amsmath, amssymb} \...
1
vote
1answer
19 views

How can I get a line from an external text (input by `\lstinputlisting` of the listings package) into the table of contents?

I am just experimenting with a couple (about 50 or more) of simple text files, inputting them into a collection to be printed. My first problem, getting the first line printed as a heading in bold, ...
0
votes
0answers
22 views

What is the option I should use for basicstyle in \lstset if I want Times New Roman font in source code?

I copied the following from somewhere in Internet to the beginning of the latex document to enable math escape in source code listing : \usepackage{listings} \lstset{ basicstyle=\ttfamily, ...
1
vote
0answers
40 views

How do I combine multiple GitHub source code files into a single listing?

I currently have the following command that I use to create a listing from a GitHub-hosted file: \NewExpandableDocumentCommand{\GitHubFile} { O{foo-default-group} m m m } {% |"wget -qO- https://...
0
votes
0answers
14 views

When Using the listings Package, How Do I Remove Unwanted Spaces Inside Character Literals?

I am using single quotes to enclose Python character literals in my listing. Unfortunately, the result is that the character '(' looks more like ' (', while the character ')' looks like ') '. Since ...
0
votes
0answers
21 views

Adjust top/bottom padding in listing environment?

In this example, one notices the margin around the text is different in (1) and (2). I would like lstlisting to have the same padding than in (1): \documentclass{article} \usepackage[utf8]{inputenc} \...
1
vote
1answer
44 views

Adding keyword to a listing that matches exact instances [duplicate]

I want to add more keywords to a listing, however, I only want to match the exact instances of that new keyword, as the keyword sometimes happened to occur as part of normal words and it gets colored ...
0
votes
1answer
29 views

Changing font family of lstlisting to standard/normal LaTex font

I want to change the font family of my lstlisting to an italicized "normal" latex font, so a non-monospaced font. I've already tried setting my basicstyle=\rmfamily\itshape and while it ...
0
votes
0answers
18 views

Output data from file and text in listing

Sometimes I need to mix input from a file and local text in listings. The following snippet produces File ended while scanning use of \lstenv@Process. \documentclass{book} \usepackage{listings} \...
0
votes
0answers
29 views

How to make overleaf not error-flag $ in source code

I have the following piece of LaTeX code We have that \lstinline[language=R]!glm(n ~ i, family = poisson)$dev! \( = -2l(\hat\theta) = - 2l(\hat\beta_0 + i\hat\beta_1)\). Overleaf compiles it, but the ...
0
votes
1answer
43 views

List of invisible things

I need to create a list of invisible things. For instance, in the following MWE, there is a list of examples, but it should not appear in the text. MWE: \documentclass{article} \usepackage{tocloft} \...
2
votes
0answers
26 views

listings package highlight differ background color

I wish to highlight differ code color with listings package like below: Below code highlight the foreground, how to change the line's background color as well? \documentclass{standalone} \usepackage{...
11
votes
2answers
469 views

Fortran 77: Specify more than one comment identifier in LaTeX

I am trying to specify two types of comment style I have used in my Fortran 77 program (both a c and a !). At the moment the current program just recognises the ! and not the c. Does anyone know how ...
1
vote
1answer
39 views

listings and danish special chars does not work together

In the small document listed below, I try to include some danish special chars in a lstlisting environment, but that does not work. However it works fine in the verbatim environment. I use the ...
0
votes
0answers
52 views

Trouble using pygmentize as standard user in Windows

i have some problems with pygmentize. I know that there are already a few questions in this forum concerning pygmentize but i can't find a solution for my problem. I'm using Texmaker with Miktex as &...
1
vote
0answers
48 views

Side-by-side layout only on some lines of listing

How is the following achieved? I've done the blue parts with escapeinside: \documentclass{article} \usepackage{listings} \lstset{numbers=left} \begin{document} % this achieves the first two lines ...
6
votes
1answer
172 views

file/after hook executed twice with listings and LaTeX 2020-10-01 PL3

This morning after an update to LaTeX 2020-10-01 PL3 my test suite failed with a mysterious error. The error could be traced back to a not-so-minimal WE of the following form \documentclass{scrartcl} \...
0
votes
0answers
50 views

LaTeX equivalent of HTML's <pre>?

What's the LaTeX equivalent of HTML's <pre> tag?
0
votes
1answer
36 views

Using lstlisting with tcolorbox give me a huge box

I'm using lstlisting with tcolorbox to show some code, but I have a problem with the width of the box. If one of the lines is longer than the document width, then because I have breaklines and ...
0
votes
1answer
36 views

\lstset does not respect line breaks and indents with Cyrillic symbols

I'm trying to output some code along with translated comments but the listing does not respect indentation and line breaks if first symbol in a line is Cyrillic: \documentclass{book} \usepackage{...
0
votes
1answer
47 views

Uneven space above and below listing with parskip used

The following code creates a bigger space below the listing. I need parskip to keep space between paragraphs. \documentclass{book} \usepackage{listings} \usepackage{xcolor} \setlength{\parskip}{6pt} %...
1
vote
3answers
66 views

Customize the caption with a background

Hi there, i have some problems with modifying a caption which belongs to a listing. The current result is shown in picture. What i would like to change, can be seen in the second picture. As you can ...
0
votes
0answers
9 views

Is it possible to use an existing TestMate style for latex listing styles?

In Textmate I have a language grammar in textmate grammar specification, for example like the one below from the texmate site: { scopeName = 'source.untitled'; fileTypes = ( ); ...
0
votes
0answers
20 views

How to color only literal constant in listings package?

I'm trying to show some c++ codes and want to hightlight all the literal digits with colors. I have referred to the question Coloring digits with the listings package and Colored strings by listings ...
2
votes
1answer
41 views

Fira code breaks listings background

I'm trying to use Fira Code on listings with a background. However, the background lines break above (, ), { and }. At first I thought this was a problem with custom fonts in general, but after ...
1
vote
2answers
31 views

Changing inline listings font size when inside a footnote

Listings will have the same size specified on basicstyle, which i've set to footnotesize, which looks best for my purposes. However, that also applies to inline listings, which usually happen on ...
0
votes
0answers
22 views

How to get a right vertical alignment in lstlisting

I am writing some SQL code in LaTeX, but the rendering is not that satisfying. I'll leave the code I wrote down \begin{lstlisting} create table Dipartimento ( Codice char(3) primary key, ...
0
votes
1answer
23 views

Centering lstlisting environment

I'd like to center (horizontally) the lstlisting environment in the page. I tried using "xleftmargin=0.2\textwidth" but the result is not that satisfying. I tried to include the lstlisting ...
1
vote
1answer
45 views

How can I manually add italics or underlines to code listings using minted?

I'm a new user of minted, and I have a LaTeX fragment that looks like this: \begin{minted}{python} `s` = input(`prompt`) \end{minted} I was previously using the listings package: \begin{lstlisting} `...
0
votes
0answers
11 views

How to add source code to glossary entry (lstlisting not working)

I am trying to add source code as the description to a glossary entry: \newglossaryentry{chans} { name=chans, description={ Refers to the following struct: \\ \begin{lstlisting}...
0
votes
2answers
37 views

Picture and Code Side by Side: Lstlisting not working inside \subcaptionbox

I am trying to get source code and a picture side by side with two captions that are aligned with the upper part of the caption text as suggested in this thread: Having two figures subcaption on the ...
1
vote
2answers
58 views

strange unicode behavior in listings [duplicate]

I have the minimal document here: \documentclass{article} \usepackage{unicode-math} \usepackage{listings} \setmainfont{Stix} \setmathfont{Latin Modern Math} \setmonofont{Fira Mono} \begin{document} ...
1
vote
1answer
108 views

How to create this beautiful Python highlighting in LaTeX with listings?

I found this beautiful Python code highlighting in a PDF today. I want it! But I don't know how to get it? Here is what I tried: \documentclass[10pt,a4paper]{article} \usepackage[utf8]{inputenc} \...

1
2 3 4 5
64