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
0answers
22 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{.....
3
votes
2answers
105 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 ...
0
votes
1answer
42 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.
1
vote
0answers
16 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 ...
1
vote
0answers
27 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}, ...
0
votes
0answers
22 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 ...
0
votes
0answers
23 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 ...
0
votes
0answers
16 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 ...
2
votes
1answer
34 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}...
1
vote
0answers
32 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 ...
0
votes
1answer
31 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: ...
0
votes
2answers
26 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} \...
1
vote
0answers
22 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, ...
1
vote
1answer
33 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 ...
0
votes
1answer
18 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 ...
0
votes
1answer
55 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=...
0
votes
0answers
67 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, ...
0
votes
1answer
26 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 ...
1
vote
1answer
42 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 *** ...
0
votes
0answers
13 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?
1
vote
0answers
57 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 ...
0
votes
1answer
35 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; \...
0
votes
0answers
19 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 ...
0
votes
0answers
25 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 ...
1
vote
0answers
17 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]{...
1
vote
0answers
17 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 ...
0
votes
1answer
25 views

“Allow page break before the next line” inside lstlisting

I am trying to use the code from this answer to have precise control over where page breaks can occur inside listings. My problem is twofold: it seems I can't put the commands on their own line, and ...
0
votes
1answer
32 views

How do I remove the box around python code?

I am using \usepackage{pythonhighlight} for python code and this creates a box around the code by default. Is there a way to remove the box? \begin{python} def f(x): return x \end{python}
0
votes
1answer
70 views

Syntax highlight for gmsh code (*.geo)?

I am looking for syntax highlighting packages (as listings or minted) for *.geo (gmsh input) and/or MSH file format version 2 or 4 *.msh (gmsh output). Example of content of *.geo file // Scale global ...
1
vote
1answer
39 views

Non-ASCII escape characters

I'm using all ASCII characters in my code blocks, so I need to reach for non-ASCII ones for the escape characters. I expected Xetex to deal with this just fine; alas, it doesn't seem to be the case. \...
2
votes
1answer
44 views

How are these texttt fonts different?

Below are two examples of fonts. The first is from the verbatim environment (which I read has default font ttfamily). The second is from a lstlisting with basicstyle=\ttfamily. They look different. ...
0
votes
0answers
15 views

Which syntax for @ in a listings literate?

To load, with \lstinputlisting, C files that contains copyright information I used \lstset{ language=C, literate={@}{\textcopyright}1 } But I am still getting 'invalid UTF-8' error for the '©' ...
1
vote
2answers
39 views

How can you align text in a tabular in the top left corner with listing

I am creating a pseudo latex interface of a console GUI. I do not want to use screenshots of the GUI because I need the text to be able to go to the next page. What I have right now is this: \...
0
votes
0answers
18 views

Reset \lstset Style

I define a \lstdefinestyle in my document that looks something like this: \lstdefinestyle{examplestyle}{ backgroundcolor=\color{green}, commentstyle=\color{blue}, keywordstyle=\color{magenta}, ...
0
votes
1answer
26 views

Why are there blank horizontal gaps in my listing/lstlisting background?

There are horizontal gaps in my listings code block when I change the background color. This minimal working example code and screenshot demonstrate the issue. \documentclass{article} \usepackage{...
0
votes
0answers
33 views

How to show output of my python code using lstlisting?

This is the code that I am inserting inside the tex document. And everything goes fine. \begin{lstlisting} import numpy m = numpy.zeros(shape=(56,54), dtype=int) #We begin by creating an empty 56x54 ...
1
vote
1answer
45 views

Exclude lstlistoflistings cite of bibliography sources

I have a \lstlistoflistings in my document. And I am referencing some of the code. However, in the bibliography it appears to be citing them as if there was an explicit citation whereas for \...
1
vote
1answer
44 views

Code listing for arduino language?

I've been trying to use the listings package. The problem is that I don't know how to put different colors to the different key words. With my code I can only get some of the keywords to be an ...
1
vote
1answer
92 views

Newlines are not translated to space within texescape of listings

I try to use the listings package to typeset C code, such that C comments are interpreted as input to \LaTeX. One line comments are easy with texcloption, \begin{lstlisting}[texcl] main(){main();}//\...
1
vote
1answer
40 views

Extra }, or forgotten \endgroup. lstset

I am facing an issue for, nothing yet worked. Yes, the code is okay, it should be good. I reinstalled the complete MiKTeX environment, yet the problem appears. \documentclass{article} \usepackage{...
0
votes
1answer
29 views

Why I got an error while compiling in my list of symbols when I am using Greek letters?

I am writing a list of symbols and acronyms for my thesis using \usepackage[printonlyused]{acronym} and \usepackage{multicol} I have no issues for Latin letters, but when I want to use, for example, ...
0
votes
1answer
34 views

Add dot after number of listing in list of listings

Hello does some of you know how to add leading dot after listing number in list of listings? Im using listings package and \lstlistoflistings command. Im using tocloft package to do it in list of ...
0
votes
1answer
9 views

Text alignment in a \sortedlist environment

I'm using the following command : \documentclass[10pt]{report} \usepackage{datatool} \usepackage{enumerate} \newcommand{\sortitem}[2]{% \DTLnewrow{list}% \DTLnewdbentry{list}{label}{#1}% \...
0
votes
0answers
13 views

Unexpected linebreak in lstlisting environment

The Situation: I'm importing a piece of Code into the document via \lstinputlisting[language=custom]. The Code is formatted in a way, that there are 80 characters in a single line at maximum, so I ...
3
votes
1answer
47 views

How to import text from a text file “AS IS” and justify it?

I would like to import text from a .txt file as is, and have it be automatically wrapped and justified. What I have done so far: \documentclass{article}% \usepackage{listings} \begin{document} \lstset{...
2
votes
0answers
96 views

Code highlight in ltxdoc documentation

I wish to add LaTeX code highlight in a package documentation. Usually I use the following code to highlight LaTeX code (copied from classicthesis documentation): \usepackage{listings} \definecolor{...
8
votes
1answer
189 views

Highlight numbers using listings package

The problem: Is it possible to highlight all the numbers inside a lstenvironment except the numbers in comments, strings or variable names? Example of expected output (Python in Google Colaboratory): ...
1
vote
1answer
34 views

How to add # in emph in lstlisting package?

my current lstlisting package format is provided below. I am not sure why but the # is not displayed as blue but rather as golden. I wish to make it displayed as the colour that is specified in ...
2
votes
1answer
28 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
29 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} %...

1
2 3 4 5
66