Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [lstlisting]

The tag has no usage guidance.

0
votes
1answer
32 views

How to change Figure/Listing/Table names to anything I want (e.g CodeSnippet)? [duplicate]

Anyone knows how to change the Listing name to Code Snippet? \documentclass[bsc]{bangorcsthesis} \title{Mirror, mirror on the Web} \author{Loizos Vasileiou} \date{\today} \degreeScheme{BSc Creative ...
3
votes
1answer
122 views

Python comments not highlighted with lstlisting

I want to use lstlisting for some Python code, and I have a code segment that looks like this: \documentclass[11pt]{article} \usepackage{color} \usepackage{listings} \lstloadlanguages{Python} \...
1
vote
1answer
22 views

add text just before caption number of lstlistings

How can I add a text (i.e., # symbol) just before the number (between label and number, i.e. Listing #1:) in lstlisting caption?
1
vote
0answers
13 views

Passing arguments to longfbox in BeforeBeginEnvironment

I defined a \BeforeBeginEnvironment for lstlisting and added a default \begin{longfbox}[...] definition. What I want is to pass some custom arguments to \begin{longfbox}[...] defined in \...
0
votes
0answers
85 views

Matlab prettifier problem with *

I'm trying to use the matlab-prettifier. Following code does not compile: \begin{lstlisting}[ style = Matlab-editor, basicstyle = \mlttfamily, ] ro=zeros(length(prec),length(prec)+length(h)-1); ...
2
votes
1answer
52 views

Reference lstlisting code by caption/title instead of number

In my LaTeX document I use \ref{code.java} to reference a code as shown in the image below and it shows the section/chapter number. Why it shows "1" instead of code.java? Is it possible to make the ...
0
votes
0answers
45 views

lstlisting basicstyle with color and fontsize

I have a setting of lstlisting as shown below. I would like to change to font size of the listing. I know that I can do that with basicstyle=\tiny or similar, but that loses the basicstyle=\color{...
0
votes
2answers
41 views

Listings: Replace the left out code

Is it possible to leave out some code and mark this, instead of including only parts of the code (which is almost the same)? I would like to have an output almost like the second and third listing in ...
2
votes
1answer
29 views

Using a language dialect in listings

I don't understand why the following document does not compile: \documentclass[letterpaper, 11pt, onecolumn]{article} \usepackage{lipsum} \usepackage{listings} \lstloadlanguages{[11]C++,[ISO]C++} \...
1
vote
1answer
31 views

lstlisting and bold keywords

I have the following MWE for SQL typesetting. What doesn't work for me and for which I need help are two things: I would like to add "SUCH AS" as a keyword (or make it bold in the text without ...
0
votes
0answers
28 views

Title space of List of listings is too small

I am encountering the problem that the space between the title and the actual list is too small no matter what I do. But this issue only exists regarding the list of listings. All other lists (e. g. ...
3
votes
1answer
29 views

How to use \ref Inside lstlistings

How can I use \ref inside lstlisting. I create two lstlistings, e.g. listing1 and listing2. Now, in the third lstlisting, I want to give a reference to them. But when I do, I do not get the ...
0
votes
0answers
42 views

New lines after \ in lstlisting

I have very simple bash listing \begin{lstlisting} $ docker create --name my-nginx \ --network host \ --publish 8080:80 \ nginx:latest \end{lstlisting} It looks fine in PDF, but once I try to ...
2
votes
1answer
44 views

Styling and spacing around float caption for listing

When I use the newfloat package instead of the float package there seem to be some side effects with llncs and/or listings. Case 1: When I use the float package, the float caption of listings is not ...
0
votes
0answers
32 views

How to suggest updates to lstlisting Java keywords?

It seems the listings package does not provide syntax highlighting for the following words in Java: strictfp assert enum var Is there any way to add them manually or somewhere to file a bug report ...
0
votes
0answers
16 views

Caption for lstlisting over n pages

I have a code which is over 3 pages. I wish to caption each page with is caption then something like (Part 1 of 3)... How can I do that? I am using the lstlisting package
0
votes
1answer
31 views

Incomplete \iffalse related listlisting, \textit and \textcolor

I've asked something similar before, but that specific issue has been solved (waiting for comment to be posted as answer as of 2.3.19 18:12 GMT+1). I have a LaTeX code which gives me these errors at ...
0
votes
1answer
44 views

Incomplete \iffalse in specific lstlisting regardless of contents

I have a LaTeX code which gives me these errors at a specific line : Incomplete \iffalse; all text was ignored after line 140. Forbidden control sequence found while scanning text of \write. at line ...
2
votes
1answer
33 views

lstlisting vertical offset at beginning of beamer slide

After having installed the TeX Live 2018 distribution, I observe a previously unseen vertical offset at the beginning of a list, if the list is the first visible object within a beamer slide. I can ...
0
votes
1answer
43 views

How to skip lines in lstlisting with dots? [duplicate]

I am wondering if package listings has a feature that can skip a few lines and substitute them with some dots, to produce something like the following 1 | error_temp = error - ((numpy.linalg.norm(b,...
1
vote
1answer
43 views

how to use accents inside a lstlisting

i know that this answer is a duplicate but the solution proposed to other question doesn't work for me. So, i declared my language and my style and then add a "literate={è}{{\`{e}}}{1}" (or "literate=...
0
votes
0answers
24 views

Can one temporarily suppress a keyword in lstlistings?

I'm trying to write some pseudo code using the lstlisting package. The trouble is that I occasionally want to use the word "for" in statements such as "if x is of the form 2n for some n ∊ ℕ". And that ...
1
vote
1answer
37 views

Editor breaks line within lstlisting

I'm using an editor that breaks lines after a line length of 80 characters. Whenever I use a long lstinline at the end of a line and the editor continues in a new line I get the error message Package ...
0
votes
0answers
40 views

\lstset equivalent for figures [duplicate]

I have some code blocks and captions in my document using lstlisting. I configure these using \lstset and \captionsetup: ... \captionsetup { ... } \lstset { ... } \begin{document} ... \begin{...
1
vote
1answer
19 views

Referencing to figures & sourcecode in appendix (Numbering issue)

during the main part of my paper I reference to the appendix like so: \footnote{\textit{\ref{fig:graphqlSchema} \nameref{fig:graphqlSchema} (S. \pageref{fig:graphqlSchema})}} or so: \footnote{\...
0
votes
1answer
16 views

Wrong index order when using \lstinline in \index

A stub of my document: \documentclass{book} \usepackage[utf8]{inputenc} \usepackage[english]{babel} \usepackage{makeidx} \makeindex \begin{document} \chapter{MyChapter} This is a\index{A} test\...
2
votes
0answers
19 views

How do I keep morekeywords from being highlighted in a comment?

Say I have the following listing style: \lstdefinestyle{custCpp}{ language=c++, keywordstyle={\bfseries}, % keyword color keywordstyle = [2]{\color{blue}\bfseries}, otherkeywords = {...
0
votes
0answers
19 views

Get .prf file from Jetbrains Webstorm and apply it to listings configuration

From the listings doc it is mentioned that I basically can retrieve a Configuration file for the styling of a language from the IDE and apply it as lstset setting: ...settings in an IDE and can be ...
1
vote
0answers
33 views

Roman to Arabic Listing Caption Numbering [closed]

I'm working on my thesis that uses many code listing in it. In each listing, I want to put caption with the chapter number followed by the position of that listing on that chapter. The problem is my ...
1
vote
1answer
25 views

LaTeX lstlisting's style for character literals

As we all know, we can specify the style for string literals in lstlisting by using stringstyle= But in some parts of my code, I have character literals (i.e. when I .Split() some string). And those ...
2
votes
0answers
53 views

Using the % percent sign in lstlisting breaks text coloring

In my lstlisting, If I use a % sign, the highlighting for the rest of the file no longer works. \subsection{Dereferencing pointers} \par When you dereference a pointer, you are going to the memory ...
0
votes
1answer
23 views

How can I style Listing captions the same as Figure captions?

Here is my listing caption format: Here is my figure caption format: How can I format the listing captions to be the same as figure captions? here is the relevant bit from the style file: % Revised ...
7
votes
2answers
178 views

Two lstlistings side by side with refering arrow

SE I am trying to draw the image below in LaTeX using lstlisting, tikzpicture, minipage, and tabular The code that I got so far can be seen below \documentclass{article} \usepackage[utf8]{inputenc} ...
1
vote
1answer
49 views

lstlisting - macro only for specific language

I am currently using following code for G-code formatting. Unfortunately I have no idea how do I enable the macro just for the new "gcode" language. \usepackage{xcolor} \usepackage{listings} \...
2
votes
1answer
26 views

Customize keyword lstlisting

I want to make appear "adriano@ubuntu:~$" in blue but I cannot figure out why this doesn't work. I modified the example from here. Here is my mwe: \documentclass{article} \usepackage{xcolor} \...
3
votes
1answer
36 views

Use same reference count for lstlisting and figure/graphics

I have the following code on overleaf: \begin{lstlisting}[caption={Código inicial para o sistema de arquivos},label={lst:Figura1}] abstract sig FSObject { } sig File, Dir extends FSObject { } sig ...
3
votes
0answers
72 views

Highlighting strings between < and > in lstlistings

The listings package provides the option moredelim, allowing for custom styles for words enclosed by given delimiters. I would like to give <...> an custom colors, however, doesn't seem to work ...
1
vote
0answers
46 views

Strange output of typeset C++ code [duplicate]

I use listing typography C++ code, it performs very well when formatting LaTeX code, but it has very strange character output when used to typeset C++ code. Here is my WME: \documentclass{standalone} ...
1
vote
1answer
78 views

Continuous line numbering in lstlisting, but separate lsttableoflistings entries?

i'd like to use the name=something,firstlinenumber=auto function for continuous line numbering throughout a couple of subsequent listings in my document. I'd also like to have each of the listings ...
1
vote
1answer
70 views

Error to compile lstlisting

I'm trying put this code to tex document: \begin{lstlisting}[caption={Definição dos UUIDs no microcontrolador,captionpos=b] #define SERVICE_UUID "ab0828b1-198e-4351-b779-...
2
votes
0answers
43 views

Underscore and asterisk color in lstlisting string

I have the following code: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{listings} \usepackage[usenames,dvipsnames]{color} \begin{document} \lstdefinestyle{R} { language=R, ...
4
votes
1answer
45 views

Emphasize hex number in lstlisting using font color

I'm looking for a way to emphasize specific names and hex numbers in an lstlisting. Using emph works for names, but not for hex numbers. What did not work Consider the following MWE: \...
1
vote
1answer
81 views

Adjust top and bottom margins using minted

I've been using the listings package with the following setup to produce a compact layout of code samples: \lstset{ basicstyle=\footnotesize\ttfamily,breaklines=true, framextopmargin=50pt,...
2
votes
1answer
38 views

Remove extra space from double quotes in lstlisting environment

I have a book in which I'm using lstlisting for pseudocode. In some cases, I have strings, such as here: \begin{lstlisting} foreach (name in NameCollection) { Print ``Hello, {name}!'' } \end{...
1
vote
1answer
58 views

Changing font color in listing numbers

I want to change the font color in a listing. I want only several lines in the listing to change its color (e.g. 1, 2, 9, 10, 12, 13). That is, I want to apply the color to individual lines of the ...
1
vote
1answer
28 views

Listing in item, how to make the list in the same line with the bullet

I am working with beamer to make slides. When I try to add some code in lstlist inside an item list, the list is always in the next line compared to the bullet, as in the following picture. My code ...
0
votes
1answer
39 views

Priority of page breaks between paragraphs in beamer slides with allowframebreaks

I have breamer slides with allowframebreaks which have some basic structure, e.g.: \begin{frame}[fragile,allowframebreaks]{Title} some text... \begin{itemize}...\end{itemize} other text \begin{...
4
votes
1answer
644 views

Formatting SQL code

I try to format SQL code to achieve at least similar result to this picture : My result: But I can not do that. I struggle with margins, paddings, and numbering for a long time and I already feel ...
5
votes
1answer
140 views

ConTeXt: Is there a way to create multi-page code listings?

I am using t-vim module and I would like to format my listings similar to figures with captions, but with the ability to spread them over multiple pages. I can see three ways to do it: Put the \...
4
votes
3answers
2k views

What font to use for source code in a document? [closed]

I'm currently writing some text where I discuss a python script. So naturally, there's a lot of code in the document and it seems like listings is the default way to do so. However, unlike what I'm ...