{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

2
votes
1answer
43 views

resizebox fails for tikzpicture when used in conjunction with listing package

Here is the example that fails \documentclass{standalone} \usepackage{tikz} \usepackage{float} \usepackage{listings} \usepackage{color} \usepackage{textcomp} \usetikzlibrary{shapes,positioning} ...
3
votes
1answer
60 views

verbments (listings alternative) and UTF-8

This is a follow-up question to UTF8 for listings With these MWE I will not see the german umlauts in the resulted pdf (XeLaTeX was used): \documentclass{article} \usepackage{verbments} ...
0
votes
0answers
26 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 ...
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 ...
5
votes
1answer
57 views

Listings line numbers that match the linerange specification

This is a follow-up question to First line number in lstinputlisting environment. Consider the MWE: \documentclass{article} %\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox ...
6
votes
1answer
173 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 ...
5
votes
1answer
75 views

tikz inside lstlisting inside tikz

Here is the minimum working example: \documentclass{article} \usepackage{tikz} \usepackage{float} \usepackage{listings} \usepackage{color} \usepackage{textcomp} \usetikzlibrary{shapes,positioning} ...
3
votes
1answer
125 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 ...
6
votes
0answers
127 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} ...
1
vote
1answer
45 views

listing package: colored numbers, but not colored in variable names

How to format all numbers in a different color has been discussed in this post. However, this also colors numbers that are part of a variable name. Is there an option to avoid that? ...
2
votes
1answer
39 views

listings package: formating all numbers in language definition?

How to format all numbers in a code has been shown here. I have adapted it to include it in a language definition: \documentclass[fleqn, a4paper]{article} \usepackage{listings} \usepackage{color} ...
4
votes
1answer
44 views

How to refer to the count value of number of lines in a lstlisting

I need to refer to to the count value of the number of lines in a listing. Is there a way to do that ? \lstinputlisting[caption={SPARQL query used...},label={lst:sqry}]{codes/sparql_query.sparql} ...
3
votes
1answer
34 views

Add key for new Listings environment

I'm trying to add a new key to a custom listings environment. I have tried to modify this example. My problem is that the value I am attempting to pass through in the document for the key does not ...
4
votes
2answers
101 views

Listing with mixed english and russian symbols in comments

I'm using the listings package for formatting .cpp code in LaTeX. My code needs to have mixed English and Russian words in comments. The font must be monospaced (preffered Courier family). /* Prints ...
8
votes
2answers
147 views

Combining `tikzpicture` and `lstlisting`

I'm working on a custom lstlisting environment, in which I use TikZ to add a frame and a title. Because of the widespread curly braces of node I cannot use newenvironment, so I have to resort to ...
3
votes
1answer
35 views

Wider caption for listing using multicol

I am using the multicol and listings packages. I would like to have the caption spread across the entire listing for multi-column listings. Here is a MWE of what I am attempting, however the output ...
1
vote
1answer
111 views

Highlighting a Chunk of Code within a lstlisting by specifying the line number

This question in somehow related to http://stackoverflow.com/questions/1304315/highlighting-a-chunk-of-code-within-a-lstlisting but not exactly the same. I want to make some slides with animation ...
3
votes
2answers
76 views

Overbrace in lstlisting of Scala code

I want to add an overbrace to some text in a Scala code listing (using lstlisting). \begin{lstlisting} object TypeClass extends FooParMain { def newApp(args: Array[String]) = new FooParApp { ...
14
votes
6answers
3k views

Highlight text in code listing while also keeping syntax highlighting

I’m using the listings package for code listings. Now I try to highlight some part of the code using \hl from the soul package. Here’s an example of a resulting query where the injected part of a SQL ...
3
votes
1answer
68 views

lstlisting in a box?

My problem is that I am trying to write a document with coloured sections for examples. Examples can contain code listings. Somehow I can't seem to combine a background colouring with a listing, or ...
1
vote
0answers
22 views

How to do source code listings in ConTeXt? [duplicate]

I am new to LaTeX and ConTeXt, so I hope I am not asking something obvious. I have been able to create a LaTeX document using \usepackage{listings}. Now I have discovered ConTeXt. Is it possible to ...
7
votes
1answer
199 views

“Display math should end with $$” error

I'm trying to write math in a code listing, like so : \documentclass{article} \usepackage{listings} \begin{document} \begin[mathescape]{lstlisting} $\infty$ \end{lstlisting} \end{document} I get ...
2
votes
0answers
49 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: ...
8
votes
3answers
2k views

LaTeX techniques and templates for writing a book

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 ...
14
votes
2answers
284 views

minted vs. texments vs. verbments

Regarding the typesetting of syntax-colored source code, I know that listings is inferior because it doesn't utilize a full lexer. Instead the Python-based solution is recommended. It seems there are ...
1
vote
1answer
46 views

Minted: customise listing name? [duplicate]

How do I customize listing name: Listing 1: thing -- when I use minted? Here's an MWE: \documentclass{article} \usepackage{minted} % \renewcommand{\lstlistingname}{Something} % doens't work! ...
1
vote
0answers
14 views

Minted in listing: break code across pages? [duplicate]

I'm using minted to highlight code. And I put that into listings -- in order to get those numbered. By it self minted breaks code across pages. But when I put it into listings -- I get code on a ...
5
votes
2answers
53 views

How to combine listing and figure into a single figure?

I am using package listings, and I would like to combine a listing and a figure into a single float. As an example, I am using listings as follows: ...
2
votes
1answer
48 views

\lstlistoflistings doesn't have enough room between numbers and title

I'm using the \lstlistoflistings command from the listings package to generate my list of code samples. Unfortunately there isn't enough room between the number and the code listing title. See the ...
6
votes
1answer
72 views

Adding words to lstlisting for Python langaue

I wish to add a few keywords to some python code inserted into a latex document. I want to make 'True' & 'False' appear yellow and also some module calls such as 'ttk' appear red. I have tried ...
2
votes
0answers
75 views

LaTeX source code listing like in professional books for \lstinputlisting [closed]

Found this topic: http://stackoverflow.com/questions/741985/latex-source-code-listing-like-in-professional-books and I'm very satisfied with this soulution, it looks just great in a generated pdf ...
1
vote
1answer
45 views

lst include has first line indented [duplicate]

When I'm including a source file, by way of \lstinputlistings{file/path/to/file} However, This results in the following below: Why is the first line not being formatted correctly? And how do i fix ...
5
votes
1answer
262 views

tcolorbox - list of listings?

In a book with figures, tables and listings, I figured out that all listings and some tables and figures look better when presented in a tcolorbox. The book has the usual tables of contents: ...
1
vote
1answer
64 views

lstlisting: how to align highlighted code

I want to define a couple of new commands in order to highlight parts of my code (this is actually for a trace dump, not for a programming language). My problem is that I can't seem to make the ...
5
votes
2answers
4k 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 ...
2
votes
1answer
104 views

Syntax highlighting for different programming languages [duplicate]

In my paper I want to include some source codes with colored sytax. For syntax highlighting I use the listings package: \lstset{frame=tb, language={[Visual]Basic}, aboveskip=3mm, belowskip=3mm, ...
2
votes
1answer
67 views

How to suppress automatic conversion of “<=” inside lstlisting/lstinline?

I have the following LaTeX code: some text \lstinline!u <= 1! some text In my output, the two characters <= get automatically joined to form a single "less-than-or-equal" chararacter (i.e. ...
1
vote
1answer
115 views

How to change fontsize in lstlisting without losing bold syntax highlighting?

If I load the listing package to set nice code and change the font size (like suggested there: Shrinking monospace style for listings package), I lose the syntax highlighting, because the font does ...
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 ...
4
votes
1answer
57 views

Ignore keyword in Listings

Consider the following minimal example: \documentclass{standalone} \usepackage{listings} \begin{document} \begin{lstlisting}[keywordstyle = \textbf, language = SQL, deletekeywords = {time}] create ...
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
1answer
139 views

Removing small gaps between lines in LaTeX lstlisting output

Whenever I set a somewhat dark background color in a code listing it becomes obvious that there are small line separations, these of course stay white making the overall appearance not desirable. My ...
0
votes
1answer
67 views

wrap listings package - Problem with verbatim argument

I would like to define a command that wraps a lstlisting environment in some other environments (esp. a minipage). I understand that working with verbatim arguments is a difficult task. I tried the ...
4
votes
2answers
114 views

Spaces inside Cyrillic listings

I want to include source file using listing package. In that file there are some cyrillic symbols in comments. I setup listings like: \lstset{extendedchars=\true,basicstyle=\ttfamily} And in ...
2
votes
2answers
69 views

How to prevent a listing from straddling two pages

If I have a small listing that happens to be at the end of a page, how can I force LaTeX to place it on a new page so that it does not straddle two pages, which looks ugly for a small listing.
9
votes
1answer
4k views

How to create beamer slides with source code that can be copied?

We are converting our course slides from Powerpoint to LaTeX, to be able to offer all code in a more open format and to let students easily copy code from the slides. However, the latter does not seem ...
8
votes
1answer
236 views

Inconsistent output for R language operators when using listings package

A referee noticed that the <<- (assignment to a global) and %*% (matrix mult.) operators in a code listing I used were wrong. I am using the standard listings package (version 1.4 dated ...
4
votes
1answer
69 views

Make lstlisting honour baselinestretch

I have to use lstlisting instead of Verbatim in a particular case, because math escape doesn't work properly with the latter. I managed to have both look the same, but lstlisting ignores my ...
3
votes
1answer
96 views

Using math mode escapes with listings enabled fancyvrb

I am trying to escape math mode within Verbatim, using this answer. This works fine, until I use the listings package with fancyvrb=true \documentclass{article} \usepackage{fancyvrb} ...
4
votes
3answers
1k views

Customizing the list of listings generated by \lstlistoflistings?

I'm using listings in my document, and its command \lstlistoflistings to generate the list of listings. The problem is that I've customized all the other lists (TOC, LOF and LOT). More precisely, I've ...

1 2 3 4 5 17