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

Subimport star breaks listings languages

\subimport*{}{} from the package import seems to break listings languages, but only if listings with a language hasn't been used in the root document: ! Package Listings Error: Couldn't load ...
4
votes
1answer
224 views

Can the listings package be set up to highlight Prolog code like minted does?

I am interested to know how listings can be customized to mimic the Pygments's Prolog lexer (i.e. make Prolog code represented by listings look the same as it is done with minted) I previously asked ...
4
votes
1answer
94 views

Listing removing horizontal lines and autocrop to the size of code fragment

I am trying to include the code in my presentation. There are two things that I need to fix: there are horizontal lines appearing between the code lines I do not want to use the entire page, need to ...
4
votes
2answers
113 views

How to make a minted code listing centered on a page?

So, I am writing a report with Prolog code listings in it. I have been using lstlisting to make my listings and I made my code centered on the page, such as this: \renewcommand{\figurename}{Listing} ...
5
votes
2answers
215 views

graphic in tcblisting

I'm using the package tcolorbox to create a file with examples Latex, I have reviewed the options tcblisting environment and use these: text outside listing listing outside text listing above text ...
8
votes
0answers
167 views

Why should \lst@definelanguage be preferred over \lstdefinelanguage in a style file? [closed]

The listings manual (v1.5b, subsection 4.18) recommends using \lst@definelanguage instead of \lstdefinelanguage in a style file: Where should I put my language definition? If you need the language ...
4
votes
2answers
128 views

How can I reverse the caption numbering in listing

How can I make a reverse numbered caption with listings? So the package makes ''Listing 1.1'' style captions but I need it in form ''1.1 Listing'' .
6
votes
2answers
163 views

Use listings with different languages in same code block

My goal is to have a somewhat large verbatim block and use listings to give syntax highlighting to only particular parts. Here's a toy example: \begin{verbatim} How to include files in: C: ...
6
votes
2answers
180 views

How can you highlight a C compiler directive spanning multiple lines?

In my \lstset{...} I have morecomment=[l][{\color[rgb]{0.1, 0.2, 0.8}}]{\#}, which I've seen used to give preprocessor commands colour. This works just fine but I'd like to get multi-line macros to be ...
3
votes
1answer
133 views

Code listing in subfigure using lstlisting

I am trying to use the subfigure package of LaTeX to display a piece of SQL code. The purpose is similar to Code listing in subfigure, but I'd like syntax highlighting using lstlisting environment ...
2
votes
0answers
56 views

penalize page breaks in \lstlistings

I have a document with some rather lengthy \lstlisting's (source code snippets). It looks really bad if there is a page break within a listing/snippet. Thus I tried to avoid page breaks in listings by ...
16
votes
1answer
151 views

How to strip a listing of all (line and block) comments without leaving white space?

I'm looking for an easy and robust way to strip all the comments from a listing. My approach (passing \@gobble to the commentstyle key) correctly removes all the one-line comments and block comments. ...
2
votes
1answer
281 views

Rendering VHDL in latex

I have a VHDL code which I want to insert into my latex document. I need a package that takes care of syntax highlighting, indentation etc. Is there a package which serves this purpose?
0
votes
1answer
275 views

including python code in beamer? [closed]

Suppose I have a python file. How can I include in beamer presentation in one of the slides? \insertcode{"Scripts/mc.py"}{Python} does not work with \usepackage{listings} , which otherwise work in ...
8
votes
3answers
287 views

Listing background broken by \colorbox and \framebox

I am using listing environment (listings package) with the background parameter. I want to highlight some lines of code and I am using the \colorbox, \makebox and \framebox to achieve this. However, a ...
3
votes
1answer
809 views

Package hyperref Warning: Token not allowed in a PDF string [duplicate]

My document contains section titles that are formatted by the listings package. (The section names are names of configure script switches.) ...
8
votes
1answer
170 views

Different colors for default and language-specific listings

I'm generating pdf documents using knitr and pandoc. The conversion is mostly automated from R markdown -> markdown -> latex -> pdf. However, my documents combine R source code and its output, and I ...
9
votes
2answers
241 views

Can the listings package highlight by regexp?

I'm trying to typeset SuperCollider code using the listings package. Any "freestanding" identifiers that begin with a capital letter are class names, and should be highlighted; by "freestanding", I ...
8
votes
1answer
227 views

How can I automatically highlight SuperCollider symbols and environment variables?

I've been poring over the listings manual, trying to figure out how to get some very specific types of formatting for the SuperCollider language. I need to highlight words where the opening delimiter ...
6
votes
1answer
99 views

How can I test the first character on each line of a listing?

The listings package defines a hook called EveryLine to allow users to execute TeX code at the beginning of each line of a listing; the following is taken directly from the listings source code ...
2
votes
1answer
59 views

Listings on multiple pages - keep number like Continuedfloat

I have the following code: { \lstset{language=C, basicstyle=\tiny, tabsize=3, frame=lines, breaklines=true, breakatwhitespace=true} ...
5
votes
1answer
90 views

What's up with the tag key?

Subsection 4.18 of the current listings documentation (2013/08/26 Version 1.5b) describes a key called tag. That key is used in lstdrvrs.dtx, which is a file that ships with listings and takes care of ...
4
votes
1answer
129 views

How to handle listings, fancyvrb, newfloat and caption?

I am planning a "small thesis" for university which will need to display lots of code (C, C++, gnuplot, LaTeX, ...) - thus I spent this evening reading about listings and fancyvrb. The latter I've ...
3
votes
1answer
93 views

messy/overwritten numbering in enumerate tag

I have the following in my LateX code: \begin{enumerate} \item \begin{lstlisting} ...
3
votes
1answer
88 views

Lstlisting in twocolumn document

I have a problem when using lstlisting in twocolumn document. At my university I have to make reports in twocolumn documents. My teacher send me pre done .tex file with this code in it: ...
4
votes
1answer
67 views

Changing side of line numbering in two columns documents part two

I have the same question as this one: tex.stackexchange.com/questions/9510/changing-side-of-line-numbering-in-two-columns-documents/ I'd like to use the listings package in a twocolumn document. An ...
7
votes
1answer
149 views

Display of source code in customised (IDE-like) format in PDFLaTeX

I want to put some “C” source code snippets in latex (I am using PDFLaTeX), but I don’t get the result that I want using the “listings” package. What ideally would like to get is the same result as ...
7
votes
1answer
84 views

Problems with amsbook, lstdoc, and sections

The code \documentclass{amsbook} \usepackage{lstdoc} \begin{document} \chapter{Chapter} \section{Section} \end{document} produces the error messages Missing } inserted. [\section{Section}] and or ...
4
votes
1answer
91 views

Why is this \def not working as expected?

I am having a weird problem with \def. I am new to (La)TeX and can't figure this out. I have a simple code as follows. \documentclass[10pt,a4paper]{article} \usepackage{listings} \begin{document} ...
2
votes
1answer
48 views

Remove heading lslisting multiple pages

Hi guys I have a problem with lslisting because the code spans over multiple pages. I really hope you can help: How can I remove the heading (BILIAG A. APPENDIKS)? Here is a minimal example of the ...
2
votes
1answer
62 views

Signature below listings

How can I put automatic signature below my code listings. Now I put my code listings like this: \begin{lstlisting} MY CODE \end{lstlisting} Settings of listings: \usepackage{color} ...
1
vote
0answers
20 views

Change language of caption in lstlisting [duplicate]

When I define a caption in lstlisting, LaTeX writes, for example, "Listing 1.1: ..." but I want to change the "Listing" to another language. How can I do this?
7
votes
1answer
111 views

Listing within tcolorbox: how to adjust width to the natural listing width?

I would like to create a tcolorbox whose width is computed based on the longest line I have in listed code. I know it is possible to adjust the width with respect to the title. Is it also possible to ...
3
votes
1answer
105 views

Floatable centered and non-splittable lstlisting

I've been looking around and tried various setups but have yet to found the solution. I'm trying to define a lstlisting environment that is a float, is centered in the page, and cannot be broken ...
2
votes
2answers
124 views

Put figure and listing side by side [duplicate]

I'm trying to put a listing and figure side by side. I tried to follow the suggestions in this link How to put algorithm and figure(s) side by side? without using caption package but the listing stays ...
4
votes
1answer
73 views

Line break at a whitespace in inline code listing

How can I automatically break the following inline code at a whitespace? The problem is that I have to use breaklines=false. \documentclass{article} \usepackage[latin1]{inputenc} ...
5
votes
1answer
304 views

Escape moredelim in lstlisting

I am wondering if it is still possible to print characters chosen to be moredelim in \lstdefinestyle. It turns out that since I've defined a character as moredelim, it can only be used inside quotes ...
4
votes
1answer
134 views

How can I prettyprint a URL of a http-request in this particular way?

I have a URL for a HTTP-Request as the only content of an lstlisting environment, and I want to prettyprint it as follows: color1 for the first line, and for ?, &, and |, color2 for parameter ...
11
votes
1answer
423 views

Using listings: “zebra effects” AND line numbers

I just made a code listing with a "zebra effect", just like here: Creating a zebra effect using listings But afterwards, the line numbers at the left side of the listing don't appear any more. This ...
6
votes
1answer
62 views

Alignment problem if line breaks are used in listings

I am using a monospace font and I want that all lines are horizontally aligned ("a" should be directly under "a"). How can I do this? I have noticed that also the pagebreak symbol shifts the text. ...
2
votes
0answers
31 views

LaTeX List of listings name in front of number [duplicate]

I am having problems with LaTeX specifically using listings package. The first one is I want to add the word "Código" in front of number of Listing in List of Listings. For example List of ...
2
votes
1answer
88 views

Add coloring rules for specified language keywords in lstinputlisting [duplicate]

I would like to add coloring definition for e.g. @Override in java files. How can I do that ? So far I have the following coloring definitions : \documentclass[a4paper,11pt]{article} ...
3
votes
1answer
46 views

Manual line break in listings or listings doesn't work in figure env

The example illustrates my problem. I have long code rows which should break automatically (see line 1) but some lines I want to break manually (line 2 / 3). How can I do this? I have played a little ...
37
votes
4answers
2k views

Has the time come for a LaTeX3 successor to 'listings'?

I'm currently looking for a nice and challenging open-source project to work/collaborate on after my thesis. I don't have a Comp. Sci. background, but I'd like to learn more about compiler ...
4
votes
2answers
108 views

How to ensure footnotes being at the same height on every page?

I have added a footnote to the text but I also have some "unbreakable" code listings. Because of that the footnote gets dragged "higher" in the page. As you can see there's more space between ...
3
votes
1answer
203 views

How to embed special markers into the code listing that will mark certain parts of code to be colored using a custom scheme?

I would like to color my C# code listings as Visual Studio does. However, all language definitions that I found so far only color the keywords and not the user types. I understand that it requires ...
0
votes
0answers
17 views

How to prevent page breaking for lstinputlistings? [duplicate]

In my pdf created from latex sources I can see that sometimes \lstinputlisting will have a page break in the middle just because it happened to be in the end of the page. I would like to prevent it. ...
3
votes
1answer
59 views

Automatic line breaks of long numbers in listings

How can I automatically break long numbers in a listing? Redefining \lst@lettertrue doesn't work. \documentclass{article} \usepackage[T1]{fontenc} \usepackage{listings} \lstset{ breaklines=true } ...
4
votes
1answer
109 views

How can I mimick the listing caption style for my custom “Listing (cont.)” caption?

I have the following LaTeX code which works fine: \documentclass[12pt,a4paper]{article} \usepackage[a5paper]{geometry}% just for the example \usepackage[utf8x]{inputenc} \usepackage{listings} ...
1
vote
0answers
26 views

An environment for C-code [duplicate]

I am trying to create an environment specifically for C-code, but when I compile the document below, LaTeX just hangs. I'm running MiKTeX 2.9 if that matters. Is lstlistings one of those environments ...