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.

1
vote
0answers
19 views

TiKZ arrows and text inside of lslisting code

I have some lslistings code and I want to add some text and math elements as is shown in red color in the image below I tried using TiKZ but I got many errors. I'm attaching a MWE and thanks in ...
0
votes
0answers
9 views

Include a listing but set the caption in the enclosing file

I have a document with many large listings. To keep things organised I'd prefer to keep these listings in separate files and using \input in the appropriate location in the text. However, I'd also ...
0
votes
1answer
25 views

Problem with lstlistings inside tcolorbox

i have defined my new command: % sets for lstlisting \lstset{ basicstyle=\small\ttfamily, columns=flexible, breaklines=true, frame=single, rulecolor=\color{colorCodeBorder} } \newcommand{\mynote}[1]{...
1
vote
1answer
25 views

Inline listing shortcut

I have defined the following abbreviation for inline listings: \newcommand{\lsin}[2]{\lstinline[columns=fixed]{#1}} but when I use this as "\lsin{SELECT} clause...", it eats up the space after it as ...
0
votes
0answers
24 views

Missing { inserted when using an lstinline inside a multicolumn of a table

The following code does not compile \documentclass[12pt]{article} \usepackage{listings} \begin{document} \begin{table}[] \centering \begin{tabular}{l|c|c|} \cline{2-3} ...
0
votes
0answers
23 views

Keep automatic numbering in listings [duplicate]

I have the following MWE \documentclass{article} %-> Package for font (and other elements) color: \usepackage{color} \definecolor{semigray}{gray}{0.5} %-> To hyphenate long url addresses: ...
2
votes
3answers
35 views

How to insert text with special characters and automatic line breaks

I want to insert a Readme file into my latex code, which contains some special characters. First i tried to use a verbatim environment, but this did not work because there were no automatic line ...
2
votes
1answer
29 views

Define Code block macro based on tcblisting

I want to define a code block macro that is used like this: \begin{codeblock}[bash] # This is a comment sudo apt-get install texlive \end{codeblock} or even better: \codeblock[bash]{ # This ...
1
vote
1answer
17 views

Why is identifierstyle used for lstlisting with no language?

Here is my code: \documentclass{article} \usepackage{xcolor} \usepackage{listings} \lstset{ keywordstyle=\color{blue}, identifierstyle=\color{red}, } \lstnewenvironment{algol}{\lstset{...
5
votes
1answer
58 views

Color text inside lstlisting

So I've been looking for a way to color text inside a lstlisting. There are already several questions answere. E.g. here: How can I highlight some lines from source code? All solutions I've found ...
7
votes
1answer
58 views

Why doesn't \lstset{escapeinside={((}{))}} work as expected?

Here is my code: \documentclass{article} \usepackage{listings} \lstset{basicstyle=\ttfamily,columns=fullflexible} \begin{document} \lstset{escapeinside={((:}{:))}} \begin{lstlisting} foo ((:\textit{...
2
votes
0answers
24 views

How to display vertical lines at indents in lstlisting?

I want to display vertical lines in indentations. I already found this thread: Lstlisting and indentation lines, but it isn't what I want. This is how my attempt looks like: This is how I want it to ...
0
votes
2answers
24 views

lstinputlisting makes giant whitespace [closed]

I am using the Astronomy and Astrophysics template and want to add code at the bottom in a single column appendix. I have tried this by doing this. \onecolumn \appendix \section{Software use ...
0
votes
0answers
30 views

lstlisting inside itemization

I need to have \lstlisting inside an itemization. I have the following code but as you will see from the output, the listing starts on the line following the item label. Is there anyway to get it on ...
0
votes
0answers
46 views

Caption setup for package Minted

When using minted, the spaceing below and above the code is too high. In comparsion when using a new created environment (mintedlisting) with the package caption, the spaceing seems to be right but ...
3
votes
1answer
58 views

Part of words that contains key word in lstlisting environnement

I have made a definition for a language. The problem that I have is when a word contains a key word, the "key word" part of the word is displayed in color There is the MWE : \documentclass[11pt]{...
0
votes
1answer
29 views

Is there a lstset for the latex language itself

I would like to have a bit of latex code inside my pdf. I am using lstlisting by having hard time asking the right question to my search engine as request like "lstset for latex" obviously do no give ...
0
votes
1answer
37 views

Error with lstlisting environment

currently I have a problem with the lstlisting environment. Every time I try to include this to my LaTeX document, the compiler stuck at the point "C:/Users/xxxx/AppData/Local/Programs/MiKTeX 2.9/tex/...
0
votes
1answer
30 views

lstlistings with with different languages and diffrent keywords

\lstdefinelanguage{RIPE} {% sensitive=t,% morekeywords={inetnum, netname,descr, country, admin-c, tech-c, status, mnt-by, notify, created, % last-modified, source, person, address, phone, e-...
0
votes
1answer
34 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 ...
2
votes
1answer
275 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
28 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
16 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
101 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); ...
3
votes
1answer
122 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
169 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
42 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
64 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
57 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
34 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
46 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 ...
1
vote
1answer
62 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
36 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
17 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
33 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
58 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
37 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
71 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
50 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
27 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
45 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
41 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
22 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
17 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
25 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
25 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
38 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
32 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 ...
1
vote
0answers
76 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 ...