{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

1
vote
1answer
369 views

No footnotemark in the listoflistings

I'd like to have footnotes in the caption of listings. I got that working. But the \footnotemark gets shown in the \listoflistings. Normally you can specificly define the text for a caption for the ...
4
votes
2answers
4k views

listings caption number

I'm using the listings package with this \begin command: \begin{lstlisting}[ language=Python, caption={Simple Python Program}, ] This yields a nice code listing with a caption like "Listing 1 ...
8
votes
2answers
411 views

combining listings and tufte-book, listings caption on tufte's margin

I am not very familiar with all latex details, but I'd like to use the listings package in a tufte-book document. However, the listings package places its captions above or below the listing and I ...
10
votes
2answers
2k views

Inline code and short verb with minted

I it possible to use minted for inline code and to add a short verb sing for minted? Like \lstMakeShortInline| in listings.sty? \documentclass{article} \usepackage{minted} \newminted{tex}{} ...
9
votes
2answers
10k views

Defining `lstset` parameters for multiple languages

I am using the listings package, and have defined lstset parameter sets for multiple programming languages. I would like to select a parameter set when beginning a lstlisting or lstinputlisting by ...
6
votes
2answers
1k views

How to make a float that is not labelled 'Figure' but 'Listing'

I would to include my listings as floats, pretty much as Figures, but I don't want to call them Figures. I want to call them listings. How can I do that?
3
votes
1answer
488 views

Strange spacing in inline listings (listings package)

I am using the listings package to typeset some code. I've defined a lstlisting environment, based upon the standard Haskell environment, and added a number of literate replacements, including: ...
4
votes
1answer
466 views

Beamer: How to do src highlighting when src is split with \only<> command? [duplicate]

Thanks to Marc van Dongen there is a template of a "step by step" programming tutorial (with a sample layout in his question): How to create step by step annotated programming tutorial in LaTeX? . I ...
4
votes
1answer
2k views

Color \ , [], {} and / in listings environment

I tried to color a source code listing as follows. I would like the \ to be the same color as the word that follows for example: \documentclass in red including "\" \usepackage in blue including "\" ...
3
votes
1answer
968 views

White horizontal lines in lstlisting

I'm having the following problem: I'm using the listings package to render what is supposed to look like a teminal screenshot. But the background colour is striped. In my other code snippets the ...
6
votes
2answers
725 views

Listings language definition keyword suffixes

I'm trying to create a listings language definition for ARM assembly and many of the instructions have prefixes/suffixes (i.e. BGT, BLE, BNE, BEQ branch instructions). Is there a way to define B with ...
4
votes
1answer
2k views

Can you change lstinline without changing the global lstset?

Consider that I want to be able to write: \inline{some code or keyword} and just have it distinguished from the rest of the paragraph text, I've done that like this: ...
1
vote
1answer
187 views

Combine listings package with my own enviroment [duplicate]

Possible Duplicate: How to use different lstset settings for listings? I have defined my own enviroment as: \newenvironment{codegui}[3]{% \def\tmplanguage{#1}\relax ...
6
votes
2answers
1k views

In listings, lines that are broken (option breaklines enabled) cause frame to be drawn badly. How do you fix this?

I have an lstlisting which has breaklines and frame enabled. The actual setting is as follows. \lstset{ basicstyle=\ttfamily, showstringspaces=false, breaklines=true, keywordstyle={}, ...
3
votes
1answer
973 views

LaTeX Django template custom language for listings

I'm using Listings package to insert python and javascript code into my thesis. This package has a lot of languages but not Django Template. Someone has yet defined that custom language, or there's ...
7
votes
1answer
261 views

How do I get guillemets in a listing?

I'm wondering if it's possible to use guillemets («») in a lstlisting block? I have seen some solutions for including it in the document, but none with the listings package.
8
votes
1answer
988 views

autogobble for lstinputlistings

In the manual for listings it says that gobble has no effect for lstinputlistings. Since the manual is about four years old now and after reading How to automatically skip leading white spaces in ...
0
votes
1answer
453 views

Incorrect page number in List of Listings

The problem I'm having is that page numbers, in a List of Listings, are frequently off by one page. I'm using the listings package and I have a List of Listings in the beginning of the document, ...
6
votes
1answer
596 views

Vertical rule at the left of a listing

I would like to draw vertical rules at a specific location in the left margin of a listing in a listings environment. Is it possible ? ======= PSEUDO EXAMPLE ======= for i in range(5): # One comment ...
6
votes
2answers
1k views

Escaping in \lstinline

There are several options for escaping LaTeX code in the lstlisting-environment. But this doesn't seem to work in \lstinline. I'd like to do something like this: ...
4
votes
1answer
1k views

lstlisting ignores float setting

My document starts with: \begin{document} \lstset{ % language=Java, float=tb } However all listings appear exactly just where they have been defined, e.g. this one: ...
8
votes
2answers
652 views

Attach listing to PDF

I would like to add listings source as attachment to a PDF (created by pdflatex). For \lstinputlisting this is pretty easy: \RequirePackage{listings} \RequirePackage{embedfile} ...
4
votes
1answer
344 views

Using listings for R code with ## in rangeprefix

In R, comments are preceded by the symbol #. Moreover, to avoid messing with the indentation, it's usually ## instead of #. Therefore, as I want to include some R code in a LaTeX document, I am using ...
3
votes
1answer
213 views

Is there a way to tell listings what to do immediately after escaping?

What I want to do is having two or more possibilities when escaping from normal code formatting. For instance, if I give the option escapechar=\⠶ I would like to avoid saying something like this: ...
6
votes
1answer
4k views

Colored strings by listings package

I'm trying to type my C++ homework by LaTeX in order to prepare it as a pdf file. I want to have my keywords in blue, my numbers in violet and my strings in reddish brown. I could do the two first by ...
5
votes
1answer
1k views

Showing only specific lines using the listings package

I am very new to TeX. My source code is in an external file, let's call it source.java, and I use \lstinputlisting{source.java}. How could I use only the lines 3-5 for my code listing? (and not the ...
0
votes
0answers
43 views

I cannot get an image and `lstlisting` aligned in a table [duplicate]

Possible Duplicate: How to align picture top left in a table? I want to display an image and some lines of monospaced text with line breaks (as far as I know, lstlisting is the only ...
4
votes
1answer
542 views

remove unwanted contents from list of listings

The following code adds a wrong line to the list of listings \documentclass{scrbook} \usepackage{listings} \usepackage{filecontents} \begin{document} \begin{filecontents*}{democodefile} ...
3
votes
1answer
360 views

Sync listings caption numbers and add all to List of Listings

I want to create a list of all listings. Listings itself allows to add captions and list them in a list using \lstlistoflistings, but they can not float. If I set up such a floating environment using ...
4
votes
1answer
578 views

lstinline loses braces when used as an argument to another command

I'm using the listings package, for the Java language (which, as all C-like languages, uses braces as a block delimiter). I intend to use \lstinline{...} as the second argument to a command for ...
5
votes
1answer
543 views

How to define macro that only makes argument substitution?

I am having some problems when I define a macro whose content has the lstlisting environment. For example, (assume ! is the escape char inside the lstlisting environment) \def\mycode#1{ ...
4
votes
1answer
1k views

Custom line numbers in lstlisting environment

I am using the lstlisting environment to display code and it works great, however for my current application I need something like: line 1; 3.1: line 2; line 3; 3.1.5: line 4; ...
2
votes
1answer
913 views

Using “listings” package to colorize the source code of ANTLR grammar file?

I use listings package in my diploma thesis for source code. Besides the mainstream languages like Java and C# I also need to include the sources of the language grammars (.g) which are pure mark-up ...
8
votes
1answer
928 views

listings bug: space after literate replacement lost with spaceflexible/fullflexible columns

Problem with space being lost in listings immediately after a literate replacement when using columns=spaceflexible or columns=fullflexible (appears correctly with columns=flexible). A small example ...
3
votes
0answers
105 views

listings bug: space after quote collapsed when inlined with spaceflexible/fullflexible columns [duplicate]

Possible Duplicate: listings bug: space after literate replacement lost with spaceflexible/fullflexible columns I seem to have stumbled upon a minor bug in listings (version 1.4 as of ...
13
votes
1answer
2k views

Manual highlight of TeX code in a verbatim environment

Friends, I'm stuck with a unusual situation: I'm trying to highlight specific words of a TeX code inside a verbatim environment. I know listings can help me by defining a set of keywords, but in this ...
2
votes
1answer
360 views

Latex Listing Format Error

I'm having some difficulty with getting the listings package to properly format code snippets. In particular, it does not consistently bold keywords and italicize comments. The code I am currently ...
5
votes
1answer
1k views

Remove top and bottom margins around listings

When using the lstlisting environment, or similar ones from the listings package, there are paragraph-like margins above and below the actual text. This makes sense in a paper, but gets in the way if ...
10
votes
1answer
501 views

Draw comparison lines between two listings

I have a LaTeX code set up as so: \documentclass[a4paper,10pt]{report} \usepackage[utf8]{inputenc} \usepackage{fullpage} \usepackage{listings} \usepackage{graphicx} \usepackage{float} ...
4
votes
1answer
4k views

Define a new caption in a listing environment

I want to have different listings with different types of captions, consider that I've got the following: \documentclass{article} \usepackage{listings} \usepackage{color} \usepackage{caption} ...
10
votes
3answers
1k views

Avoiding “minus sign” dash in listings commentstyle

Is there a general way to get listings package to typeset a hyphen as a minus character in the rest of the code (the default behavior), but typeset a hyphen as a true hyphen if it occurs in comments ...
4
votes
1answer
681 views

How to color digits with the listings package

For my project, I've been using the listings package in order to color the keywords, comments, strings, and digits in the code. The thing is, I've managed to color the keywords, comments and strings, ...
3
votes
1answer
197 views

Problem with listings-ext [closed]

I am using listings-ext on Ubuntu 11.10 (with LyX) and listings.cfg defines the style colored-code - which I also use in the LaTeX preamble: \usepackage[style=colored-code]{listings-ext} But ...
7
votes
1answer
1k views

Problem with underline in listings

I want to underline some code in my source code included using listings. I did the following but the underline is including the white space before the statement. How could I do it so that it only ...
9
votes
3answers
3k views

Typesetting UTF8 listings with German Umlaute

I'm having some issues with listings that include German Umlaute. The following example code generates a completely messed up PDF. \documentclass{article} \usepackage[utf8]{inputenc} ...
4
votes
1answer
93 views

Handling Truncated Listings

I included some listing in my document using the listings package but some of the lines are rather long and are being truncated. How do I best handle this issue?
8
votes
2answers
1k views

Full width code listing within two column text

I am using multicols to create two columns for body text. For code typesetting I am using the listings package. For the latter I have created an environment using \lstnewenvironment command, used as ...
12
votes
1answer
2k views

How can I pass underscore to \newcommand properly?

I'd like to simplify my code appendix with this command definition: \usepackage{listings} % ... \newcommand{\CodeListing}[1]{% \lstinputlisting[caption=#1]{#1}% } That is, the caption should be ...
4
votes
1answer
348 views

Using LaTeX listings throughout the document

I've got a LaTeX document with a main file and many sub-files. Because we're writing a documentation we use code snippets everywhere. How can I define a listing and use it throughout the documents? ...
7
votes
1answer
390 views

How can I prevent lstlisting with shadowbox-style to be split?

I have my listings styled with frame=shadowbox. In some cases the lower or upper border of a listing appears on the previous or next page (see screenshot). I do not wrap the listing in a minipage ...