{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

10
votes
2answers
213 views

Including sections of source code as a listing, while being robust to source code edits

Is there a way to input particular sections of source code using \lstinputlisting (from the listings package) in a flexible way? It's possible to use the firstline and lastline options to input ...
1
vote
1answer
806 views

Pointing to Java files not in root latex folder using listings

I am trying to use listings to point to a Java source code file. The file path is different from the Latex document. Below is an example of what I am trying to do, though it doesn't compile it says it ...
4
votes
1answer
263 views

Getting listings to highlight Func<x,x,x>

Given this image: How would you create a lstdefinelanguage that would make Func<double, double, double> highlighted without having to add spaces after each comma? \documentclass{book} ...
8
votes
1answer
651 views

Cleveref can't refer to line numbers in listings

Consider the following minimal example: \documentclass{article} \usepackage{listings} \usepackage{cleveref} % \crefname{lstnumber}{line}{Line} \begin{document} % \section{Section} ...
2
votes
1answer
581 views

captionof{lstlisting} Listingsnumber not in caption shown

Hi there having another problem. In the following Minimal Example a listing with captionof doesnt show the Listings Number in the Caption :( \documentclass[ 11pt, % Schriftgröße DIV10, ...
0
votes
0answers
54 views

Add keyword to a lstlisting language [duplicate]

Possible Duplicate: Extend a language with additional keywords? I'm using the package listings to write some Scheme code. I setted: \lstset{language=Lisp} since "Lisp" is the most ...
2
votes
1answer
640 views

The whitespace character in listings [duplicate]

Possible Duplicate: Explicit space character? The listings package by default replaces spaces in (for example) strings with a strange underscore style thing, almost like a square bracket ...
7
votes
1answer
914 views

Remove the header of List of Listings

I'm using classichtesis and I would like to remove the header of List of Listings. Before posting here, I tried the following strategies: The command \renewcommand\lstlistlistingname{}, suggested ...
5
votes
2answers
644 views

Position tikz pictures at left margin of a listing code block

I'm trying to finish my attempt at having good looking unlimited line annotations for the listing environments, using tikz. The original problem was that indentation caused shifts in the positioning, ...
8
votes
1answer
3k views

x86-64 assembler language dialect for the listings package

I'm writing a paper with a lot of x86-64 code listings in it. Unfortunately, the listings package itself does not have support for x86-64 instructions and register names (which are just named ...
8
votes
3answers
1k views

Problems with copy and paste from PDF using lstlisting

I'm using lstlisting to create course notes from which I am hoping that code can be copy&paste'd I've already implemented the suggestions in Phantom spaces in listings (pdf) to make sure that ...
3
votes
1answer
2k views

LyX Error: Could not find LaTeX command for character '' (code point 0x2009)

I have been trying to copy and paste some code into LyX (via the 'Program Listings' menu item), and when I compile the document I get the LyX error: Could not find LaTeX command for character '' ...
6
votes
2answers
396 views

How to add numerical (ala No Starch Press) listing notes without XeTeX?

I've been following the instructions and code available at: https://zuttobenkyou.wordpress.com/2010/12/05/latex-saner-source-code-listings-no-starch-press-style/ I would like to add notes (and style) ...
6
votes
2answers
682 views

How to highlight all identifiers starting by '@'?

I would like to highlight any expression made of letters and that starts with one @. The use of moredelim=*[s][\color{blue}]{@}{\ } works only in case like @name is followed by one space. The ...
0
votes
1answer
317 views

listings package-Problem with formatting the parenthesis [duplicate]

In the following code, I've one problem with the formatting of closing parenthesis. I don't know why. I give this long testing and uggly code because with smaller ones I've no trouble. ...
5
votes
1answer
581 views

Shared line counter with \lstinputlisting

Using the listings package, you can name your listings to make them share a line counter: On the other hand you can use firstnumber=auto and name your listings. Listings with identical names ...
6
votes
3answers
783 views

Different background colors for lstinline

In the following code, I've decided to use the code from Colored background in inline listings so as to redefine \verb to have the possibility to use colors for the text and the background of the ...
8
votes
3answers
3k views

LaTeX techniques and templates for writing a book [closed]

I am about to write a couple of books using LaTeX. I am fairly used to producing small LaTeX articles using Sweave and R, but I have never written a book using LaTeX and I am not conversant with the ...
1
vote
0answers
64 views

Listings remove single quotes after I made it look good [duplicate]

Possible Duplicate: Listings package not correctly showing PHP strings So I've used this code for my listings. However it seems to ignore single and double quotes and everything inside them ...
0
votes
0answers
75 views

Showing listings of code side by side error [duplicate]

Possible Duplicate: How can I put lstlisting block into subfloat block? Running this code gives me an error that ! Paragraph ended before \lst@next was complete. \begin{figure} ...
2
votes
2answers
914 views

adding keywords to be highligted in the lstlistings

The recent version of C++ has added a some new keywords e.g. decltype etc.. I want to highlight them in my report. I saw this post but it didn't work for me. Extend a language with additional ...
1
vote
1answer
58 views

Command for Package feature Demo (listings problem)

I have to write a small demonstration of some features of my package. I was thinking about doing something like: \documentclass{article} \usepackage{listings} \newcommand{\demo}[1]{% \fbox{ ...
4
votes
1answer
705 views

Avoid comment style for URLs in code listings

I using the following settings for code listings. \usepackage{listings} \usepackage{textcomp} \lstset{language=Java, keywordstyle=\color{RoyalBlue}, basicstyle=\scriptsize\ttfamily, ...
6
votes
1answer
5k views

Adjust bottom margin of a listing environment

I use the following settings for code listings. \usepackage{listings} \usepackage{textcomp} \lstset{language=Java, keywordstyle=\color{RoyalBlue}, basicstyle=\scriptsize\ttfamily, ...
0
votes
0answers
44 views

Prevent listings grouping together [duplicate]

Possible Duplicate: Keeping tables/figures close to where they are mentioned I'm writing a document with a large number of code listings. Most of the time I want them to be shown on the ...
4
votes
1answer
147 views

symbol “-” not shown in any of “listings” after compiling together with “breqn” package

After compiling my "-" symbol in every single listing environment dissapears. I found out that "listings" package must somehow conflict with "breqn" package. Below is a minimal working example. Try to ...
3
votes
0answers
615 views

lstlisting: how to color numbers in code [duplicate]

Possible Duplicates: How can I change the color of digits when using the listings package? Listings package: How can I format all numbers? How to color digits with the listings package ...
4
votes
1answer
653 views

\thelstlisting undefined for nostarch

I'm trying to get nostarch working and it won't even get out of the gate. I'm just a lowly user so these kinds of errors leave me quite clueless. The sample doc in the distribution nssample.tex ...
8
votes
2answers
1k views

\prevdepth error with mdframed and listings

I get strange errors with the last versions of mdframed (v 1.4) and listings (v 1.4). Here is a minimal example: \documentclass{minimal} \usepackage{mdframed} \usepackage{listings} \begin{document} ...
3
votes
2answers
2k views

Why doesn't \newline work inside lstlisting?

I am new to LaTeX and am using a template provided by a friend: \subsection{P2P library} The library is implemented in C-Sharp and provides two basic facilities - maintaining a member list at every ...
10
votes
1answer
793 views

How to extend the \lstinputlisting command

With the answer from autogobble for lstinputlistings I've managed to create a command that gobbles \lstinputlisting and makes firstnumber to start by firstline. I would like to rewrite it as a ...
2
votes
0answers
74 views

Sources to be copied from PDF [duplicate]

Possible Duplicate: Phantom spaces in listings (pdf) I would like to create PDF using luatex and it's important that listings where copied from this PDF in the original form (to keep them ...
8
votes
2answers
3k views

\lstinline!Foo! vs \lstinline{Foo}

I wonder what is the difference or correct usage of \lstinline!...! and \lstinline{...}? I like better {} because I feel there it's more consistent with other commands but for example in below ...
10
votes
4answers
906 views

Pretty-printing LaTeX syntax with lstlisting environment

I would like this: \begin{lstlisting} \mymacro[<optional argument>]{<mandatory argument>} \end{lstlisting} to generate output like this: I've made a couple attempts at this, but ...
5
votes
1answer
253 views

Is it possible to embed source code in a regular text with “listings”?

I want to write something like In order to avoid a RuntimeException where RuntimeException appears with a code font. I've tried something like \begin{lstlisting} In order to avoid a ...
3
votes
1answer
626 views

Problem defining a new command using lstinputlisting

I am trying to define a new command to easily insert SQL queries (from a file) on my document. I define it like that \newcommand{\sqlfile}[2]{\lstinputlisting[language=SQL, caption={#1}, ...
1
vote
3answers
2k views

lstlisting with c++: spaces around scope resolution operator

I am having a hard time to make the output of lstlisting for c++ source look good. Currently, I am stuck with a problem to reduce the amount of space around the scope resolution operator ::. See the ...
5
votes
1answer
2k views

cleveref + listings

\documentclass{scrbook} \usepackage{listings} \usepackage{cleveref} \begin{document} Ref: \ref{test}. Cref: \cref{test}. \begin{lstlisting}[caption={Test},label={test}] test \end{lstlisting} ...
4
votes
1answer
694 views

Listings with rule above caption to look like \floatstyle{ruled}

I am using the listings package. I would like my listings to have a heavy rule above the caption, so it looks like the \floatstyle{ruled}. So it would look like: a bold line === caption ...
1
vote
1answer
620 views

How to use example code (of any language) and reference it?

How to use Java or any code in LaTeX and refer it in my document?
6
votes
1answer
1k views

Scala support in listings package

As far as I know, the Scala programming language is not supported by the listings package. Is an implementation under way? Will it be included in the standard listings distribution?
2
votes
2answers
123 views

A macro that behaves like a font-changing command (affects the rest of the current group)

Many LaTeX packages provide an interface to modify the typesetting of certain elements with the standard "parameterless" font commands, such as \bfseries, \sffamily or \color{red}. All of these ...
10
votes
1answer
2k views

Remove keywords from code 'listings'

I tried to customize a code listing to support some pseudo-code format that suited me best. It was easy to add keywords using otherkeywords or morekeywords, but the opposite, the deletekeywords did ...
17
votes
1answer
1k views

In the minted package, how do I enforce straight single quotes?

Basically I want \mint{python}|'banana'| to produce straight single quotes, rather than the curly ones it normally produces (in pdflatex).
1
vote
1answer
374 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
419 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?