{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

6
votes
1answer
170 views

Making Source Code Copyable with listings

I'm using listings to display some matlab code in my latex document but i'd like to have syntax highlighting. I've tried two ways of getting syntax highlighting and neither make the code copyable. The ...
3
votes
1answer
123 views

How to include Maple code in LaTeX?

At here Fanciest way to include Mathematica code in LaTeX we can include Mathematica in LaTeX. I want to include the code restart: with(geom3d): eqS:=Equation(sphere(S,(x-1)^2 + (y-1)^2 +(z-1)^2 ...
1
vote
1answer
28 views

Add keywords to an existing language in listings

I've already read extending a language with additional keywords and I have found kind of a solution, but I'm not quite sure if it's the right way and if I won't have problems in the future. The ...
1
vote
1answer
44 views

listings caption gray box meaning of code

Some time ago I copied this code from Stackexchange to have a nice gray box at the top of my imported source code which I displayed with listings: \DeclareCaptionFont{white}{\color{white}} ...
12
votes
0answers
75 views

Help defining PDF syntax with listings package

I'm trying to make a pdf language definition for the listings package, but I can't get the string definition to work correctly. This is what I have defined: \lstdefinelanguage{pdf}{ ...
6
votes
0answers
124 views

UTF8 for listings

With German umlauts I have to define these characters (Typesetting UTF8 listings with German Umlaute) and the following MWE is working: \documentclass{article} \usepackage[utf8]{inputenc} ...
6
votes
0answers
169 views
+50

Strange error when combining Beamer, Animate, Tikz and Listings

I'm working on some slides where I show how code is actually executed in Java. Therefore I'm working with the animate package to generate animations. Without going into details, I've written a macro ...
4
votes
0answers
144 views

Stop listings going over page breaks

I am using Pandoc to generate Tex from Markdown. It automatically generates listings when it comes across the appropriate Markdown (code indented four spaces). It then uses the listings package to ...
3
votes
0answers
50 views

texcl, escapeinside, and single character comments, with listings package

I'm using the excellent listings package to typeset some code in a language very similar to Scheme. The language has one type of comment: when an (un-escaped) semicolon is encountered, the rest of ...
3
votes
0answers
104 views

About autoindent and postbreak in the package listings

I am using the package listings to show my Matlab code. The code was pre-typed in a file and everything will be loaded from the file and a .tex file will be generated automatically to show the code ...
3
votes
0answers
69 views

place symbol or some command on page break within lstlisting

Whenever I have a page break splitting my lstlisting on different pages, I would like to have a symbol or generally spoken some command inserted automatically. I can accomplish that manually by using ...
3
votes
0answers
67 views

define moretexcs (listings)

I want to define moretexcs lists outside of a lstdefinestyle macro because I want to load these definitions from a separate tex file. However inside lstset moretexcs is ignored: ...
3
votes
0answers
64 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
0answers
59 views

1. Orderly sorting questions, 2.Resulting right answers using package exerquiz

I have two datasets, each containing problems dealing with a specific topic. These problems are stored in external files (again, one file per topic) and loaded into the datasets in a order. I need to ...
2
votes
0answers
48 views

Regular expressions in listings

I'm looking for a possibility to use regular expression in listings. I'd like to highlight each N thats followed by 4 decimal numbers for example N1234. How can I achieve that? Here is an example: ...
2
votes
0answers
60 views

Default value for basicstyle in lstlisting

I have most of the code in Python, which renders very nice with this simple configuration of lstlisting At a certain point I have to include an XML file, so I switched to language=XML but it renders ...
2
votes
0answers
48 views

spacing before scope resolution operator

I'm new to LaTeX and I have encountered a problem with the listings package, I have a space before the :: operator of C++ . after reading lstlisting with c++: spaces around scope resolution operator ...
2
votes
0answers
42 views

Right-align the prebreak symbol in a listings environment

I’m using the breaklines and prebreak option with listings, but I find it visually not very pleasing that the prebreak-symbols are not vertically aligned. I’d prefer if they were all on the very right ...
2
votes
0answers
45 views

Override properties of a predefined listing style

I use the listings package and I want to override an attribute of the HTML style. Unfortunately my code overrides the whole HTML style and not just a single property: \lstloadlanguages{HTML} ...
2
votes
0answers
42 views

Listings: Format part of a string differently (markup language inside a string)

I made a new language definition for a .NET template engine where part of the strings in the C# code are markup. Example: string templateString = @"{% for name in names %} Hallo {{ name }} {% ...
2
votes
0answers
120 views

Enforce a line-break inside \lstinline

I use \lstinline{foo} from the listings package to set pieces of code in regular text. To get automatic line-breaks I use the following options: \lstset{ breaklines=true, breakatwhitespace=true, ...
2
votes
0answers
99 views

Headers and footers for listing environment?

What I need to be able to do is apply a header and footer when I use the listings environment. I have a few requirements: The header and footer should be outside the listing itself, i.e. they are ...
1
vote
0answers
38 views

Latex to HTML using Pandoc

I have a bunch of tutorials I have written and they are written in Latex. Now I want to convert them to HTML and to Blogger also. I heard about Pandoc and decided to try it. Below are my results : ...
1
vote
0answers
42 views

How to add a caption to a listing with minted?

Package minted provides a way to add captions and labels to a listing wrapping it around with listing environment. With this environment the code block is put inside a floating box which won't break ...
1
vote
0answers
57 views

Globally set the justification in a framed box

I want to show the text from a Python Interpreter in a Windows console. This should be plain text (like you see in a command line terminal). I also want to show Python code snippets with highlighting. ...
1
vote
0answers
58 views

Minted cross reference line

I used to use listings a lot but minted+pygmentize has outstanding output. However, there are a few features from listings that are hard to find in minted, like having the line numbers on the right. ...
1
vote
0answers
100 views

highlight listings in beamer

While trying to use listings and beamer, for highlight some parts of the code I found the following: How to make overlay still work inside lstlisting environment? However I notice that I can't ...
1
vote
0answers
72 views

Preventing line break at the start of a long name in `\lstinline`

This question has developed from How to deal with very long lstinline-phrases like long class names?. That question is about line breaking inside a \lstinline phrase. I have provided an answer which ...
0
votes
0answers
26 views

Description list looking like a glossaries list

Is there a package or something that allows me to create a list (like description) that looks like a glossaries list, where the descriptions are indented the same length? Like it is if the ...
0
votes
0answers
24 views

XML with Listings: Different colors for attributes and elements

How can I make every attribute name in color X and every element name in color Y without adding keywords and stuff? What I did so far: \lstdefinelanguage{myXML} { morestring=[b]", ...
0
votes
0answers
41 views

Define listing for different languages

I'm writing a thesis where I need to highlight XML, C# and Python code, here is my definition, but all I get is the same highlight for all three types. \documentclass[a4paper,slovak,12pt]{article} % ...
0
votes
0answers
35 views

line spacing in lstinputlisting with floats

I have a document with many code listings using \lstinputlisting. Some are floats for convenience and some (multipage listings or others that need explicit placement) do not float. If the listing ...
0
votes
0answers
28 views

listings range end markers in comments with texcl

I'm trying to using the listings package to generate nice listings of some Lisp-style code (where line comments begin with a ;). I'd like to keep the code compilable, and so put the range markers ...
0
votes
0answers
90 views

Cannot install listings through MikTex package installer

When I was trying to install the listings package through package manager, it showed that The operation could not be completed because the following file failed verification: ...
0
votes
0answers
25 views

LaTeX - listings: Color digits but not in variable names

I am using the listings LaTeX package to so some C code high-lighting and I am facing a slight issue. I would like my numbers to be coloured in red, but not when they are part of a variable name. For ...