{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

5
votes
1answer
298 views

How to share a counter for a subfloat

I am trying to make a listing float containing 3 subfloats. I have managed to to make the actual float by combining the answers from question1 and question2. Now I only need to make mylisting use the ...
5
votes
1answer
670 views

avoid linebreak in \lstinline if possible

By using \lstinline{mysourcecode} I put some code within my document. I would like to avoid that this code is broken to a new line, if possible. so, if the codeline itself is less long than a full ...
7
votes
1answer
594 views

C preprocessor commands in listings package

I am using the listings package, which is mostly formatting things nicely. However, it fails to syntax highlight indented preprocessor commands correctly. For example, \documentclass{article} ...
4
votes
1answer
843 views

Highlight certain texts in listings or minted [duplicate]

Possible Duplicate: Manual highlight of TeX code in a verbatim environment I want to highlight certain parts of a program output listing which represent user input. For example I want to ...
0
votes
0answers
73 views

My lstlisting environment only shows “2” above the first line, instead of numbers before each line, when Hebrew is enabled [duplicate]

Possible Duplicate: backgroundcolor in lstset does not work I've recently changed my document skeleton and now my code segments, defined with \begin{lstlisting}...\end{lstlisting}, changed ...
4
votes
1answer
1k views

How can I get lines to break automatically using the LaTeX listings package?

I am using the listings package to include sample Perl source code in LaTeX. I included the package with \usepackage{listings}, and used the following code: \lstset{language=Perl} ...
6
votes
3answers
438 views

Invisible listing captions

Short version: how can I make a listing's caption show up in the List of Listings but not in the body of the document where the listing is? I'm writing a university report, and many of my subsections ...
3
votes
1answer
7k views

Package listings: Error “Undefined control sequence.” because of single-quote-symbol?

I'm using the package listings and came across a problem displaying an SQL statement within an java environment. This is the MWE. \documentclass[]{report} \usepackage{listings} ...
0
votes
1answer
229 views

\afterpage issue with \lstlisting

I have issue with \afterpage command and \lstlisting, it's add one blank page after beginning code listing, and after blank page is two of my command. \appendix \section*{APPENDIX A} ...
3
votes
1answer
873 views

Strange character when using listings package

I'm seeing an odd character like a very flat U, where there should be a space, with the listings package. See example below. Does anyone have any idea why this is happening, or how to get rid or work ...
7
votes
1answer
1k views

Set font in listings in XeLaTeX

I want to set specific font just for listings in XeLaTeX. \newfontfamily\consolas{Consolas} \lstdefinelanguage{MyLanguage}{ basicstyle=\ttfamily, .... % my language definition } ...
6
votes
1answer
2k views

Is there a good definition for highlighting PHP code in listings?

Does someone have a good definition for highlighting PHP code with the listings package?
7
votes
3answers
719 views

An environment for writing regular-font pseudocode

I want to create a pseudocode environment that looks like this: Basically, the font doesn't change - it's just the same as that of the surrounding text. It allows mathmode. And there is a box ...
3
votes
1answer
4k views

\usepackage{caption} breaks references to tables

I'm formatting the listings captions as follows: \usepackage{caption} \DeclareCaptionFont{white}{\color{white}} \DeclareCaptionFormat{listing}{\colorbox{gray}{\parbox{\textwidth}{#1#2#3}}} ...
3
votes
1answer
694 views

How to set frame size in a listing

I'm trying to put a frame around my code, but the frame has the wrong dimension. How can I set them right? ...
5
votes
2answers
587 views

Add keyword with special character

I'm trying to add a language (Scheme) in the lstlisting package. \section{Scheme} \lstdefinelanguage{Scheme} {morekeywords={,lambda, cond, case, display, let, import, quote, quasiquote, unquote, ...
4
votes
2answers
412 views

Problems When Escaping from Listings

I would like to use LaTeX to document my C++ code, since I am able to typeset mathematics easily, as well as create diagrams using TikZ. I made a minimal LaTeX template for testing, but I have already ...
3
votes
2answers
2k views

Lyx is ignoring typewriter font setting for program listings

I'm using Lyx's Insert|Program Listing to insert a code listing into my document. Unfortunately, Lyx seems to ignore the Typewriter font selection I made in DocumentOptions under Fonts ⇒ ...
2
votes
1answer
1k views

Micro symbol µ in lstlisting

I'm writing a report about a website I'm working on to play cards online. I use lstlisting to display my PHP, JavaScript and HTML code. The problem is that I'm using a lot of µ's in my JavaScript ...
3
votes
1answer
1k views

Custom divider between 2 minipage and lstlisting

I am using the following code to have 2 boxes beside each other for code comparison: \documentclass[12pt]{article} \usepackage{listings} \begin{document} \begin{singlespace} ...
10
votes
2answers
203 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
669 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
235 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
604 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
493 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
49 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
541 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
782 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
570 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
2k 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
1k 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
378 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
522 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
303 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
490 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
710 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
74 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
810 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
576 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
4k 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
43 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
132 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
444 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
587 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
1k 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 ...