{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

0
votes
1answer
175 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
258 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. ...
6
votes
1answer
1k 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 ...
12
votes
3answers
6k 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
90 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 ...
6
votes
1answer
3k 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} ...
15
votes
1answer
400 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
553 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
2k 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
279 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
283 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
104 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
518 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
150 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
935 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
263 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
453 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
833 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
512 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
344 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
311 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
171 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
573 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
533 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
275 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
517 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
298 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
466 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
206 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
152 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
444 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
335 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
285 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
161 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
363 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
265 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
361 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
111 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
1k 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
22k 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 ...
10
votes
1answer
13k 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
791 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 ...