{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

5
votes
1answer
103 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
498 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
148 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
909 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
257 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
450 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
39 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
794 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} ...
5
votes
1answer
496 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
332 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
307 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
170 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
4k 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
561 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
522 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
272 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
510 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
292 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} ...
4
votes
1answer
456 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
205 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: ...
5
votes
0answers
148 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 ...
9
votes
2answers
435 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
332 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
284 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 ...
3
votes
1answer
160 views

Linebreak after \lstinputlisting

Is there any way for me to insert a linebreak after a \lstinputlisting? At the moment text proceeding the code in the lstinputlisting follows directly after but I'd prefer to have a linebreak but ...
6
votes
2answers
2k views

Increase space between listings env. and surrounding text

How can I set the space between a listing (lstlisting) and text that surrounds it? Is there a parameter I can set at the beginning of my document, that controls this? I tried framesep, but it just ...
2
votes
1answer
359 views

Making figures (listings) be like tikz node/arrow transitions

I have the MWE as below: \documentclass[a4paper,11pt,twoside]{report} \usepackage[left=2.5cm,right=2cm,top=2cm,bottom=2cm]{geometry} \usepackage[T1]{fontenc} \usepackage{graphicx} ...
2
votes
0answers
261 views

Using \lstinline[] changes all text colour in editor after use [closed]

Ben using \lstinline today from the listings package... and every time I use it, it seems to change the colour of all text following it in texmaker to light brown... which is very annoying when trying ...
3
votes
1answer
356 views

How to combine the listings and algorithm2e packages to be used with List of Listings

I want to make a "List of Algorithms and Listings" that contains both listings made with \begin{lstlisting}... (listings package) and algorithms \begin{algorithm}... (algorithm2e package). I also ...
3
votes
2answers
1k views

Listings line numbers and figure

I'm using listings to typeset some C inside a figure environment next to a diagram, and I have the numbers on the left. My problem is in two-column mode the line numbers appear in what should be the ...
1
vote
1answer
110 views

Order of `float` and `caption` packages in preamble

I am using float and caption packages in my document, and also packages like tabularx, listings, algorithm... that (as far as I know) define floating elements or elements that have captions ...
5
votes
1answer
994 views

How to add color to source code under the listings environment

I would like to color a few keywords in my slides under the listings environment In the following contrived example, I would like to color the __shared__ word with orange and WIDTH with blue. How ...
13
votes
2answers
21k views

Decrease font size in a listing

Hi I am trying to include a short code snippet into one of my beamer slides However one of the lines is not fitting into the slides. Please let me know how to decrease the font size to make the ...
9
votes
1answer
12k views

How do I add syntax coloring to my C++ source code in beamer

I have just learned how to insert source code into beamer with the listings package. However I dont know how to go about adding any syntax coloring on the C++ source code. How do I do that? Here ...
8
votes
3answers
6k views

How to put C++ source code into beamer slides [duplicate]

Possible Duplicate: How display LaTeX code in LaTeX document? How do I fit java style source code in one frame in beamer? How do I add C++ formatted and coloured source code to my beamer ...
3
votes
1answer
774 views

Background color in inline code listings with linebreak

I want to highlight code inline with a gray background. Preferably with listings. This question is related to Colored background in inline listings. But as my MWE shows it doesn't work with line ...
2
votes
1answer
292 views

\lstinputlisting of a whole java project

I'd like to print the complete source code of my java project, which has multiple .java files in several packages (i.e. folders), many .properties files and many .xml files, and others. I want to use ...
2
votes
1answer
640 views

vim type Display for C Code in Latex

Target Display: My Latex Code: % xxxxxxxxxxxxxxxxxxxxxxxxx Code Snippet STARTS xxxxxxxxxxxxxxxxxxxxxx \lstset{ language=C, % choose the language of the code stepnumber=1, ...
6
votes
1answer
610 views

How to Format C Program Code Block Nicely

I am using the following settings to format my code blocks: % xxxxxxxxxxxxxxxxxxxxxxxxx Code Snippet STARTS xxxxxxxxxxxxxxxxxxxxxx \lstset{ language=C, % choose the language of ...
6
votes
1answer
178 views

Is it possible to change the font of line numbers in a code listing?

Using LyX I can add line numbers to my code listing. However, these are in the document (serif/Roman) font and look strange next to code blocks (Typewriter font). Is it possible to change the font of ...
4
votes
1answer
353 views

Treat a dotted suffix as keyword in listings

I'm writing C++ code in latex with listings. I'm trying to get listings to recognise the suffix .t() as a keyword (it means matrix transpose in the Armadillo C++ library). I tried to get the ., ( ...
2
votes
1answer
162 views

Listings not breaking up

I have a code listing as shown in the picture (number 4) that goes a bit out of the margin although breaklines=true. When I try to break new line it gives me an error Listings Error: lstinline ended ...
1
vote
1answer
279 views

How to obtain Sweave(l) listings with rounded corners?

I downloaded the Sweavel.sty-File from here: http://biostat.mc.vanderbilt.edu/wiki/pub/Main/SweaveTemplate/Sweavel.sty Now, for a modern look, I would like to produce rounded corners in the R code ...
5
votes
1answer
144 views

How to keep last n lines together in listing?

I have a large listing defined with lstlisting (listins-package). Now the listing reaches over three pages. On the last page there is only one line (the last line) of the listing. I looks not very ...
2
votes
1answer
176 views

Listings package does not break with mwrep document class

I cannot get listings package to break lines with any of the methods described in previous questions: Listings package does not break, ...
2
votes
1answer
195 views

How to define different spaces below float and non float listing?

I am using listings from the listings-package. I'm having a problem with spaces below the listings. I use both, float- with h and non-float listings. The problem now is, that the spaces below the ...
8
votes
1answer
1k views

Maple package for Latex

I'm translating the book PHYSICS WITH MAPLE by Wang. It contains some codes and outputs from Maple of course. I was wondering do we have a package such as mcode or matlab-to-tikz ( MATLAB) for Maple ...
0
votes
0answers
60 views

How to escape single quote in lstlisting? [duplicate]

Possible Duplicate: Package listings: Error “Undefined control sequence.” because of single-quote-symbol? How to escape single quote ' in lstlisting? I tried \' and ''' but ...