{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

4
votes
1answer
94 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
64 views

messy/overwritten numbering in enumerate tag

I have the following in my LateX code: \begin{enumerate} \item \begin{lstlisting} ...
3
votes
1answer
69 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
57 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
121 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
70 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
84 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
39 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
56 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?
6
votes
1answer
83 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
69 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
81 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
59 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} ...
4
votes
1answer
121 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
97 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
383 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
54 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
55 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
37 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 ...
35
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
94 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
180 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
15 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
34 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
96 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 ...
1
vote
0answers
93 views

listings package: embed text from a .txt file in a LaTeX document [closed]

I'm using the listings package to put text from a text file into a LaTeX document \lstinputlisting{file.txt} However, it isn't putting in special characters correctly, % is displaying fine which ...
8
votes
1answer
407 views

How can I highlight YAML code in a pretty way with listings?

I'm trying to highlight simple YAML (the markup language, not the CSS framework) code. I know that there is a solution using pygments and minted, however, I would prefer a solution with ...
2
votes
1answer
50 views

Is there a way to ignore the empty lines while for importing matlab code through \lstinputlisting for matlab code

I use the mcode latex package available here: I use: \lstinputlisting{G:/PROJECT_and_SEMINARS/sms/v.1.39.a.1/sms.m}[caption={Source code of program: SMS. Version:1.39.a.1}][firstnumber = 1] ...
3
votes
1answer
53 views

Description definitions and ntheorem

I want to have inline listings in description items, so I used this very nice answer. Unfortunately this hackery destroys my theorem environments with error something's wrong--perhaps a missing \item ...
4
votes
1answer
76 views

Handling a PDF with user text strings

I am using LaTeX to generate descriptive receipts for an online system. I use special character tags and replace these with content e.g. {{ first_name }}. Now, there are several of these and they ...
3
votes
1answer
81 views

Change indentation depth when using spaces in lstlisting

I have an lstlisting that renders some lines of code. The code is indented by four spaces per indent. Is there any setting to change the indentation to only two spaces? I know that there is tabsize ...
3
votes
1answer
100 views

Coloring or Bolding multiple lines in fancyvrb integration with listings

I would like to apply latex commands on a bunch of lines in a Verbatim environment with listings, especially make bold or color a block of code. I am able to do that for a single line, but not for ...
16
votes
1answer
313 views

How to remove the leading unnecessary white spaces when using linerange option?

To be honest, I am looking for people who already read the listings documentation completely. If those people also cannot solve it, then the documentation does not mention anything about it. Sorry for ...
7
votes
3answers
160 views

How can I parse the first word in a token stream, token by token?

Some programming editors and IDEs highlight legal and illegal variable names in different ways. I wish listings easily allowed for such syntax checking and highlighting, but it doesn't, at least at ...
3
votes
2answers
125 views

Setting up `Ubuntu Monospace` font for a specific listing

My OS : Ubuntu 13.10 Latex version used : Version 3.1415926-2.5-1.40.14 (TeX Live 2013/Debian) In my report, I am using the following listing : \lstdefinestyle{BashInputStyle}{ language=bash, ...
1
vote
0answers
53 views

written tab (not only a non-copyable space) in listings enviroment (LaTeX) [closed]

I am trying to put python code in the appendix of report using listings package. Visually it works fine, but there are not tab symbols in the pdf file, only space without symbol in background. The ...
0
votes
0answers
140 views

How to replace (unicode) characters by ü,ğ,ş etc.?

\documentclass[11pt,a4paper]{article} \usepackage[utf8x]{inputenc} \usepackage{ucs} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{graphicx} \usepackage[T1]{fontenc} ...
0
votes
1answer
112 views

two-column lstlisting in landscape orientation

How can I divide my page in two to show my code with lstlisting? This is a large code and I want to set as 2 pages in one. Is an appendix of my project not all the document. EDIT thanks to ...
3
votes
1answer
49 views

latex R code with %*%

I'm using latex with lstlisting to format my R code. Some of my code uses matrix arithmetic, including %*%. Unfortunately this causes errors when compiling. There is an example of what I would like ...
2
votes
1answer
106 views

lstlistoflistings entry in table of contents name is always 'Contents'

I'm trying to add a list of code listings to my document, with a reference to it in the TOC. By simply calling \lstlistoflistings I end up getting everything I need (the list of listings, an entry ...
6
votes
1answer
407 views

LaTeX commands in Verbatim using fancyvrb and listings

I am trying to use LaTeX commands like \textbf, \textit, \textcolor in fancyvrb combined with listings. Especially I want to bold and color any text or entire blocks of Java code (not just keywords) ...
7
votes
1answer
172 views

Faster compiling [duplicate]

I'm writing at my thesis and it has now about 60 pages.. When I want to compile it (to pdf), it lasts about 20 seconds.. Is it normal? I think, the included graphics costs a lot of time?! ...
4
votes
2answers
113 views

Integrating listings with fancyvrb

I am trying to use fancyvrb with listings and I get an error saying l.2 ...{Verbatim}[formatcom={\lstset{style=Java}}] Package Listings Error: language java undefined. ...
4
votes
1answer
54 views

Listings environment within another environment

\newtheorem{alg}{Algorithm}[subsection] \begin{alg}\label{alg:1} \begin{lstlisting}[frame = single, breaklines = true, numbers = left] test code \end{lstlisting} \end{alg} How can I prevent the ...
1
vote
0answers
10 views

include “\end{lstlisting}” inside lstlisting block [duplicate]

I'm writing a shell script that returns all shell scripts in LaTeX lstlisting environments. Now, the shell script that does this is also included in the LaTeX file it generates, which gives me a ...
2
votes
1answer
64 views

Listing / lstinline and line breaks

I'm using \lstinline among other things for writing file names of my source files. For example \lstinline{foofoo.pl} Then, sometimes I have the problem that some lines containing this string are ...
4
votes
2answers
83 views

How to colorize escaped math in syntax highlighted listings?

my listings are syntax highlighted using \lstset with escapechar=$ and commentstyle=\color[rgb]{0,0.5,0}. Now my C-code looks like int16_t speed; // calculated speed in $\(\frac{cm}{s}\)$ and the ...