2022 Developer Survey is open! Take survey.

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
2 votes
1 answer
33 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=...
user avatar
  • 656
0 votes
0 answers
39 views

Why does the page number slightly move its position when a long listing code that need two pages is added?

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 ...
user avatar
  • 83
1 vote
1 answer
45 views

How to align code in lstlisting?

I'm trying to learn the TeX file given by my teacher. I managed to link the C++ file to the listing using: \lstset{language=C++, % numbers=left, % stepnumber=1, numberstyle=\ttfamily, ...
user avatar
0 votes
1 answer
71 views

Listings package - avoid white lines in between lines of code

I'm using Listings to display some JavaScript code. Here are my settings, which I changed a little from those found here: https://mysnippets443.wordpress.com/2015/11/28/latex-insert-javascript-code-...
user avatar
  • 125
0 votes
0 answers
39 views

No space between caption and section in custom newenvironment for minted

In my document i used minted long listing, suggested in minted manual, but it not correctly display for \section*. \documentclass[14pt]{extarticle} \usepackage[newfloat]{minted} \RequirePackage[paper=...
user avatar
0 votes
0 answers
37 views

tcolorbox with option listings gives error if command used is already defined

Using the tcolorbox and its listing-feature I get with this code \documentclass{scrartcl} \usepackage[listings]{tcolorbox} \newcommand{\zB}{z.\,B.} \begin{document} % error message \begin{tcblisting}{...
user avatar
  • 607
0 votes
1 answer
63 views

How to improve spacing in `lstlisting` environment?

I would like to post some MATLAB codes in beamer using matlab-prettifier. I want to create a main title for codes using title option from lstlisting. However, the result becomes as follows Is it ...
user avatar
1 vote
1 answer
44 views

Extra space in listings before column character with french language

It seems that linstings package maintain babel language properties while it includes code. My problem is that the french space before column remains in the python code I included. My question is: how ...
user avatar
0 votes
1 answer
54 views

lstlistings: symbols in lstset morekeywords

For some reason morekeywords doesn't consider =>, <= and check-sat as keywords in the example below. Is there a workaround or a more adequate way to do this? \documentclass[a4paper,12pt]{article}...
user avatar
  • 101
1 vote
1 answer
40 views

double quotation marks creates issues in listings [closed]

I'm writing a R code in LaTeX using the listing package. Everything works fine in the first two lines, with the code written in plain text and the comments in italic. However, after this string quote=&...
user avatar
2 votes
2 answers
53 views

How to write Swedish letters in code listing (lstlisting) in Latext?

I am writing R codes in lstlisting: \documentclass{article} \usepackage{listings} \usepackage[swedish,english]{babel} \usepackage{xcolor} \usepackage{color} \definecolor{ForestGreen}{rgb}{0.0, 0.5, 0....
user avatar
1 vote
0 answers
90 views

Pandoc-generated lstinline in index

I'm generating a large document using Pandoc, and I'd like to use inline code in my index keys. Pandoc generates \passthrough{\lstinline!foo!} for these inline code fragments, and they don't seem to ...
user avatar
  • 945
0 votes
0 answers
22 views

Display Language Name of an lstinputlisting on the top right of the listing

My Problem Similar to this question, I want to display the programming language at the top right of the code listing, as you can see in the following image: The problem with the linked solution is ...
user avatar
  • 1
0 votes
0 answers
24 views

Escape to LaTeX from within lstinline [duplicate]

I'm trying to run a LaTeX command within an lstinline from the listings package. I found How can I use LaTeX-commands inside of a listing? which explains about escapechar, and I can get that to work ...
user avatar
0 votes
0 answers
24 views

Listings - Disable specific instance of keyword highlighting

I have a python listing where I have an object with the attribute "range", but I also use the actual range keyword in a loop in the same listing. Is there a way to only disable the wrong ...
user avatar
0 votes
0 answers
42 views

Listings: Math Symbol as Line Comment

I'm using pandoc to transform markdown to latex to PDF. Where there's no fitting (simple) solution in MD, I use inline latex. Since hash / pound (#) signs are title markers in MD, I'd like to escape ...
user avatar
  • 3
0 votes
1 answer
134 views

Use the bold typewriter font from lmodern for keywords in listings but keep Computer Modern fonts in the rest of document in LaTeX

I am writing a document in LaTeX using the standard Computer Modern fonts. The text is mainly in Russian but it includes some listings. I prefer to typeset listings using the standard typewriter font (...
user avatar
0 votes
1 answer
38 views

Use semi-bold instead of boldface fonts in code listing syntax highlighting

By default, LaTeX syntax highlighting for source code uses bold text for keywords. How can I instruct it to use semi-bold fonts instead. (This assumes, of course, that a semi-bold variety exists for a ...
user avatar
1 vote
1 answer
112 views

How to make listings treat unknown languages as normal text

When writing a code block for the plantuml language, I get the error Package Listings Error: Couldn't load requested language.. How can I ignore this error and just show the code block without code ...
user avatar
0 votes
0 answers
14 views

How can I create a lstlisting with the caption "Listing" in some other language? [duplicate]

How can I create a lstlisting with the caption "Listing" in some other language? So instead of "Listing 2.1" I want to have this in some other language.
user avatar
  • 181
0 votes
0 answers
41 views

lstlisting: numbering of longlines automatic broken by breaklines=true

I try to get linenumbers on longlines that breaklines=true break up: So i added to my head the counter defintion: \newcounter{lstbreaklinesnumber}[lstnumber] % breaklines-counter so it should reset on ...
user avatar
0 votes
0 answers
82 views

Support for Microsoft Visual Basic in the listings package

Evidently the listings package does not support Microsoft Visual Basic. Are there any plans for VB in the future? Alternatively, are there any known work-arounds?
user avatar
0 votes
0 answers
24 views

How do I correctly define keywords in the \ lstdefinelanguage section?

I create my own language definition with the listings package. It's a mix of HTML and Javascript. Why are the tags <title>, <h1>, <li> not included in the syntax highlighting and how ...
user avatar
  • 49
0 votes
1 answer
24 views

pass caption to custom command listing

I have a command \customfile that creates a listing with the file passed as an argument. \newcommand{\customfile}[1]{ \lstinputlisting[language=customlanguage,% frame=lines,xleftmargin=8pt,...
user avatar
  • 115
1 vote
0 answers
32 views

emphasise certain parts in lstlistings [duplicate]

I'd like to know wether there is the possibility to change the colour of a single word in a lstlisting. I know you can set certain words or characters to certain colours in the beginning with lstset{.....
user avatar
  • 23
3 votes
2 answers
145 views

Placing listings in page margins

Goal My goal is to place listings in the margins. I want to use sidenotes for this, not snotez, because I also require other functionality present in the former, but not the latter. What I tried I ...
user avatar
0 votes
1 answer
79 views

Is there a package that displays a terminal screen with code with listings or minted?

I search a LaTeX package which show code inside a terminal image, where I could use listings or minted. If this not possible I have to build it by myself and will it post here.
user avatar
  • 449
1 vote
0 answers
33 views

Break a tcolorbox and remove subsequent empty lines

I have some lstlisting blocks that I am typesetting as colored textboxes. Some of these blocks contain empty lines; and some of these blocks are broken across page boundaries by a manual \tcbbreak. I ...
user avatar
  • 945
1 vote
1 answer
58 views

Title-cased small caps in Listings

I'm trying to transform an uppercase KEYWORD into \textsc{Keyword} in Listings. I'd like something of the form \lstdefinestyle{mystyle} { language = ML, basicstyle = {\ttfamily}, ...
user avatar
  • 1,000
1 vote
0 answers
74 views

Including Cisco IOS commands with proper highlighting in my document

The problem I want to include Cisco IOS commands (from the Cisco IOS CLI) with proper highlighting in my document. Is it really necessary? One could argue that applying syntax highlighting to Cisco ...
user avatar
  • 634
0 votes
0 answers
50 views

Setting any `listing options` changes `tcolorbox` layout

I'm using tcolorbox to typeset listings. When I try to set the listing options, the whole layout of the tcolorbox changes. Why is that? How do I avoid that? To be clear, I'd like to keep the first ...
user avatar
  • 945
0 votes
0 answers
27 views

Installing "listings" in mac for R sweave

I am trying to install the package "listings" so I can show python code on LaTeX, with R sweave. I found the folder /Library and the only thing LaTeX related I found there is a folder called ...
user avatar
2 votes
2 answers
113 views

Colorize C escape sequence in strings

Given the following MWE: \documentclass{article} \usepackage{xcolor} \usepackage{listings} \usepackage{nimbusmono} \lstset{ language=[ANSI]C, basicstyle=\ttfamily, stringstyle=\color{red}...
user avatar
0 votes
0 answers
65 views

How to get minted listing to break into multiple pages

Listings like \begin{listing} \begin{minted}[linenos,breakanywhere,breaklines]{python} # long code \end{minted} \label{lst:label} \end{listing} will go over the page number and generate a Float ...
user avatar
0 votes
1 answer
39 views

Word sometimes bold and sometimes not in listing

I would like to write a listing in which the same word appears in some cases in bold and in some other cases not. In particular the listing is structured as a set ok key-value pairs, as follows: key1: ...
user avatar
  • 1
0 votes
2 answers
36 views

How to insert algorithm as text using listings package

Good afternoon , I need to write some algorithm steps as text using listings package : \documentclass[10pt]{book} \usepackage[english]{babel} \usepackage{amsmath,amsthm} \usepackage{amsfonts} \...
user avatar
  • 173
0 votes
0 answers
42 views

Minted & Top Caption

I have tried to use the following example to get the caption for listing above the listing. (I also saw the example for newfloat, however I already use float for figures and tables as well.) However, ...
user avatar
1 vote
1 answer
69 views

Node position with listings overlay

I'm trying to add a label on a code listing. I will have a listing labeled "Device A" and a listing labeled "Device B". I was hoping to draw the label somewhere in the corner of ...
user avatar
0 votes
1 answer
46 views

Numbering format for listings (lstlisting)

I'm writing a document with a lot of listings ini it. I need to index the listing with the following format: "Listing a.b" with: a the chapter (arabic) and b the order of occurence in that ...
user avatar
0 votes
1 answer
79 views

Text on the side

I need to put text on the left side from my lst listing it should look like on the photo. \lstdefinestyle{myStyle}{ belowcaptionskip=1\baselineskip, breaklines=true, frame=none, numbers=...
user avatar
0 votes
0 answers
76 views

Define a new caption (listing environment)

I got the following code here: \documentclass{article} \usepackage{xcolor} \usepackage{listings} \usepackage{caption} \DeclareCaptionFont{black}{\color{black}} \captionsetup[tip]{ labelfont=black, ...
user avatar
  • 41
0 votes
1 answer
62 views

Emphasize greek letters within LyX's (Program) Listing

I include greek letters in LyX's Program Listing (using mathescape=true) and want to emphasize them (with color & bold, using emph and emphstyle), but I can't get it to work; I geuss that it ...
user avatar
  • 3
1 vote
1 answer
134 views

When combining listings and JetBrains Mono * glyphs drop to the baseline (and are too big)

Preparing a book where I use JetBrains Mono (Github Repo) (JBM) for code I noticed that in all the listings the * characters where rendered far to deep (on the baseline) and quite big. Also the *** ...
user avatar
0 votes
0 answers
16 views

Remove redundant space before/after LyX's program listing

How can we remove the redundant space before and after LyX's program listing box which can be seen in the following example?
user avatar
  • 35
1 vote
0 answers
110 views

Creating code environment with \DeclareTCBListing from tcolorbox

I intend to create a code environment to speed up and clean my TeX code. The idea is that it can be preceded by a 5mm space, a section and/or subsection and/or subsubsection also be optionally printed ...
user avatar
  • 69
0 votes
1 answer
55 views

Weird error with memoir and listings

The following MWE crashes: \documentclass{memoir} \usepackage{amsmath} \usepackage{listings} \newlistof{lstlisting}{lol}{\lstlistlistingname} \begin{document} \begin{lstlisting} struct x; \...
user avatar
  • 5,237
0 votes
0 answers
24 views

How to cite my listings code snippets

I have a listing section in my paper, like this for example \begin{lstlisting} System.out.println("good"); \end{lstlisting} And I want to reference to it later in the text. How do I do ...
user avatar
0 votes
0 answers
27 views

Question about enumeration

I need to use an enumeration inside another one without using two enumeration-environments one inside the other. I have tried the command \subitem but it seems it doesn't exist. Which command should I ...
user avatar
0 votes
0 answers
39 views

Listings, set color to text in escapeinside

I'm trying to write accents in listings, so I decided to use escapeinside to return to latex and put them easily. \documentclass{article} %%%%%%% Document %%%%%%% \usepackage[spanish,es-tabla]{...
user avatar
1 vote
0 answers
21 views

Replacing a listing with another listing in a single frame in beamer

I want to divide my slide to two parts, right and left. \item First point appears at the same time as "the first piece of code." Then \item Second point appears at the same time as "the ...
user avatar
  • 274

1 2 3
4
5
69