{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

1
vote
1answer
913 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
760 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
659 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
214 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 ...
11
votes
1answer
838 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
571 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
141 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
258 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
760 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
5k 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
304 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
148 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
370 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
251 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
725 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
370 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: %... ...
3
votes
1answer
3k views

\lstinputlisting for a normal text file?

sometimes im using \lstinputlisting to show some code examples in my pdf. Now I just would like to insert a normal textfile. Everything is fine, I like this box around my text and the numbers every ...
1
vote
1answer
174 views

svmono with 'draft' causes lstlistings to produce no output

Why does the following produce no output? \documentclass[draft]{svmono} \usepackage{listings} \begin{document} \begin{lstlisting} theorem :: GROUP_10:14 for G being finite Group, p being ...
5
votes
2answers
632 views

Is there a non-verbatim form of lstinline from the listings package?

I'm using the listings package with beamer and I'd like to try to avoid making frames fragile where possible. I know that many of my frames will need to be fragile but there are some where the ...
39
votes
3answers
36k views

What can I use to typeset MATLAB code in my document?

This question led to a new package: matlab-prettifier Does anybody have a quick and easy way to typeset some relatively long MATLAB code in the appendix? I looked up a few methods, and the ...
2
votes
2answers
350 views

Make several pages of source code into 1 column within a twocolumn book format

I have a \documentclass[11pt, 12pt, oneside, twocolumn, fleqn, leqno]{book} which was given to us by our professor. My problem is, he want us to put the LaTex Code inside the pdf document that will ...
1
vote
0answers
35 views

Mixing multiple programming languages with different styles in same document [duplicate]

Possible Duplicate: Defining lstset parameters for multiple languages What's the easiest way to include code, using listings, from more programming languages? \lstset{ % language=Python, ...
6
votes
1answer
464 views

Python “as” keyword ignored in Listings

Following code cant highlight as keyword. What am I doing wrong? Shouldn't as be bold like import? \documentclass[a4paper,10pt]{article} \usepackage[utf8]{inputenc} \usepackage{listings} ...
5
votes
1answer
297 views

Highlight a prompt with the listings package

I use the listings package to typeset a series of commands in the language Octave (a free clone of Matlab) in my lecture notes. Most of the command lines look like this: octave:1> A=eye(4) A = ...
20
votes
2answers
1k views

Problem with literate and breaklines=true in listings package

As the title says, the option breaklines=true seems to have an undesired interaction when using literate; in the following example the closing parenthesis doesn't get colorized ...
4
votes
1answer
534 views

\lstinline & \colorbox

Why the command below don't work? How can I fix it? \documentclass[11pt]{book} \usepackage[dvipsnames]{xcolor} \usepackage{listings} \lstset{language=[LaTeX]Tex, ...
0
votes
1answer
191 views

Question about ArsClassica codes

I would to know for what is used the code below (Last lines code) in arsclassica.sty. Also I would to know why in arsclassica-settings there are some repetitions of \lstset is not the same thing put ...
2
votes
1answer
278 views

Long lines when using listings [closed]

First Issue I'm using the listings package to present some algorithms using pseudocode. The problem is that sometimes the lines of my pseudocode are too "long" and listings breaks them in 2 lines. ...
8
votes
1answer
2k views

How to make lstlisting look exactly like the algorithm environment?

I'm typesetting pseudocode with algorithm and algorithmicx to get results like the following (taken from the package documentation): Now I would like to print real C++ code with the listings ...
17
votes
3answers
10k views

Avoid page breaks in \lstlistings

I'm trying to avoid page breaks in my lstlisting (seen in section 0.0.2) I know I can remedy this by floating my lstlisting, but it adds some unwanted white space (seen in section 0.0.1). Is ...
5
votes
1answer
98 views

Prevent Listings from breaking frames

Is there any way to prevent the listings package from leaving unsightly gaps in the frame when using breaklines=true. I'm just \lstinputlisting some code, placing it in a shadowbox frame and letting ...
4
votes
1answer
1k views

A line in the lstlisting environment cannot start with “\end{frame}” in a beamer presentation

I'm making a presentation about LaTeX using the beamer package (v3.10). I'm using the listings (v1.4) package to print pieces of latex source code and highlight the keywords. It seems that the ...
7
votes
1answer
4k views

Add another color at other keywords in listings

How can I add another color at other keywords? For example: morekeywordsA={RequirePackage,ProvidesPackage}=\definecolor{keywordsA}{HTML}{8A4A0B} ...
17
votes
1answer
477 views

Is there a listings configuration for TikZ as used in PGF/TikZ manual?

I want to create a tutorial how to use TikZ now. Is there a listings configuration for TikZ as used in PGF/TikZ manual? For example, I want to make \ as an integral part of tikz in \tikz, relevant ...
2
votes
1answer
705 views

How to add a keyword with a blank space in Listings package? [duplicate]

I am trying to define a listing style in order to have fortran source codes which look like vim style colors. For example, I would like to give a specific color to end program or end module or ...
4
votes
2answers
3k views

Inserting Code in multiple pages as an appendix

I am trying to insert a script (bash shell code) to the appendix of my document. I am trying to import the script from separate file. The script file name is Event_Db_BckUp_Script.als. The problem is ...
3
votes
1answer
340 views

Hide listing from listoflistings [duplicate]

Possible Duplicate: remove unwanted contents from list of listings How can I hide a listing from the listoflistings, similar to using \section*{Title} to hide a section from the table of ...
2
votes
1answer
316 views

Strange error in itemize with menukeys and \lstinline

A user of my menukeys package found a strange error an if don’t have any idea what’s the cause and all the more how to fix it … The following example make the bullet move to the right inside the text ...
5
votes
1answer
121 views

Paragraph titles disappearing

So, I'm trying to use the listings package for some code samples in my document. When I converted my verbatim sections to lstlisting my paragraph titles disappeared. I've attached some example code ...
6
votes
2answers
689 views

verb inside lstlisting caption

I try to do this: \begin{lstlisting}[language=Perl,caption={text {\verb+myverb+} some more text}] ... \end{lstlisting} But it gives me something like: Undefined control sequence ... some more ...
4
votes
1answer
175 views

Possible to adjust character width?

I'm using Beamer and lstlisting to put some code in a presentation. The character spacing feels a bit too wide to my eye. Is it possible to reduce it? I've tried searching on this SE but can't seem ...
2
votes
1answer
1k views

How to extend fancyref for listings?

I use a listings environment to format source code such as a JSON file. \begin{lstlisting}[label={lst:json-example},caption=A JSON example] { "title" : "JSON specification", "author" : "Douglas ...
4
votes
0answers
291 views

Page break before caption in lstlisting [closed]

I have the following settings for a lstlisting: \lstset{ language=XML, numbers=left, numberstyle=\tiny\color{gray}, stepnumber=1, numbersep=5pt, ...
1
vote
1answer
520 views

lstaddons: Dynamic linewidth calculation

I use the package called "lstaddons" (creator, initial question) to get colored line backgrounds on listings. I want to color the whole line to the frame. What I miss there is a dynamic calculation ...