{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

8
votes
1answer
258 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
195 views

\lstinline break at punctuation

I need listing package (\usepackage{listing}) to break at punctuation namespace::subnamespace::class ^ ^ at either these two locations
5
votes
1answer
529 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 ...
4
votes
2answers
1k 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
3k 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
838 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 ...
9
votes
0answers
463 views

Making Source Code Copyable with listings [duplicate]

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
1k 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}, ...
5
votes
1answer
406 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
257 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 ...
1
vote
0answers
76 views

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

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
1answer
475 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
484 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
3answers
1k 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
175 views

Changing code in listings dynamically [closed]

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
268 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
93 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
526 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
86 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 ...
5
votes
1answer
746 views

About autoindent and postbreak in the package listings [closed]

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 ...
5
votes
1answer
2k 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
303 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
135 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
511 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
238 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 ...
6
votes
1answer
1k 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 ...
4
votes
2answers
2k 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
514 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
160 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 ...
7
votes
1answer
1k 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
373 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 ...
3
votes
2answers
888 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
190 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
429 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
221 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} ...
13
votes
2answers
1k 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
204 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
312 views

List a CMake file [closed]

Does anyone have/know of a style file for the listings package which would enable the correct syntax highlighting of cmake files in LaTeX?
6
votes
1answer
5k 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
166 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
389 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 ...
3
votes
1answer
3k views

Set my lstlisting at the exact place in my code (like “h” for figure)

When using lstlisting, my displayed code is sent back on the top of my page. I would like to have the same kind of option as: \begin{figure}[h] ... \end{figure} ie having displayed my code exactly ...
16
votes
4answers
11k views

language option supported in listings

I am afraid that listing doesn't support javascript. \begin{lstlisting}[language=javascript] ... \end{lstlisting} What am I doing wrong?
4
votes
1answer
282 views

Multiple caption names for listings code (lstinputlisting) based on type of code

In my document I have used: \renewcommand\lstlistingname{Algorithm} \renewcommand\lstlistlistingname{Algorithms} to rename my lstlistings titles. The problem is that now I want to add a different ...
1
vote
1answer
90 views

strange behaviour same code but in different chapters

I've just come accross a problem I'm unable to solve. I use this code in chapter 2 and it all works fine : \begin{ttfamily} \begin{lstlisting} <?php $template = 'blue.php'; if ( is_set( ...
2
votes
1answer
476 views

Exclude listings from LoL

Is there a way to exclude a specific listing from being printed in the LoL? I put one in a figure environment for the sake of not being printed on two seperate pages. But now I have the figure as well ...
4
votes
1answer
84 views

Listings WriteFile adds additional line if content contains two spaces between words

I use the listings latex package to write/read the environment body to a file. But if in the environment are two spaces between some words, there is an additional linebreak added at the beginning (I ...
0
votes
1answer
289 views

Listings and multiline labels

I wish a multiline label in the lstlisting environment. I would like to reference more than one line within the same listing. Can you help me to find a solution? I have found this link but this only ...
1
vote
0answers
868 views

How to force LaTeX to place a figure exactly where I want [duplicate]

Possible Duplicate: Force figure placement in text How to influence the position of float environments like figure and table in LaTeX? How can I force LaTeX to insert a figure exactly ...
5
votes
1answer
116 views

Conflict between listings and gb4e?

this code doesn't compile for me. Could it be a bug or is something wrong with my LaTex installation? \documentclass{article} \usepackage[T1]{fontenc} \usepackage{gb4e} \usepackage{listings} ...