{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
97 views

odd displays of accentuated characters in lstlisting environment

when i try to write accentuated characters (éà...) in a lstlisting environment, hence : \documentclass{article} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{xcolor} ...
2
votes
2answers
137 views

Multiline listing within multicolumn row

I have a problem putting a listing (using lstlisting package) within a table. The problem is that I want to put a multiline listing in a row taking 2 columns. The following minimal example shows ...
3
votes
1answer
99 views

Changing lstlistoflistings title [closed]

I'm having difficulty getting the list-of-listings section to display the proper title, it simply says "Contents" no matter what sort of changes I make. Here is the command I put in the preamble at a ...
4
votes
1answer
57 views

Dynamically created program listing

Is there a way to have a easy to change value in program listing? Something along these lines: \newcommand{\variable}{2} And then having somewhere \begin{lstlisting} ... i *= \variable; ... ...
2
votes
1answer
94 views

lstlisting: mathescape and Erlang

I am trying to combine to use mathescape together with the Erlang syntax highlighting in the package lstlisting, as described in Section 4.14 of its manual: \documentclass{article} ...
0
votes
1answer
106 views

Bug? Colored frame in mcode package

While using mcode.sty, I recognized that at linebreaks with long comments parts of the surrounding frame got colored green or were even left white at using mathematical formulas, e.g. in the following ...
7
votes
1answer
132 views

Line breaks in listings

Is there a way like wrap the line after at most 60 letters but it should not break inside some commands like listings does? Example: \documentclass[a5paper]{article} \usepackage[T1]{fontenc} ...
1
vote
1answer
82 views

\lstinline break at punctuation

I need listing package (\usepackage{listing}) to break at punctuation namespace::subnamespace::class ^ ^ at either these two locations
4
votes
1answer
117 views

Creating a table around a java script code highlighted using minted

I would like to create a block around javascript code in latex. I use minted package for format highlighting. Here is my example code: \documentclass[]{article} \usepackage{minted} %opening ...
3
votes
2answers
207 views

How to use a colon in lstlisting keywords?

for the use of CSS code I've defined the following style: \lstdefinelanguage{CSS}{ sensitive=true, alsodigit={-}, keywords={transform, transition-property, transition-duration, ...
3
votes
1answer
238 views

How to add \lstlistoflistings to the table of contents?

can someone tell me, how to create an entry for the \lstlistoflistings command in the TOC? I want, that you can see the page number where the list can be found.
3
votes
1answer
196 views

How to tweak the LOF and LOT without using any packages?

The list of figures/tables in default book class looks like: Default looking: List of Figures 1.1 Snapshots .................. 2 1.2 Snapshots .................. 4 1.3 Snapshots ...
7
votes
1answer
209 views

Making Source Code Copyable with listings

I'm using listings to display some matlab code in my latex document but i'd like to have syntax highlighting. I've tried two ways of getting syntax highlighting and neither make the code copyable. The ...
0
votes
1answer
98 views

Standard single quotes for code in listings [duplicate]

In my code, I have curved quotes (see screenshot). Can I replace them with vertical quotes? This is my formatting code: \lstset{% % General design backgroundcolor=\color{lightgray}, ...
2
votes
0answers
49 views

Override properties of a predefined listing style

I use the listings package and I want to override an attribute of the HTML style. Unfortunately my code overrides the whole HTML style and not just a single property: \lstloadlanguages{HTML} ...
1
vote
1answer
60 views

How to use listings with multiple languages?

I've got a HTML document with JavaScript inside that I want to show in my article. For that I would like to use my JavaScript and HTML formatting. How can I get the listings package to use two ...
2
votes
0answers
44 views

Listings: Format part of a string differently (markup language inside a string)

I made a new language definition for a .NET template engine where part of the strings in the C# code are markup. Example: string templateString = @"{% for name in names %} Hallo {{ name }} {% ...
0
votes
0answers
24 views

Can I define styles of the listings package hierarchically? [duplicate]

Possible Duplicate: listings: General settings for a language seem to be overwritten/not respected With the listings package I can define styles or environments. Now I wonder if I can ...
0
votes
1answer
81 views

Can I mark specific lines in lstlisting?

I want to give listings and somehow mark a particular set of lines. My preference would be to make them italic. (The purpose of wanting to do this is so I can say "these lines are required but you do ...
6
votes
1answer
161 views

Treat grammar as listing

I have a grammar in my document using the package syntax like described in the answer to How to type a Backus-Naur form in LaTeX. Now I want it to be treated like the listings I have in my document. ...
1
vote
2answers
170 views

framebox does not work for lstlisting environment

I am looking a way to wrap something with a frame. I try different approaches but finally choose to use fancybox package and minipage (because I need to control the width of the frame). It works ...
0
votes
1answer
101 views

Changing code in listings dynamically

I need to change dynamically the code in the listing by adding just one key word to the code. I tried to do it like this: \begin{lstlisting}[escapechar=|] class MyThread extends Thread { private ...
3
votes
1answer
87 views

How to control latex appendix environment when placing R code in?

I am having a problem with latex environment. When I place r code using \begin{lstlisting} ... code..\end{lstlisting} other objects like tables are displayed only after the script subsections, despite ...
3
votes
1answer
59 views

bug in listings package?

It seems as if the listings package can not be loaded after all other packages using \AtBeginDocument \documentclass[]{scrbook} % \AtBeginDocument{\RequirePackage{listings}} \begin{document} ...
0
votes
1answer
101 views

Why does using lstinline inside mathescape inside lstlisting not work?

I'm trying to typeset some code. That code has some embedded mathematics, but in the embedded mathematics, I need to reference variables from the code. I would like for the variables in referenced ...
4
votes
1answer
62 views

test if a listings or glossaries style is valid

I want to test in my template if a call of \lstinputlisting[style=mystyle,... or \printglossary[style=mystyle,... is valid or will fail because of an unkown style. However I could no find out ...
3
votes
0answers
119 views

About autoindent and postbreak in the package listings

I am using the package listings to show my Matlab code. The code was pre-typed in a file and everything will be loaded from the file and a .tex file will be generated automatically to show the code ...
0
votes
0answers
70 views

Is that any way to make verbatim environment line breaking automatically and justify left and right [closed]

I am trying to show the text literally in verbatim environment with line breaking automatically. I Googled this and people recommended using the listings package. I am following the instructions in ...
4
votes
1answer
94 views

label within lstlisting prefix gives strange output on \ref

I have all kinds of labeltypes for my own convenience defined like "sec:", "cha:", "fig:", "lst:" and so on. Now I wanted to point to a certain line of code within one of my listings. There is no ...
2
votes
1answer
108 views

Define listings language using variable

I'm using the listings package to document excerpts from my programs. I have been creating new environments for the various programming languages and wondering whether there was a way to hack the ...
0
votes
1answer
62 views

Avoid page break in listing [duplicate]

Possible Duplicate: How can I ensure that a listing is not going to be split? My listing goes at the bottom of a page and fits good. But the header is separated and moved to another page. ...
2
votes
1answer
129 views

Center just one line of code (e.g. comment)

In my lstlisting I want to place a comment in the form of /*====== some section ====== */ but having it centered and not like the rest of the lines of code which are left aligned. Using the escape ...
4
votes
1answer
95 views

place symbol or some command on page break within lstlisting [duplicate]

Whenever I have a page break splitting my lstlisting on different pages, I would like to have a symbol or generally spoken some command inserted automatically. I can accomplish that manually by using ...
3
votes
1answer
95 views

text dropped after beginning of listing

How do I fix this haunting message? "text dropped after beginning of listing" In my preamble I use: \usepackage{listings} \lstset{basicstyle=\ttfamily,breaklines=true} Then within the document ...
3
votes
2answers
171 views

Continue line numbers in listings package?

I have been using the listings package to present my source code in LaTeX. However, I can't get the line numbers to continue between two separate user-defined listings that have been given the same ...
7
votes
2answers
189 views

How can I use line numbers with leading zeros?

I use the listings package for source-code and have read all documentation. However, it appears that leading zeros for line numbers are not implemented as standard option yet. How can I redefine the ...
2
votes
1answer
69 views

Getting lbr frame lines in a listing up to the caption box above it

I have a document similar to this: \documentclass[twoside,11pt,titlepage,a4paper]{report} %unterscheidung zwischen gerade und ungerade seite, 11pkt, kp, kp \usepackage[T1]{fontenc} %inputcodierung ...
3
votes
0answers
142 views

Enforce a line-break inside \lstinline

I use \lstinline{foo} from the listings package to set pieces of code in regular text. To get automatic line-breaks I use the following options: \lstset{ breaklines=true, breakatwhitespace=true, ...
5
votes
1answer
166 views

is it possible to add line numbers to input files read using \verbatiminput?

I know one can use \usepackage{listings} which supports line numbers. And I use that for pdf files. But I also generate HTML using Latex2html, and l2h does not support this package. It only supports ...
2
votes
2answers
194 views

listings: General settings for a language seem to be overwritten/not respected

I struggle with the following listings styles. I have code of two different languages (R and LaTeX) in my .tex file. As some settings are the same for R listings and LaTeX listings, I define the style ...
2
votes
1answer
85 views

Watermark with LstListing

I'm trying to add a draftwatermark to my document, but I'm having some problems with lstlisting. Whenever I've used lstlisting (for C++ code), the background of the code section is white and ...
2
votes
1answer
122 views

Inline listing for LaTeX code: language definition fails

I would like to define a command which produces inline LaTeX listings via the package listings. However, the language definition for LaTeX contains [] which seems to be the cause of the error: ...
2
votes
1answer
106 views

Something wrong: LaTeX with listings

I'm trying to get green comments and blue javadocs. But with this code I can't get blue javadocs, always I get all comments green: \usepackage{color} \definecolor{gray97}{gray}{.97} ...
0
votes
0answers
61 views

Error while using lstlisting [closed]

I don't know why I get an error related to this code: \begin{lstlisting}[framexleftmargin=0mm,basicstyle=\ttfamily\small,breaklines,columns=fullflexible] xp_sendmail {[ @recipients= ] 'recipients [ ...
7
votes
1answer
178 views

Using \lstinline inside a \item

I know about the fragility of verbatim-like commands, and that they should not be used as an argument of another macro, but a need to write a description environment in which the terms to be defined ...
1
vote
2answers
97 views

\begin{lstlisting} is overflowing?

I have done everything correctly but my \begin{lstlisting} is overflowing and I did not find any method to stop it. Plz help \begin{enumerate}[(b)] \item To generate a 128bit WEP key. We have added ...
0
votes
1answer
104 views

List a CMake file

Does anyone have/know of a style file for the listings package which would enable the correct syntax highlighting of cmake files in LaTeX?
4
votes
1answer
362 views

Including XML file into LaTeX

I am using LaTeX for very first time and have very basic knowledge about it. I am using the template from here to write my thesis. I am using Ubuntu 12.04. When I try to include a small XML file in ...
5
votes
1answer
89 views

Change listing number separator

I am working with the listings package and trying to change the separator from the default period to a hyphen. However, I cannot seem to figure out how to. I tried the code snippet below, but it ...
8
votes
1answer
241 views

Inconsistent output for R language operators when using listings package

A referee noticed that the <<- (assignment to a global) and %*% (matrix mult.) operators in a code listing I used were wrong. I am using the standard listings package (version 1.4 dated ...

1 2 3 4 5 17