{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

6
votes
1answer
161 views

listings package and latex3 variable

I'm trying to change a custom environment from a lot of optional parameters to a ;-separated list (using this answer as a template and writing its main functionality as a latex3 macro). The macro ...
1
vote
1answer
435 views

Minted cross reference line

I used to use listings a lot but minted+pygmentize has outstanding output. However, there are a few features from listings that are hard to find in minted, like having the line numbers on the right. ...
3
votes
1answer
351 views

Moving from fancyvrb to listing – need to reconstruct my font settings

I have happily used the fancyvrb package with the Verbatim environment so far, but I want to change my figures to use the listing package with the lstlisting environment in order to have bold-faced ...
2
votes
1answer
1k views

Code in \lstlisting breaks document (compile error)

I want to show a JSON object in my document. If I do the following, it works: \begin{lstlisting} { "id": "5", "key": "discardedCard" } \end{lstlisting} But if I extend the code to the ...
3
votes
1answer
772 views

How to use multiple arguments in \lstnewenvironment

How can I have more than one optional argument to be passed to \lstnewenvironment? I only need a fixed number of options and all will be present. I want to pass the frame type and font size as ...
2
votes
1answer
602 views

How to correctly use equal sign in keywords for listings?

I work on a listings code style for HTML5. The style looks quite good but I have a little problem with the equals sign. I defined the equals sign as a keyword: ndkeywords={=, ... } This will cause ...
9
votes
2answers
587 views

Two code blocks working syncronously

I need two code blocks in my beamer frame. One will be the code and other will be the output for each line of code. I want to uncover each code line and corresponding output line. So, first it will ...
3
votes
1answer
555 views

Problem highlighting listings in beamer

I'm using listings inside beamer to typeset some Octave code. Because I want to apply overlay specifications to parts of the listing as I go through the slides (for highlighting purposes), I'm ...
4
votes
1answer
531 views

How can I create wrapper macro for lstinline?

Using \lstinline I can include inline code snippets in a paragraph. I would like to provide a macro that selects formatting, etc, for lstinline so I can just do, say, \codeinline{snippet}. I had ...
1
vote
0answers
40 views

\lstlistoflistings does not add spaces by chapter [duplicate]

I'm quite new in LaTeX and ended up with this problem: I'm using list of tables and list of lstlistings (\listoftables, \lstlistoflistings), both numbered by chapter. List of tables does add spaces ...
4
votes
1answer
111 views

listings package : highlight word composed by an alphabetic and a numeric part

I would like to highlight several keywords with an alphabetic and a numeric part with different color. My problem is the number of keywords can become huge from r0 to r191 for example. And I have ...
4
votes
1answer
840 views

Why keywordstyle is not taken into consideration no bold, no red color?

When I have this code with .sty file from here \begin{lstlisting}[language=Go, firstnumber=1, captionpos=b, caption=Golang, label=amb] // You can edit this code! // Click here and start typing. ...
5
votes
1answer
716 views

Line breaks in listings with long lines

This is a follow-up question to Line breaks in listings My MWE with a very long line demonstrate the problem: \documentclass{report} \usepackage{listings} \lstdefinelanguage{text}{} ...
2
votes
1answer
344 views

How to define HTML keywords in \listings

I'm working on the implementation of a HTML5 code style for \listings. Currently I have the problem that there are different ways to define HTML tags. In my example, I don't get /p in ...
4
votes
1answer
339 views

Command to insert filename in caption of a listing

I would like to have a command to insert listings that contain the filename in the caption. This works well as long as there is no "_" etc. in the filename. I also tried the suggestion from a ...
3
votes
1answer
828 views

minted list of listings and TOC conflict

I am using minted for source code highlighting. I want a List of Listings, and I want the List of Listings to itself have an entry in the main Table of Contents. I thought I could do this with ...
3
votes
1answer
736 views

How to use angle brackets for a keyword in \listings?

I've got a code of a HTML website that I want to show in my LaTeX document. The problem is, that the HTML code has a tag called <canvas> and the JavaScript code inside the HTML document has a ...
5
votes
1answer
664 views

How to use alsolanguage in \listings package?

I defined keywords for the JavaScript programming language and HTML. I have read that it is possible to use the keywords of both languages in a \listings code snippet. But in my example, the ...
18
votes
2answers
6k views

\listings code style for HTML5 (CSS, HTML, JavaScript)

I would like to create a code style for HTML5 that can be used with the \listings package. An HTML5 document consists of three languages: CSS, HTML and JavaScript. That makes the whole thing a bit ...
3
votes
2answers
2k views

Keyword-Highlighting of C++ using Listing

I have a little problem in my settings. I cannot locate the error and need some additional eyes to tell me where I should look. I use listing to show my c++ code but when I try to add additional ...
3
votes
1answer
342 views

regular expression in listings

I'm looking for a possibility to find a way to colorize data. If a text starts in a line with XYZ from that point until the next blank line the text should be set in a defined colour. With the comment ...
2
votes
1answer
634 views

How can I typeset Greek letters in listings?

Is it possible (and if yes, of course how) to use Greek letters within lstlisting (of the listings package)? However, \epsilon, for instance, puts of course exactly that and not a Greek epsilon. I ...
3
votes
1answer
1k views

LaTeX source code listing with less space between characters [duplicate]

I want to write shell Code in my LaTeX document. I'm using the listings package, with a code sample adapted from Tormod Fjeldskår: \documentclass{report} \usepackage{color} \usepackage{xcolor} ...
3
votes
1answer
466 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
788 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
619 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
89 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; ... ...
3
votes
1answer
518 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} ...
1
vote
1answer
365 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 ...
8
votes
1answer
265 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
202 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
559 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.
4
votes
1answer
896 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
465 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
436 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
271 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
77 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
489 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
501 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
177 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
276 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
94 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
566 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
87 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
809 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 ...