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

mark LaTeX keywords in listings

I am using this code to define keywords for listings \lstdefinestyle{demostyle}{ columns=flexible, keepspaces=true, basicstyle=\small\ttfamily, language = [LaTeX]TeX, ...
3
votes
1answer
318 views

Background images for code listings in beamer

I asked this question originally in attempt to get background images behind my code listings. Background images for code listings What I did not mention is that I am using the beamer package for ...
5
votes
1answer
88 views

vertical extra space below lstlisting environment inside a list environment

i want several code listings to be embedded in an item of a custom list environment. To achieve this i employ the lstlisting environment of the listings package. Unfortunately extra vertical space is ...
8
votes
2answers
2k views

Which package to use for writing algorithms?

I am looking for a package that will allow me to write pseudocode of algorithms. The pseudocode may include mathematical symbols, like \forall, \in and subscripts. But I would like also to "talk" ...
6
votes
1answer
784 views

LaTeX to HTML preserving code coloring from listings

I'm trying to convert some LaTeX into HTML but my code listings don't preserve their code coloring. Why is that and how do I fix it? This is what it looks like: Side note: I'm also wondering why ...
5
votes
1answer
256 views

How to accept three different languages on lstlisting

How to accept three language different? \documentclass{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage[brazil]{babel} \usepackage{xcolor,tikz} \usepackage{showexpl} % exibe ...
6
votes
2answers
363 views

How to make “sub-level” numbering for listings, similar to subcaption?

I think what I'm trying to do may be complicated, so if not all of it is possible then that's OK. I'm using the listings package and I've done something similar to Custom numbering of listings ...
3
votes
1answer
1k views

How to use mathematical symbols in listing?

I want to use math mode in lstlisting. How do I do that? How to put tab in this mode? \begin{document} \begin{lstlisting}[frame=single] % Start your code-block module main() ...
9
votes
1answer
379 views

Background images for code listings

I've been searching around but I can't find any info for adding an image background for my code listing using the listings package. Is there a way to do this?
4
votes
2answers
192 views

Mangling listings source code

I would like to make it harder for students to just copy/paste code listings from the PDF. How to achieve this? I want them to actually understand the code, close the book, and write from their ...
4
votes
2answers
800 views

Listings package with caption legend in spanish

I'm using the listings package and would like to translate the caption text displayed to Spanish, so instead of Listing 1: Dummy label it will display Listado 1: Dummy label. This is my code: ...
3
votes
1answer
212 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
1k views

Add listings to list of figures

I am using the listings package to display code in my document. is it possible to add the listings to the List of Figures. Instead of Listing, there should be Figure in the caption and it should share ...
3
votes
1answer
468 views

R listings operator partially in bold

I am using listings to display R code. The matrix multiplication operator shows up partially bold, something like this: "\%\textbf{*\%}". If I separate the * and the %, the second % is not in bold. I ...
9
votes
2answers
834 views

How to compose figure from text with latex?

I have an ascii image like +--------------- | xxxxxxx +--------------- | xxxxxxx +--------------- I want to show this in figure environment. So currently I try like this: \begin{figure} ...
22
votes
2answers
2k views

Ensure verbatim code block is copy/paste-able

After rendering a document containing this code block \begin{verbatim} if [ ! -d .git ]; then git init; fi # Initialises a new Git repository, if doesn't already exist. if [ ! -f README.md ]; ...
4
votes
2answers
1k views

How to cross-reference inside of a verbatim (or listings) environment

I would like to reference other parts of my document (e.g. equations, figures) inside of some source code. Is there an escape sequence such that \ref will be parsed instead of printed as a literal ...
4
votes
1answer
278 views

listings wrong syntax highlighting in perl - format specification

Perl uses '#' as an introduction for a comment, but also as a format specification. This produces problems in the syntax highlighting in the listings-package. How can I fix it? ...
4
votes
1answer
833 views

How to center listings caption?

I would like to know how to center the listings gerenated caption in LaTeX. It always go to the left of the code. The rest of the captions (tables) are OK. \documentclass[11pt,a4paper,oneside, ...
6
votes
1answer
2k views

XML syntax highlighting does not work

How do I make comments highlighted in the form: <!-- ======= Processing Root tag ======= --> . This is not working. \documentclass[11pt]{scrartcl} \usepackage{listings, color} ...
5
votes
1answer
133 views

StrSubstitute and @ inside and outside \lstnewenvironment

While further working on code for my answer to Different approach to literate programming for LaTeX, I am encountering a problem to which I am sure there is a very simple solution, but it completely ...
1
vote
0answers
69 views

Changing font in listings-package [duplicate]

Possible Duplicate: set the font family for lstlisting I need to change the font while using the listings-package since my TeX template seems to interfere with standard listings settings ...
6
votes
1answer
908 views

Adjusting Vertical Spacing between a listing and its Caption

I am very new to LaTeX. I am inserting a listing as follows: \lstinputlisting[float=hk, caption=My Caption comes here, captionpos=b, ...
3
votes
1answer
878 views

Alternative way to print source code [duplicate]

Possible Duplicate: Syntax Coloring in LaTeX I want to add source code of my program in document but verbatim really bugs me. All that ugly fonts and stuff.
-1
votes
1answer
326 views

Smalltalk syntax highlighting for Latex [closed]

What is the easiest way to format Smalltalk syntax using the listings package?
5
votes
0answers
264 views

How to customize the font and margin for lstlistoflistings TOC entry? [closed]

In my LaTeX template, I define the chapter and section TOC entry with the titletoc package: \titlecontents{chapter}[0pt]{\vspace{.1\baselineskip}\bfseries} {\thecontentslabel\hspace{2.8mm}}{} ...
1
vote
1answer
2k views

How to customize the caption format for \lstinputlisting

I know how to customize the caption format of lstlisting environment. But how to do this if I used the \lstinputlisting command to import code? My document contain below snippet. \begin{framed} ...
6
votes
2answers
2k views

Create a \lstnewenvironment that creates named listings

I am using the \lstnewenvironment to format a set of code listings in my document. \lstnewenvironment{code} {\lstset{language=haskell, basicstyle=\small\ttfamily, numbers=left, ...
1
vote
1answer
158 views

lstlisting-environment not available within tabularx-environment

Please consider the following example. Does anyone has an idea why I cannot use the listings-environment within the tabularx-environment? \documentclass{article} \usepackage[ngerman]{babel} ...
1
vote
1answer
278 views

Looking for HAML and CoffeeScript support

I need support for HAML and CoffeeScript like other languages already got with the listings package. Do you know any solutions?
7
votes
3answers
237 views

How to define a listing example environment

I have read the listing manual document. I would like to use the lstsample environment. It looks like below: Basically, the output is on the left and the code is placed on the right. But I don't ...
5
votes
1answer
1k views

cite in caption of listings

I am trying to cite a paper in the caption of listings. I have the following code: \begin{lstlisting}[caption=Example of something (Adapted from \cite{abc})] example \end{lstlisting} But this is ...
4
votes
1answer
259 views

Can I have automatic \needspace for listings package?

I am using the listings package. The problem I have is that if the code gets in the middle of two packages, it is cut, which I don't want. To kind of solve that, I am using the package needspace and I ...
2
votes
0answers
70 views

Colors for integers in listings package [duplicate]

Possible Duplicate: How can I change the color of digits when using the listings package? Listings package: How can I format all numbers? Is it possible to have colors for integers using ...
0
votes
1answer
599 views

Problems using listings package [closed]

I'm using the listings package to include some source code files in a LaTeX document. I'm having 2 problems: characters - are not shown in the resulting file characters % are shown overlapped with ...
4
votes
1answer
309 views

listings caption is distorted

I used listing for listing the codes like: \documentclass[prodmode,acmtecs]{acmsmall} % Package to generate and customize Algorithm as per ACM style \usepackage[ruled]{algorithm2e} ...
3
votes
1answer
706 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 ...
4
votes
1answer
276 views

Can I use \lstinline for table column?

I want to apply \lstinline to one of the columns. I don't like idea to put it in every cell manually. I am trying to do \begin{table} \begin{center} \begin{tabular}{| >{\lstinline}l | ...
5
votes
2answers
1k views

Package Listings Warning: Text dropped after begin of listing when calling function

I'm trying to this: \newcommand{\code}[1] {\begin{lstlisting} {#1} \end{lstlisting} } But I keep getting this error: Package Listings Warning: Text dropped after begin of listing I'm calling ...
3
votes
1answer
892 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 ...
1
vote
1answer
266 views

listings font in pdflatex

I'm using \ttfamily but it renders listing with the Times New Roman. What am I doing wrong? I'm getting a warning message: Font shape T2A/fi4/bx/n' undefined(Font) usingT2A/fi4/m/n' instead on ...
8
votes
2answers
3k views

Python code in LaTeX document

I want to include some Python code into LaTex document, so I "imported" the listings package with \usepackage{listings} and \lstdefinelanguage{Python}{ keywords={typeof, null, catch, switch, in, ...
2
votes
1answer
652 views

Removing horizontal black line in listings

I'm using listings for code snippets and I can not seem to find a way to remove the horizontal line on the bottom of a listings environment. My code: \lstset{ ...
3
votes
1answer
631 views

listings incorrectly highlights PHP keywords

I have definitions as below: \lstset{ commentstyle = \color{gray}, extendedchars = \true, inputencoding = utf8x, language = php, keepspaces = true, keywordstyle = \bfseries } ...
3
votes
1answer
783 views

Problem with lstlisting in beamer… What am I doing wrong?

I am trying to to put an lstlisting environment in the left column, but I'm getting errors. Are lstlisting and the columns environment in beamer incompatible? Or is it something else? ...
6
votes
1answer
1k views

Inserting TeX code into beamer - Problem with otherkeywords

I am preparing a beamer presentation and using the lstlisting environment in order to put in TeX code. I am using the following code which is largely copied from here: ...
9
votes
1answer
1k views

Beamer - Using \pause within lstlisting

I am preparing a beamer presentation and using the lstlisting environment in order to put in code. However, I would like to use the \pause command within lstlisting. By definition that is not ...
11
votes
2answers
933 views

highlight lines in listings

I have code that i have included into my document using the texcode below \begin{minipage}{.48\textwidth} \centering \lstinputlisting[numbers=left,xleftmargin=2em,frame=single,framexleftmargin=2em, ...
4
votes
1answer
113 views

How to edit latex-generated text in Captions?

I want to take the answer to the question LaTeX source code listing like in professional books one step further, and change the (latex-generated) text in the caption from Listing n to something more ...
4
votes
1answer
460 views

Set styles for numbers in listings package

I am using the listings package for Smalltalk programming language but since it does not come out of the box, I am trying to do it by hand. Now I have a problem with numbers. No matter if I change: ...