{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

7
votes
1answer
507 views

Insert Text between “List of XXX” Heading and Actual Listing

I would like to insert a small paragraph of text between the "List of Figures" heading and the actual list of figures, and also between "List of Listings" and the actual list of listings. I am using ...
1
vote
1answer
855 views

listings-package custom language use space as comment-delimiter

I'm creating a custom language definition with the LaTeX listings package that should render Java's Jar-Manifest files (key: value Pairs) so that one can easily distinguish key and value. My approach ...
6
votes
1answer
122 views

How to put stuff in the margin every first line with the listings package?

I am writting a book and I use the listings package to type some matlab code. I would like to highlight every code block with an arrow or whatever hanging in the margin at the first line. Moreover The ...
4
votes
0answers
609 views

algorithm2e-like vertical lines for loops in listings package [closed]

Is there any way to set vertical lines for loops in pseudo-algorithms written with listings package, in an algorithm2e style? As an example, see here: http://csweb.ucc.ie/~dongen/LAF/Algorithms.pdf ...
2
votes
2answers
1k views

lstinputlistings syntax highlighting

I am using package listings to import my Python source code into my LaTeX document. I use the command \lstinputlistings. I have a Python source like class MyClass(Yourclass): def __init__(self, ...
24
votes
2answers
15k views

How to highlight Python syntax in LaTeX Listings \lstinputlistings command

I am using package listings to import my Python source code into my LaTeX document. I use the command \lstinputlistings. I have a Python source like class MyClass(Yourclass): def __init__(self, ...
4
votes
1answer
260 views

How to I emphazise all words beginning with ` in an lstlisting

I use a preprocesser to process some code before my verilog compiler. All preprocesser words start with the ` character Example: `pp_if unfortunately its possible to define your own preprocessor ...
2
votes
1answer
270 views

Source Code using listings produce very large PDF

Taking a 2284 line source file (language=C) and embedding into a LaTeX document using \usepackage{listings} produces a PDF of around 150KB. The original source file is 78KB. By itself this is ...
8
votes
1answer
5k views

Set horizontal width on custom listings environment

I want to create a custom listings environment and want to set its width as something like 90% of textwidth, centred. Per an earlier question for algorithms, the first thing I tried was to embed the ...
5
votes
0answers
59 views

Review of algorithm-related packages? [duplicate]

Possible Duplicate: Print programs with its proper syntax Where can I find (if it exists) an updated review of the most relevant packages for handling with algorithms (pseudocode or code ...
8
votes
1answer
157 views

How to apply the star (*) to only a few of the literates in listings environment?

I have a problem with the definition of literate: \lstset{ numbers=left, numberstyle=\footnotesize, stepnumber=1, numbersep=12pt, frame=none, framesep=7pt, breaklines=true, ...
2
votes
2answers
193 views

Unindent code inserted with \lstinputlisting

Is it possible to unindent the code inserted using \lstinputlisting? In particular I'd like to be able to unindent by a fixed amount of whitespace. I have to write a relation on a OS scripting course ...
1
vote
0answers
128 views

Indenting listings in Auctex [closed]

I'm using the listings package to typeset some Python code. I don't seem to be able use the tab key in Auctex mode to indent my code within listings. I'm new to both Emacs and Auctex, but the only ...
13
votes
1answer
8k views

How to improve listings display of JSON files?

I was wondering if there is a good way for JSON files to be listed with the listings package. The only language definition I could come up with, is this: \lstdefinelanguage{json} { ...
5
votes
1answer
579 views

Getting incorrect underscores from macro in an lstlisting

I have a macro that I define as \newcommand{\versionPath}{5\textunderscore0\textunderscore7} to denote the word *5_0_7*, which I use in lstlisting's like this: \begin{lstlisting} ...
3
votes
1answer
107 views

how to better control the number display of listings?

I'm using the listings package for my sourcecodes, and among other things to control the display of those, I'm using \lstset, obviously. Now, When setting numberstyle, I've set them to ...
2
votes
1answer
828 views

LaTeX listing of command line syntax

I have a LaTeX document using the listings package for some bash scripts. I'd like to create a different styling for text that is meant to show the syntax of a command. For instance, I have the ...
7
votes
2answers
455 views

Comparing two versions of programming code with LaTeX

I'd like to compare two versions of program with vertical line between them. How can I do this with LaTeX?
6
votes
2answers
254 views

Improving the POV definition in the listings package

I'm attempting to create a language definition in the listings package that mimics exactly the syntax highlighting in POV-Ray 3.6 for Windows (http://www.povray.org/download/). Here is a screenshot ...
3
votes
1answer
495 views

Picture breaking listing

When putting long code using lstlisting on a page it breaks, which is fine. When placing a picture in a floating figure environment, it gets between the two parts of the listing, which obviously is ...
2
votes
1answer
329 views

How to prevent figures from floating 'into' listings [closed]

I have a problem with floats and listings. Sometimes it happens that a listing is split over two pages and when a figure is near the listing it happens that the listing starts on the first page, on ...
4
votes
0answers
62 views

Highlighting keywords with spaces with the listings package [duplicate]

Possible Duplicate: How to emphasize within a listing two successive identifiers separated by a space? I am trying to highlight the following keywords with the listings package: over ...
11
votes
2answers
982 views

How to highlight all words of the form [0-9][A-Za-z0-9]* immediately following an equal sign?

I am using the Latex Listings package to include code in a document. I need to implemented syntax highlighting similar to what you see in a standard IDE. I've been able to assign colors to comments, ...
7
votes
2answers
663 views

Unicode characters changing order in listings (XeTeX)

I am trying to input code listings with unicode characters and everything seems to work (more or less) except some unicode characters being displayed out of order. For example instead of służąca ...
4
votes
3answers
517 views

How can I highlight text before a character with listing?

All is in the title. I would like to add a color to the text before a character with listing package. For example, I would like to add a color to text between the beginning of a line and : or =, in a ...
8
votes
1answer
699 views

lstlisting border bug when breaking lines

I have a certain bug regarding listings. I have used the \lstset command to configure my lstlisting environment. Somehow, when I have a line that is too long to fit into one row the listing breaks ...
2
votes
1answer
380 views

Define a macro for inserting a \begin \end listings block

Can you define a macro that would take a listings code as a parameter and insert it inside a \begin{lstlistings} \end{lstlistings} block? My idea is something like this: ...
4
votes
2answers
332 views

Sourcecode on the left, Nassi–Shneiderman on the right (float?)

I’d like to place a Nassi-Schneiderman diagram into my LaTeX document but also to have the source code for the shown algorithm beside it. Drawing the diagram worked just fine using the ...
1
vote
1answer
960 views

listings: How to increase space between backgroundcolor-box and code?

As you can see, the colored box created by backgroundcolor is quite tight. How can one increase the "padding", i.e., the space between the box and its content? This seems to be related, but I don't ...
6
votes
1answer
777 views

Unequal letter spacing in 'listings'

I am wondering why in the pdf of the example below the letters of the word "function" and the word "sum" seem to have different spacing. This somehow looks ugly. Apart from that, I am wondering if ...
14
votes
1answer
1k views

Automatic background coloring in listings using tikzmark

I am authoring Beamer presentations that feature numerous code listings, and I am required to highlight portions of code with semi-transparent balloons. Yet I've come up with a solution that uses a ...
5
votes
0answers
666 views

Advanced use of listings package [closed]

I am a PhD student in A.I. that is using the listings package to render its code snippets. I am trying to define a language environment for Drools - a quite famous Production Rules System - that is ...
5
votes
2answers
215 views

Highlighting code introduces extra space

I am trying to highlight portions of code inside a listings environment. However, using tikz introduces some extra spaces that I do not understand and would like to ask how I can rid of them. Here is ...
2
votes
0answers
45 views

Aligning comments that break in several lines? [duplicate]

Possible Duplicate: How to align comments with lstlistings? I want to include Matlab code with long comments. The next MWE shows that it is achieved by using the listings package. However I ...
12
votes
1answer
892 views

Line numbering using listings package starts at random number

I'm using the listings package to include code directly from a file. In the first instance my code is numbered as I want it 1 at the 1st line, 11 at the 11th, ... However, the second block of code it ...
8
votes
2answers
586 views

How can I define a custom listing environment?

I am trying to define an enviroment for a specific programming language, F#. Here's my code: \definecolor{bluekeywords}{rgb}{0.13,0.13,1} \definecolor{greencomments}{rgb}{0,0.5,0} ...
2
votes
1answer
146 views

etoolbox patch lstlistings

This is a follow up question to empty page afterpage listings. I'm trying to work around a listings problem with etoolbox: \documentclass{scrartcl} \usepackage{listings} \usepackage{afterpage} ...
2
votes
1answer
261 views

empty page afterpage listings

I get an emptypage on multi page listings if I use listings with afterpage. \documentclass{scrartcl} \usepackage{listings} \usepackage{afterpage} \begin{document} \afterpage{% %some fancy stuff } ...
5
votes
1answer
3k views

Creating new colors in xcolor for use in listings

I'm trying to include some code using \usepackage{listings}. However the default look is not very pretty, so I want to customize it a bit. I've read some of the other posts about changing the layout ...
3
votes
2answers
774 views

listings: Changing the meaning of underscore for the language R (customizing a language)

I really like the listings package but often it drives me crazy :). I want to have listings of the programming language R (statistic stuff). Here's a minimal example: \documentclass{article} ...
3
votes
1answer
6k views

\lstdefinestyle syntax highlighting

I´m new to latex and got the following problem. I defined a listing style for XML Syntax highlighting like this: How can I get also the equals symbol in the attribute color (orange)? I want to do ...
5
votes
1answer
308 views

Fix page numbering format for latex listings package (lstlistoflistings)

I have a problem with the listings of my latex document. I am using the "listing*s*" package (not the "listing" package). Although the pagenumbering is still set to "roman" right after the titlepage, ...
1
vote
0answers
149 views

Listings package and BigInteger Library Conflict? [closed]

In my java code, I have extensively used the variables and methods from the BigInteger library. In LaTeX, in order to display my code neatly, I have used listings package. So between the ...
8
votes
2answers
379 views

How to show a hint when lstlisting is breaking page?

I use inline lstlisting-blocks with caption. I have several listings that are running over more than one page or starting at the end of a page. Now I want to place a hint for the readers, that the ...
15
votes
1answer
2k views

Why does LaTeX replace some spaces with brackets or underscores in the listings environment?

I'm using LaTeX on Windows with MikTeX and I'm seeing some odd behaviour. In the output, some of the spaces are replaced with bracket-like underscores. This is the code: \documentclass[10pt]{article} ...
2
votes
1answer
253 views

How can I create a lstlisting environment that spans more than one page?

I am using listings package to show some algorithms in a LaTeX document. One of the algorithms I want to include is longer than one page. So, my question is: How can I create a lstlisting ...
8
votes
1answer
742 views

Append character at autobreaks in listing

I'm writing a LaTeX document for a hands-on workshop which uses shell/bash commands. I'm making use of the listings package to format the chunks of code. Some of the commands are rather long so I'm ...
11
votes
1answer
5k views

Listings without a border?

I'm using listings to format blocks of code in my LaTeX, and I like it. But, except for large blocks of code, the border around the code block is bulky and breaks up the flow of how I read the ...
3
votes
1answer
377 views

linerange reference in lstinputlisting

I have a listing that refers to my c code; I would like to reference the code using commented section in the code, as seen in the code example bellow. I have created a list style which does this, but ...
4
votes
1answer
2k views

Change in \lstdefinelanguage the font?

Im using \lstdefinelanguage to add some new languages. Now everything is fine, I just would like to add another font to my language. I would like to use inconsolata. I have now this: %... ...