{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
1k views

How to render XML tag brackets bold with listings package?

I'm currently using the listings package to render my XML snippets. The default XML language settings recognize elements, attribute and text properly and my style is set to render tag names bold, ...
1
vote
1answer
2k views

Listing of a file with underscores in its name/path

I am writing a report with LaTeX and I need to list some source code. One of the files has some underscores in its path/name. When compiling the following line : ...
5
votes
1answer
689 views

Highlighting strings between [ and ] in lstlistings

I want to use lstlisting to present a file like this: #comment [keyword] key1=value1 key2=value with RegEx [keyword:NewKeyword] key1 = value1 key2=value with RegEx and this is my language ...
9
votes
1answer
4k views

lstlisting in two columns

I would like to have two listings, side by side. They have approximately the same length, therefore I don't care about how it's layed out if one part is longer. I tried \begin{minipage}{\textwidth} ...
3
votes
1answer
214 views

Multiple listings using range markers and PGF's \foreach

I've been trying to include multiple code snippets from a unique source file by using listings's range markers (named lines) and PGF's \foreach macro: \foreach \x in {1,2,...,8} { ...
4
votes
2answers
2k views

How can I put lstlisting block into subfloat block?

I'm trying to compile my document but it's exploding. I've narrowed it down to this section: \begin{figure}[h] \caption{These are my awesome code snippets} \subfloat[This code runs every cycle.]{ ...
1
vote
1answer
153 views

Listing not printing inside “ ” [duplicate]

Possible Duplicate: Listings package not correctly showing PHP strings I'm using listings to include C code, but I've a problem: when I insert in the listing a printf like the following ...
14
votes
2answers
1k views

Coloring digits with the listings package

I'm trying to typeset some python code, and I would like integer literals to be highlighted. I've come up, after about two hours of fighting with the documentation and various other questions here and ...
4
votes
1answer
5k views

lstlisting: how to set code color and frame color

I am using lstlisting to show some code in my PDF. The problem is that when I use: basicstyle=\fontfamily{pcr}\selectfont\footnotesize\color{red}, to change the code color (not only the language ...
2
votes
1answer
932 views

Frame on lstlisting opened on the bottom when code longer than one page [duplicate]

In my \lstset I have: \lstset{ language=Java, % the language of the code basicstyle=\sffamily\large, % the size of the fonts that are used for the code %numbers=left, ...
1
vote
1answer
188 views

Using package listings with sciposter

Could you please provide a working example in which a source code delimited by listings environment word wraps its lines, without breaking the column layout of sciposter? Whenever I put a long line ...
2
votes
1answer
441 views

babel package and lstlisting caption incompatibility

I am using babel package for Turkish language and I also use listings package. A code sample for one of my listings is as follows: \begin{lstlisting}[label=some-code,caption=Poo Class] public class ...
8
votes
2answers
5k views

Setting up specific font for use in listings

I'm writing my dissertion using TeX. I would like to use a specific font in my lstlisting source code. How can I use a specific font like Monaco or Arial? I usually found solutions with basicstyle ...
15
votes
3answers
7k views

Using \lstinputlisting to include a file but only certain lines or line ranges

I wanted to tidy up a TeX document and was curious if you can use \lstinputlisting or a similar function to include a certain part of a source-code file. Example, I have a 500 or so line source file ...
1
vote
1answer
355 views

Listings settings for command line arguments [closed]

I am typesetting a set of instructions which includes several (Unix) command line arguments. I have been using the listings package to include these arguments, but the colouring is less than ideal. ...
12
votes
3answers
2k views

\autoref does not capitalize initial character in sentence when referencing label in listings environment

I have defined the following \providecommand*{\lstnumberautorefname}{line} and within my text \begin{lstlisting} |\label{sdd_1}|<sqlCallStatistics>YES</sqlCallStatistics> ...
5
votes
1answer
406 views

Narrow underscore in listings package

I've been using the listings package for a while, but have only recently noticed that the underscore is rendered with less width than the other characters. I'm working on some code snippets now which ...
1
vote
2answers
907 views

LaTeX listing counter counts with every \pause-command?

I'm writing a TeX-File for a beamer presentation and have a problem with the \pause-command and the listing counter: The Listing counter increments its count with every \pause command – although I ...
4
votes
1answer
727 views

Suppress line numbering for specific lines in listings package

I would like to suppress the line numbering for specific lines in listings package by identifying the specific lines using some kind of command.
5
votes
1answer
3k views

Fortran syntax highlighting in listings

I've got some Fortran 90 source code I want to put into my thesis appendix. For this I'm using the listings package. Is it possible to have colored syntax highlighting for the Fortran code?
6
votes
2answers
1k views

Suppress line numbering for empty lines in listings package

The listings package quite nicely formats my pseudo code listings. Is there a way that one can specify that line numbering should be suppressed for empty lines?
2
votes
2answers
4k views

Frame around minipage containing listing in beamer

I am working on the sheets of a course on LaTeX and would like to have several sheets in which you see on the left an example of a source document and on the right its output. I have this working now ...
2
votes
1answer
3k views

lstlisting environment ignores tabs

I have this LaTeX code: \lstset{ language=Java, tabsize=8, keepspaces, extendedchars=true, rulecolor=\color{black}, basicstyle=\footnotesize, aboveskip=5pt, ...
10
votes
2answers
17k views

set the font family for lstlisting

I have the following set up for my listings : \lstset{basicstyle=\footnotesize,breaklines=true} \lstset{framextopmargin=50pt,frame=bottomline} I would like to change the font family to Courier. ...
2
votes
2answers
300 views

Wrong numbering of lines in lstlistings when using escaped commands

I'm using the listings package to format some Java code in my document. I want it to number lines (1 number every 5 lines), and I need to highlight some keywords inside the code with the following ...
3
votes
2answers
515 views

How listing and verbatim do to escape special character?

I use one macro to display text using texttt style. For the moment this macro is very basic. For example, if I want to use the character _, its catcode must be changed. Is there a clever way to ...
11
votes
3answers
1k views

How to deal with very long lines that do not contain spaces?

I have a problem with a lstlisting environment. I want to use it for displaying several very long lines that can not be reformatted. Independently of the option breakatwhitespace=true or false my ...
5
votes
1answer
359 views

What are these weird symbols showing up in my source code listings?

I have a LaTeX document, and am trying to embed some Java code via the listings package. I have the following LaTeX source: \documentclass{article} \usepackage{listings} \title{Sample Document} ...
15
votes
1answer
635 views

listings package changes hyphens to minus signs

The listings package transforms source-code hyphens (-, U+002D) into minus signs (−, U+2212) when using the default proportional fonts, though not when using the default monospaced typewriter font. A ...
20
votes
4answers
9k views

Using \ttfamily with \bfseries (or how to enable bold in fixed-width font)

I'm using listings package, and I've added basicstyle=\ttfamily\footnotesize. However, when I do that, the keywords from the embedded source-code are not bold anymore. I figured that \ttfamily ...
15
votes
3answers
10k views

Shrinking monospace style for listings package

I am working on a thesis and putting together a "pretty" listing. I'm looking at setting up a small font style for a code view. What I have here is: \usepackage{listings} \lstset{language=C, ...
4
votes
1answer
562 views

How to modify the equivalent of \thefigure for listings?

In my appendix I have figures and listings. The figures are now labeled very well (see this question). Now I have the same issue with listings: in the appendix it is labeled as A.1, but in my text ...
2
votes
1answer
2k views

Add html preformatted text into latex

I am writing my thesis using LaTeX, and a would like to add some code in it. I tried so far the listings by I am not satisfied with the result. Is there a way to add a pre-formated code in HTML into ...
2
votes
1answer
1k views

“Wrong” numbers while referencing lstlistings in text

I'm using the lstlisting package to put sourcecode in my pdf file: \documentclass{scrbook} \usepackage{listings} \lstset{ % language=xml, basicstyle=\footnotesize, % the size of the fonts that ...
13
votes
1answer
1k views

Listings package: How can I format all numbers?

I want to highlight all the numbers appearing in an input code of a certain program by, for example, coloring them. By numbers I mean integer, rational and floating point numbers. I am trying with the ...
3
votes
1answer
315 views

How to remove the skip after a listing when “\parskip” is increased with “\baselineskip”?

I've increased \parskip with \baselineskip to use the "skipped" paragrahs style instead of the default "indented" style. However, this causes all listings to automatically include a baselineskip ...
4
votes
1answer
608 views

How can I create my own listings style/format?

I'm trying to format some SQL statements using the listings package. It looks OK for small statements but the long ones look bad. select * from Customers where C_nID=10; to select * from customers ...
8
votes
3answers
361 views

Masking \end{lstlisting}

I am not sure if I am using the right wording in title. Basically what I need is to add the following source using the listing package. In preamble: \usepackage{listings} then and is here when I ...
4
votes
1answer
492 views

lstlisting produces empty row when used inside a tabular

Is there any way I can get rid of the empty new row produced by lstlisting inside a tabular? Here's a minimum working example: \documentclass[11pt]{article} \usepackage{listings} \lstset{ ...
11
votes
2answers
2k views

How to automatically include command line session output in documents?

When I write documents that contain source code examples and snippets the listings package is a great solution to include such things. Especially with the \lstinputlisting command and ...
0
votes
1answer
353 views

Highlighting line ranges in listings

I've put here one adaptation for "no-beamer" documents of this code. Thanks a lot for the indications given below by Daniel. % Sources : % 1) ...
10
votes
2answers
885 views

How to align comments with lstlistings?

I am using listings with these settings: \lstset{language=C++,basicstyle=\small\sffamily, numbers=none, frame=tb, columns=fullflexible, showstringspaces=false } I like the proportionally ...
4
votes
2answers
3k views

\lstinputlisting will not continue to next page

So I have this LaTeX snippet: \section{Appendix} \listoffigures ... \begin{center} \begin{figure} \caption{MacroCell with 8 AND Gate Arrays} ...
8
votes
2answers
239 views

How to add listings environment to DTX files

I am working on my first DTX file and want to add a code example, which shall be printed with listings. This works so far, but since the documentation is commented the listings code is using a full ...
3
votes
1answer
833 views

Way to present programming code side by side to show the differences to the reader?

I am trying to make a side by side comparison of the result of listing-mode and minted-mode for a piece of Ruby and Java-code. I have problems making this look 'side by side'. Any suggestions to make ...
9
votes
1answer
698 views

Highlighting line ranges in a lstlisting: partial solution, but expansion issues

In my quest for a better solution for How to change appearance of a particular line when using \lstincludelisting, I came across the linebackground= option Martin Scharrer added to the listings ...
6
votes
1answer
802 views

How to redefine \lstinline to automatically highlight or draw frames around all inline code snippets?

How to redefine \lstinline to automatically highlight or draw frames around all inline code snippets? E.g. using \bh and \eh commands from Highlight text in code listing while also keeping syntax ...
2
votes
1answer
183 views

Listings, problem with rendering embedded strings

this is my style defined for C#: \lstdefinestyle{CSharp}{ language=[Sharp]C ,captionpos=b ,columns=fixed ,morekeywords={var,get,set} ,basicstyle=\footnotesize\ttfamily ...
0
votes
1answer
293 views

listings package - including textfile - tabstops wrong [closed]

In MikTex with \usepackage{listings}, when including a textfile into a pdf-document using \lstinputlisting[]{textfile.xt} then ocassionally, the display of the tabstops in the created pdf-file ...
0
votes
1answer
336 views

Display FASTA File in LaTeX [closed]

Is there a proper way to show a FASTA file in LaTeX? So far I tried $'s or listings and TeXshade but this does not seems to work.