{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.

learn more… | top users | synonyms

0
votes
1answer
22 views

Error in listings demo code [on hold]

I copy and paste code from https://www.sharelatex.com/learn/Code_listing \begin{lstlisting} import numpy as np def incmatrix(genl1,genl2): m = len(genl1) n = len(genl2) M = None #to ...
0
votes
0answers
26 views

Define listings language with multiple keyword groups

I wanted to used syntax highlighting for a language unsupported by the listings package. Right now I have it almost working, but not completely. This is the MWE: \documentclass{article} ...
2
votes
0answers
24 views

Warning: uncodable character in LyX lstlisting

The problem I'm trying to insert the output of the tree command into a Program Listing field of LyX. The text is the following: exampleFolder/ ├── 01.mp4 ├── 02.avi ├── 03.mov └── 04.mpg If this ...
2
votes
2answers
38 views

List of listings similar to list of figures

After learning on the net I managed to get this type of list of figures : And I want exactly the same with the list of listings, but here is what I get : My code is this one : ...
2
votes
1answer
34 views

Make listing a floating image

I have used the listings package for including a program into a LaTeX document. But the program splits into two when a page is finished. I want to make the listing behaved like an image, so that it ...
0
votes
0answers
15 views

\end tag ignored in frame [duplicate]

I have the following slide in a document of class beamer. \begin{frame}{Modular Design} \begin{lstlisting} <code> \end{lstlisting} \end{frame} This however returns these ...
1
vote
0answers
27 views

Do not apply literate option in comments

I defined my own programming language using listings and, to do so, I had to use the literate option a lot in my definition. For example, to make parentheses bold and green, I did this: ...
0
votes
0answers
19 views

Keep lstlisting together with preceding paragraph (like formulas)

I have several listings that are only 2-4 lines long. They should be kept together with the preceding paragraph, like it is the default for formulas. For example, lets assume the following code and a ...
3
votes
1answer
12 views

Reference to \lstnewenvironment

\documentclass{scrreprt} \usepackage{regexpatch}% http://ctan.org/pkg/regexpatch \usepackage{color} \definecolor{codecolor}{rgb}{0.8,0.9,0.9} \definecolor{chatcolor}{rgb}{0.9,0.9,0.8} ...
2
votes
1answer
14 views

lstnewenvironment argument across multiple lines

Hey I am using code bellow to create custom lstnewenvironment, it all works fine if I have \begin{test}{caption}{lst:label} on one line. If I break it in any way for example \begin{test}{Some ...
2
votes
1answer
24 views

Changing the line number in code listing

Below is how the code listing looks like now: I want to change line number 8 to blank, and line number 9 to 10. Reason is that they are actually two lines at ... (at line 8), how should I do that? ...
3
votes
1answer
26 views

Adding a caption to a tcolorbox \tcblisting

I'm new to the whole TeX world and have finally managed creating my own tcolorbox code box: Now I would like to caption my code boxes like regular listings. It should say something like ...
2
votes
1answer
31 views

Why does using a lstset option in usepackage command make pdflatex not terminate?

Question Why does passing a wrong (as in non-existing) option to listings upon package loading result in a non-terminating pdflatex run, instead of - say - a simple error message? Background ...
0
votes
0answers
24 views

How to type set with the same font in code listing?

In text I have use \emph{chkFlag}, and it looks like this I hope to typeset chkFlag with the same font in code listing as follows: What is the correct command should I use?
1
vote
0answers
18 views

line breaks and word wraps for unpredictable character strings

I am writing python to parse and process lots n lots of files to build a final report of results from information in the files. I am using python to write the latex file, then converting the latex ...
2
votes
0answers
32 views

Automatically colour previously defined strings of text (for strings with spaces &/or punctuations) [duplicate]

Main question Answers to the question Automatically colour previously defined strings of text show how to colour pre-defined strings of text, but all those pre-defined strings are without spaces and ...
1
vote
1answer
27 views

Different Style of captions

I am writing a document where I have different types of figures like tables and listings. To get the captions the way I want I wrote the following in the preamble: \usepackage[font=small, ...
1
vote
1answer
20 views

How can Listings ignore (some) indentations?

I am trying to explore writing a .tex in a 'indentation' style, like this: \documentclass{article} \usepackage{listings} \begin{document} Hello latex! \begin{lstlisting}[language=python, ...
1
vote
1answer
21 views

Cannot include courier into latex beamer listings

I have the following set up for my listings: \documentclass[russian,pdf]{beamer} \mode<presentation>{} \usepackage[T2A]{fontenc} \usepackage[utf8]{inputenc} \usepackage[russian]{babel} ...
2
votes
1answer
31 views

enclosing a lstlisting environment inside my own environment using matlab-prettifier

I've just started using matlab-prettifier. Since the line \begin{lstlisting}[style=Matlab-editor] is a lot to type, I created my own environment: \newenvironment{myMP} ...
1
vote
1answer
20 views

listings - How to format words of a external code file under a condition

I'm using listings to put a external code file in my document. I'm trying to customize its appearance to identify when the first character of a word is a digit and then change the color of this ...
2
votes
0answers
31 views

How to justify escaped proportional text inside monospaced/fixed listing?

I have a fixed column listing on which I have escapped to LaTeX to write a proportional bit of text. The following pic illustrates what I have: On the green box, the proportional text have ...
1
vote
1answer
25 views

Cannot emphasize underscored words in listings

I declared an emphasis mode that underlines and colors words in red, as follows: \lstset{columns=fullflexible,basicstyle=\vttfamily,emph={\color{red}\underline}} However, when using it in a ...
2
votes
0answers
30 views

How to put the caption below the listing? [closed]

When I use a simple caption, tex puts it above the listing \begin{lstlisting}[caption={My Caption}] \end{lstlisting} If I use \captionof, caption goes below the listing, but paragraph for next ...
3
votes
1answer
34 views

Higher Asterisks in lstlisting environment

The project I'm working on right now is a general template for documents that will contain code from an arbitrary programming language. Specifically, I'm trying to make a nice layout for code in the ...
0
votes
1answer
21 views

Determine if inside \lstinline or ordinary lstlisting environment

My editor requires me to have a non-white background in my code listings. In order to make my code listings look nicer, I use the literate setting of listings to change underscores (which are very ...
4
votes
1answer
27 views

Lstlisting duplicate caption

I've been trying to insert the code to my LaTeX document. I used this piece of code: \begin{lstlisting}[label={lst:rws}, captionpos={bottom}, caption={Pseudo-code of RWS Selection}] r = Random(); /* ...
4
votes
1answer
30 views

How to force \lstinline to add a line break

I have an inline piece of code in my main LaTeX document that I have included using the \lstinline command: \lstinline{template<class UIntType, UIntType a, UIntType c, UIntType m> class ...
3
votes
1answer
30 views

Textcase, Listings, and Tilde

Consider the following MWE: \documentclass{scrreprt} \usepackage{textcase} \RequirePackage{listings} \usepackage[american]{babel} \begin{document} \MakeTextLowercase{A~B} \end{document} ...
4
votes
0answers
40 views

Exception from code syntax highlighting in listings

EDIT: The question is not really relevant for me any more, I decided to instead use the highlight package in R to export Code as LaTeX output. This still requires manual modifications, but at least I ...
1
vote
1answer
22 views

change caption of multiple listing styles

I want to have different listing environments, each with an own caption. My try was this (vorlage.tex): \documentclass{scrreprt} \usepackage{regexpatch}% http://ctan.org/pkg/regexpatch ...
2
votes
1answer
45 views

Conflict with unicode-math and listings

\documentclass{article} \usepackage{unicode-math} \usepackage{listings} \usepackage{fancyvrb} \begin{document} \lstset{fancyvrb} \begin{Verbatim}[commandchars=\\\{\}] \pm \end{Verbatim} ...
2
votes
2answers
45 views

Universal numbering for figures and lstlistings [duplicate]

I use ShareLaTeX for my thesis and I am facing a problem. I have used the following code to change figures' name to "Εικόνα" and lstlistings' name to "Εικόνα" too. ...
3
votes
0answers
34 views

Using the same line numbers in lstlisting on repeated beamer slide

In the following example, the line numbers on the second occurrence of the slide start from "3". But the references in the itemize item of the second occurrence of the slide show as "1" and "2" (i.e. ...
1
vote
1answer
98 views

How to prevent page break between listing caption and code?

How to prevent page break between listing caption and code (see the picture)? Minimal example illustrating issue: \documentclass[a4paper, 12pt, oneside]{report} \usepackage[a4paper, left=3.5cm, ...
0
votes
1answer
26 views

custom listof not in content

This is the initial part of my thesis: \documentclass[12pt, a4paper, openright]{report} \usepackage{amsmath,amssymb,amsthm} \usepackage{graphicx} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} ...
0
votes
0answers
22 views

matlab-prettifier with fancyvrb-style of label / frame

I wonder how to make the frame line around caption of listing not being printed (top line being broken into two by caption in the middle) when matlab-prettifier (or listings package) are being used, ...
2
votes
1answer
20 views

listings breaking line despite breaklines=false

For some reason the listings package is breaking lines in the minimal working example below despite the fact that the breaklines=false option is set. \documentclass{article} \usepackage{listings} ...
2
votes
1answer
54 views

listing background color not exactly the same

I like SO code section colors. so I wish to use it as code listings box background color. I use a screen capture tool to capture the code background color to png, then use GIMP tool to check the RGB ...
3
votes
1answer
61 views

Listings & unicode characters

I want to write some unicode characters to lstlisting environment but they are displayed inline in the output which isn't what I am expecting. How can I make it work like standard characters? Thanks. ...
0
votes
1answer
15 views

Excessive space in lstinline after using Reactivatenumber

I'm using the code presented by this answer (which itself is based on this) to suppress line numbers on some lines in lstlisting. This works, but after I use it, the spacing in lstinline is messed up: ...
2
votes
1answer
36 views

Using lstlisting with T2A

I would like to display a code listing using the package listings. It all work nice, except if I had the fontenc T2A. When I do, the listing stop being displayed using \ttfamily font and is shown ...
2
votes
0answers
49 views

How to prevent parts of source from being automatically indented? [closed]

EDIT Rephrased question to be more abstract and less specific to only fragile-frames. Context: While recompiling a presentation, the process halted with err-msg file ended while scanning use of ...
7
votes
1answer
51 views

bold just one line inside of lstlisting

How can i bold just one line in this code? \begin{lstlisting} //Algoritmo 2 int f2 ( n ): local i , j , r =0; para i = 1 a n -1 para j = i +1 a n r = r + 2; ...
0
votes
0answers
25 views

Listings package does not break with my own class

I have created a class based on the article class so: \NeedsTeXFormat{LaTeX2e} \LoadClass{article} \RequirePackage{../../mypackage.sty} According to that, I have done following example document: ...
1
vote
0answers
48 views

XeLaTeX - special unicode characters

I found that work with unicode characters is a lot easier using xelatex than pdflatex, therefore I'd like to use it. Most of the content is displayed correctly but I have a problem with some special ...
2
votes
0answers
29 views

Spaceing Issue with listings

I am having a bit of trouble putting python code into a latex document using listings. The code is appearing with a large indent on the left so that it has to go onto multiple lines. Here is an ...
2
votes
2answers
39 views

How to set thickness of rounded frame in listings?

I'm using listings package for source code listings in my master's thesis. How to set frame thickness for lstlisting environement when frameround is set to tttt? When frameround is other than nnnn, ...
3
votes
1answer
42 views

listing title under itemize exceeds page width

I want to put listings under enumerate environment. For the lstlisting title's background color i took from this post. However, after putting the lstlisting under item, the title with colored box ...
1
vote
1answer
28 views

Give side by side minipages one (shared) caption instead of two

I have two lstlisting areas that are shown side by side by using two minipages: \noindent\begin{minipage}[t]{.43\textwidth} \begin{lstlisting}[...]{part1} // Code \end{lstlisting} ...