{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

3
votes
1answer
366 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
2k 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
172 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
624 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 ...
38
votes
3answers
35k 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
346 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
459 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
292 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
990 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
522 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
189 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
276 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 ...
16
votes
3answers
9k 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
97 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
473 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
697 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
325 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
311 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
120 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
678 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
171 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 ...
3
votes
0answers
287 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
509 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 ...
2
votes
0answers
42 views

listings breaklines not working [duplicate]

Possible Duplicate: How to deal with very long lines that do not contain spaces? When I use the listings package with breaklines, it doesn't seem to break lines properly if there is no ...
2
votes
1answer
1k views

center the listings title above the code

I can't manage to center the title "Listing:1" over the listing. \documentclass[8pt,blue]{beamer} \setbeamertemplate{navigation symbols}{} \usepackage{subfigure} \usepackage{fontspec} ...
6
votes
1answer
645 views

Enumitem, Listings, Tabbing to a Certain Point

I was wondering whether it was possible to align a lstlisting environment to a certain point within an enumerate . The purpose of my doing this is to fit as much code sample on the page as possible, ...
3
votes
1answer
423 views

keep listing's caption together with listing

I'm using the tips found in here to show a code listing with a caption. Sometimes the caption is put at the end of the page and the listing on the next page. How can I keep them together?
9
votes
1answer
346 views

Label a lstlisting listing in the lower right corner

I want to put a label in the lower right corner of my listings, in this case to indicate the kind of code listed there. I have a bad hack that works somewhat and illustrates what I want: ...
0
votes
1answer
188 views

Highlighting specific lines with lstinputlisting [duplicate]

Possible Duplicate: highlight lines in listings How can I include a source file with the listings package and highlight specific lines (coloured text or coloured background will do)?
13
votes
4answers
6k views

lstlistings: framed code [closed]

I use lstlistings to write Pascal Code. I'd like my code to be numbered and framed. Here is what I have as of now : \lstset{numbers=left, numberstyle=\small, numbersep=8pt, frame = single, ...
2
votes
2answers
759 views

XML listing shows incorrect quotation marks

I'm using \lstinputlisting from listings package to insert an xml file as a listing in my latex file. In the XML file the quotation marks are double quotes as normal when I view my PDF they appear as ...
1
vote
1answer
598 views

How to write program text in table

I have to write a table with two columns and in each column I have to place small C code snippets. Using the \code{} in each column seems to be very tedious because I have to write \code{} in each ...
4
votes
1answer
307 views

Using \underbrace interferes with frame around Listings

I am having some issue when it comes to use a frame around my listings. The usage of underbrace breaks the frame. Can anybody help out and let me know how to fix this? ...
5
votes
1answer
607 views

How to render Android listings with syntax highlighting?

I need to include the source code of a bigger Android project in the documentation written with LaTeX. Do you recommend any particular package that is capable of highlighting Java code and which also ...
9
votes
1answer
371 views

How to remove the indentation in list of listing

The list (from \lstlistoflistings) is indented compared to list of tables (\listoftables). How can I remove the extra indentations? \documentclass{memoir} \usepackage{listings} \begin{document} ...
5
votes
1answer
589 views

listings: closing parenthesis as delimiter not matched when linebreaks=true

I want code in parentheses and in brackets to appear in different colors. In the following document, the words brackets again appear in green as intended, and outside again is black as intended, but ...
2
votes
2answers
217 views

Alternating formatting within the same lstlisting environment

I am writing a document that contains parts of an compiler interpreter session (GHCi in this case, but this is not relevant). I have a carefully setup style for Haskell code that I would like to use ...
6
votes
1answer
1k views

\newcommand throws error: Runaway Argument? Paragraph ended before \lstKV@OptArg@@ was complete

I'm using the listings package in a document. In order to simplify the use of the \lstinline command I created a new command that looks like this: ...
6
votes
1answer
179 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 ...
11
votes
2answers
543 views

How to deal with very long lstinline-phrases like long class names?

According to this Question: listing: How to deal with very long lines that do not contain spaces? My problem is that my \lstinline-phrases does not contain any special character like "-". In my ...
1
vote
1answer
380 views

How to define a hotkey in LyX to insert an inline listings?

In LyX, I can define a hot-key for listing-insert. But in this case, what appears is the \begin{lstlisting}...\end{lstlisting} environment. In fact I want to insert a inline listings command ...
2
votes
1answer
297 views

How to use listings inside pgfplots captions?

I need to add a (general) listings code in a plot caption. For some reason listings (inline) doesn't interact well with \addlegendentry, what can I do to make the same code work outside and inside an ...
1
vote
0answers
27 views

Distance between text and \lstlisting [duplicate]

Possible Duplicate: Increase space between listings env. and surrounding text Is it possible to increase the distance between text and an \lstlisting? In my resulting PDF the listing ...