{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
2answers
105 views

Title of listing is missing

I am using the listings package to mark-up C and Assembler code. Unfortunately the title of the listing is missing (the same with the caption=... command). In the document section I using my clisting ...
3
votes
1answer
232 views

\lstinputlisting does not respect the \lstset 'float' option

How can I force \lstinputlisting[...]{filename} to obey all parameters set by \lstset? (Note the float option given to the TeX example, but not to the LaTeX example.) ...
3
votes
1answer
99 views

texcl and range prefixes in listings with shorter comments

I'm trying to use the line range markers from the listings package to include sections of code. I'd previously been using actual line numbers, but based on the answer to this question, I've been able ...
3
votes
1answer
346 views

Markup Haskell sources in complex structured document with `lhs2TeX`

Simple task Suppose there is a example.tex file with Haskell listings: \documentclass{article} \usepackage{fancyvrb} \DefineVerbatimEnvironment{code}{Verbatim}{fontsize=\small} \begin{document} ...
3
votes
1answer
247 views

listings range end markers in comments with texcl

I'm trying to using the listings package to generate nice listings of some Lisp-style code (where line comments begin with a ;). I'd like to keep the code compilable, and so put the range markers ...
3
votes
1answer
799 views

LaTeX - Using commands inside inline code

I want to be able to have inline code (printed in typewriter or something) where I can also use LaTeX commands like \myinlinecode{here comes a backslash: <\textbackslash>}. So it should be ...
3
votes
1answer
193 views

Use pxfonts in listings only

I really like the pxfont package for displaying code in listings. I would usually just do this to load pxfont for the entire document; \usepackage{pxfonts}. However, this time I am required to use a ...
3
votes
1answer
509 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 ...
3
votes
1answer
516 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
125 views

Auto include specific part of source files

I'm creating a lot of code to our small projects (in computer science), and finding myself copy/pasting my comments into the document. Would it be possible to make a reference point in the code file ...
3
votes
1answer
313 views

linerange reference in lstinputlisting

I have a listing that refers to my c code; I would like to reference the code using commented section in the code, as seen in the code example bellow. I have created a list style which does this, but ...
3
votes
1answer
245 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 ...
3
votes
1answer
678 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 ...
3
votes
1answer
209 views

Headers and footers for listing environment?

What I need to be able to do is apply a header and footer when I use the listings environment. I have a few requirements: The header and footer should be outside the listing itself, i.e. they are ...
3
votes
1answer
697 views

Latex listings R: need mono-spaced font with bold keywords and correct caret (^)

I am using the listings package to display R code. I would like a monospaced font, bold keywords, and I would like code that works when the user cuts and pastes from the pdf file into rstudio. The ...
3
votes
1answer
874 views

Problem with alignment in listings

I have a follow up question to this post I am using listings in beamer. The content in listings is being pushed further left than the other contents on my slides. I am using the code below to correct ...
3
votes
2answers
601 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 ...
3
votes
1answer
483 views

Visual separation when using linerange in listings

I have read through the listings documentation and couldn't find an answer to the following question: How do I insert some sort of visual feedback in a listings listing when using the linerange ...
3
votes
1answer
2k views

How to highlight own keywords in HTML lstlistings?

I would like to highlight some words in a lstlisting. The language is HTML. However, \emph seems not to be working with HTML. Any suggestions how I could work around this problem? Right now I have: ...
3
votes
2answers
2k views

How to use a comma in lstlisting keywords?

I am creating a language for the doxygen tool. I need to create a set of new keywords. When I try to use the comma in one of them, it does not highlighting. I protect comma with a backslash, but it ...
3
votes
1answer
2k views

How to increase the padding in the code snippet box when using `listings`?

So I am writing a book on Awk programming language, and I have enabled a single frame via \lstset{frame=single}. However, I would like the code within the snippet box to be further away from the frame ...
3
votes
1answer
833 views

Custom numbering of listings

I have a number of listings in my document, numbered 1, 2, 3 and so on. I need a table with three listings (say, three different variants of the same algorithm), that will be numbered as 2a, 2b, 2c. ...
3
votes
2answers
1k views

Listing inside tabularx?

I have a tabularx environment where I want to put an lstlisting into. But Latex fails to compile it. Testcase: \documentclass[a4paper,12pt]{scrreprt} \usepackage[utf8x]{inputenc} ...
2
votes
2answers
54 views

Counters for Chapter and Section environments when using tcolorbox for listings

This is a followup question of this question. With my MWE I'm getting wrong Listing numbers, wrong toc (including Chapter and Section environments from listings) and wrong bookmarks in pdf toc. Any ...
2
votes
1answer
40 views

Highlight line numbers in listings, conflict with hyperref package

I want to highlight the line numbers of the lines of the Listing to which I refer. See the question Highlight line numbers in Listings for details about how to highlight one line number. Now I want ...
2
votes
1answer
94 views

How can I insert a thin space (\,) in a listing?

Is it possible to create small space in listing? I tried / and \, but it doesn't work in listing environment \begin{lstlisting}[caption={Inicializace ELM327.}, label={lst:initELM},captionpos=b] ...
2
votes
1answer
76 views

Coloring ) in listing [duplicate]

I'm trying to create a style using for coloring \ and brackets in code sample (PStricks) using the listings package; I tried using the answer given by Marco Daniel in this question using literate for ...
2
votes
0answers
56 views

Problem with Listings package concerning line breaking and wrong alignment [duplicate]

Hello I have the following code: \documentclass[12pt]{article} \usepackage[top=0.3in, bottom=1.5in, left=0.8in, right=0.8in]{geometry} \usepackage[utf8]{inputenc} \usepackage{setspace} ...
2
votes
1answer
88 views

How can I highlight a freestanding regexp in string style?

I'm using listings to format a piece of JavaScript code, and I met a problem for the following code: ... regex = /abc/; ... ratio = 1.0/2.0; ... I want the regex is highlighted as a string, but if ...
2
votes
1answer
67 views

inline code listing runs into right margin

I am trying to typeset an inline C# code listing using the listings package. However, the chunk of inline code spans a few lines, so listings has to insert a coupe of line breaks into my code. So far, ...
2
votes
1answer
462 views

listings doesn't print my keywords bold in lstlisting

I've got the following problem: I want to print a listing with the listings package and lstlisting: \documentclass{scrreprt} \usepackage{listings} \begin{document} ...
2
votes
2answers
431 views

Including HTML code side by side in Latex [duplicate]

I want to write HTML codes of two pages side by side in LaTeX like as follows: <html> <html> <head> <head> </head> </head> <body> <body> ... ...
2
votes
1answer
198 views

adjustbox and lstnewenvironment

I'm trying to use adjustbox to make a frame around listings (I know that listings itself can do this, but its implementation produces sub-optimal results when the line heights are not equal throughout ...
2
votes
1answer
2k views

Add keywords to an existing language in listings

I've already read extending a language with additional keywords and I have found kind of a solution, but I'm not quite sure if it's the right way and if I won't have problems in the future. The ...
2
votes
1answer
628 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 ...
2
votes
1answer
283 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
607 views

LaTeX listing of command line syntax

I have a LaTeX document using the listings package for some bash scripts. I'd like to create a different styling for text that is meant to show the syntax of a command. For instance, I have the ...
2
votes
1answer
277 views

\lstinputlisting of a whole java project

I'd like to print the complete source code of my java project, which has multiple .java files in several packages (i.e. folders), many .properties files and many .xml files, and others. I want to use ...
2
votes
1answer
325 views

How to escape backslash in rangeprefix?

I want to escape backslash to be used as a rangeprefix as follows. The current MWE does not work as expected because it still imports all codes rather than the codes sandwiched by document ...
2
votes
1answer
206 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 ...
2
votes
1answer
2k views

Lstlistings: Getting pretty equations in display mode

I am currently trying to print my algorithms using the listings package. For clarity I always try to display the more complex mathematical expressions as formula instead of plain code. This results in ...
2
votes
1answer
972 views

Using the “combine” document class with the listings package

I am trying to use the combine document class (manual) to combine several pre-existing documents into a single file with consistent formatting. It works great, except that there is a conflict of some ...
1
vote
1answer
49 views

How can I highlight keywords with special characters or numbers in them?

In the following MWE the declared keywords te-st and 999 are not highlighted as expected: \documentclass{scrartcl} \usepackage{listings,xcolor} ...
1
vote
0answers
77 views

listings frame for multiple page code [closed]

My code is really long. And I really want to use the frame Shadowbox in my code. But the problem is since it is going over a single page, the box is actually completing at the end of the code ...
1
vote
1answer
163 views

\lstinline break at punctuation

I need listing package (\usepackage{listing}) to break at punctuation namespace::subnamespace::class ^ ^ at either these two locations
1
vote
0answers
33 views

Mixing multiple programming languages with different styles in same document [duplicate]

Possible Duplicate: Defining lstset parameters for multiple languages What's the easiest way to include code, using listings, from more programming languages? \lstset{ % language=Python, ...
1
vote
1answer
176 views

Combine listings package with my own enviroment [duplicate]

Possible Duplicate: How to use different lstset settings for listings? I have defined my own enviroment as: \newenvironment{codegui}[3]{% \def\tmplanguage{#1}\relax ...
1
vote
1answer
199 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 ...
1
vote
1answer
685 views

Code fails with Emergency stop, when using \expandafter\csname and such in listings

I am further working on my code for LaTeX Examples. I want to use the package showexpl for the simultaneus printing of code and results. Unfortunately I get an '! Emergency stop.' ...
1
vote
1answer
244 views

How to make my unusual environment accept one argument?

I cannot find a good title to express my question. Therefore, please parse the following code first. Minimal Code \documentclass[dvips,dvipsnames,cmyk,table]{book} ...