{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

9
votes
2answers
100 views

Listings for plain tex

Is there a package to produce syntax-colored blocks of source code in plain TeX ? A listings equivalent ? Or (maybe) some macro to produce a colored tex input for some given source code ? Is it ...
7
votes
1answer
62 views

Colorize symbols with lstdefinelanguage in latex

I want to put some symbols in green color with lstdefinelanguage in latex, but it seems that symbols are not recognized. The symbols I need to be colored are =, > and <. Is it possible? How can I ...
2
votes
1answer
45 views

Multiline Matlab comments in package Listings

I am using the package listings to include some Matlab code in my report. It works well with comments beginning by % but does not recognise multiline comments %{ ... %}: \usepackage{listings} \lstset{...
4
votes
2answers
41 views

Single character keywords/operators with no spaces with listings package

I want to add a very simple macro language to listings. It uses single-letter keywords/operators, with no whitespace between. I can't see how to make keywords that don't require some kind of separator ...
6
votes
3answers
138 views

How to only show text?

I have a document for a student research project and want to know how many pages content without figures, listings and tables i have. My university does differentiate between content and figures,... ...
3
votes
1answer
19 views

Semantic nesting error from underscores with `listings` while `syntax` is loaded

I use XeLaTeX and have TeXLive 2015 installed. I want to use both the listings package for printing code and the syntax package for printing grammars. For code, I also want to expand certain symbols ...
2
votes
1answer
32 views

\lstdefinelanguage cannot handle keywords #if, #endif,

I need to insert C-code snippets in my LaTeX document. Therefore I define a C-code language syntax highlighting: \usepackage[utf8]{inputenc} \usepackage{listings} \usepackage{color} \definecolor{...
0
votes
0answers
34 views

Use python as data source for Latex and DOxygen

I have python code where the comments contain latex code. Will it be possible to parse the code with doxygen and display the latex code as latex symbols. include the same code in latex (using ...
2
votes
1answer
47 views

How to insert listing inside frame and between enumerate?

I'm creating a presentation and I want to add a one line code in the presentation between each itemize element. You can see below what I want to achieve. \documentclass{beamer} \mode<presentation&...
3
votes
2answers
40 views

An error appears saying that utf8 and listing are not compatible

If I compile the next code the following error appear. ! Package inputenc Error: Unicode char \u8:�\expandafter\lst@FillFixed@\fi not set up for use with LaTeX. See the inputenc package ...
1
vote
0answers
21 views

If I use listing package, i can not use listing environments, how could I use both?

If I use listing package, i can not use listing environments, how could I use both? In the next code Im using UTF8 and listing, but an error appear. This is my code. \documentclass{article} \...
2
votes
0answers
26 views

How can I get rid of indentation before my code? [duplicate]

My Javascript code has a large amount of whitespace in its block in the output pdf file. How do I get rid of this without un-indenting my latex code? Thanks in advance. \documentclass{article} \...
3
votes
1answer
41 views

error using tcblisting inside longtable, no error inside tabular.

I was testing a nice solution provided in this answer how-to-crop-background-color-in-listings-to-the-longest-line-in-the-code However, I happened to be using longtable and not the standard tabular. ...
3
votes
0answers
42 views

Latex complains about missing $ from listing of source code

This is the smallest example I can come up which shows this problem. Latex complain about missing $ and the error is pointing to a line in code listing ! This problem can be resolved by doing 3 ...
4
votes
1answer
49 views

Square brackets in listings caption

How to add square brackets as a caption in a listing? I tried putting caption inside of "{}", but then the output is quiet weird. \documentclass{article} \usepackage{listings} \begin{document} \...
1
vote
1answer
571 views

Highlighting a Chunk of Code within a lstlisting by specifying the line number

This question in somehow related to http://stackoverflow.com/questions/1304315/highlighting-a-chunk-of-code-within-a-lstlisting but not exactly the same. I want to make some slides with animation ...
3
votes
1answer
18 views

listoffigures not working properly

I have noticed that in my document the \listoffigures and probaly \listoftables are not working properly. There is no space in between the number of the figure and the text in the list. Also, if the ...
4
votes
1answer
111 views

Isolate Latex Environments [closed]

I want to build a framework for sharing latex mathematics exercises. When trying to assemble exercises from different authors into one "homework assignment", I have a problem. How can I deal with ...
5
votes
1answer
35 views

Inline escaping {{ myVariable }}

How to escape Mustache notation inline for example: This is a Mustache placeholder {{ myVariable }} that will output myVariable. This seems to be causing errors: \lstinline{ {{#if}} ... {{else}} ... ...
0
votes
1answer
28 views

lstinputlisting shows wrong number in reference

I'm pretty new to LaTeX, so please be a little patiently with me. So here is my problem: I got some text and there i want to reference a little bit code shown in the next line. What i tried so far: ...
2
votes
1answer
33 views

adding frame=none to lstlisting options in \lstdefinestyle gives error with tabular

lstlisting has an option called frame= But when I use the frame=none in \lstdefinestyle and put the lstlisting command inside tabular or longtable I get an error Forbidden control sequence It ...
6
votes
1answer
52 views

highlight text between selector without highlighting nor deleting the selectors [duplicate]

So I'm trying to render something beautiful for my PHP code using the \lstdefinestyle command. I think the basic configuration is good, but I would like to highlight the function name to render it in ...
4
votes
1answer
32 views

Why making program listing with ACM style produces extra narrow caption?

I want to prepare a manuscipt for an ACM journal. The program listing appears with extra narrow caption, see at bottom. It is hard to believe, I found incompatility with package 'listings', in an ACM ...
2
votes
1answer
53 views

Adding a special keyword that is ignored in lstinputlisting

I would like to know how to add a special keyword to be ignored in \lstinputlisting that is used in the listings package. The screen shot shows my problem. I am writing a tutorial document of the ...
5
votes
1answer
45 views

Using Bash listings to bold variables and functions

I am using the listings package to show some sample bash script lines; however, the otherkeywords argument is giving me trouble. As the listings documentation states: If one keyword is a ...
4
votes
1answer
30 views

How to set macrocode using the listings package

When writing a dtx file, is it possible to typeset the code samples (i.e., everything enclosed in a macrocode environment) using the listings package? For completeness, here's Joseph Wright's model ...
3
votes
2answers
28 views

Source code listing using \lstinputlisting - prevent other floats splitting it up

I am using the listings package to take an external PHP file and display it as a code listing in my document. It spans several pages (fine) but unfortunately there are other floats which end up being ...
2
votes
1answer
32 views

why is adding subdepth package makes lstlisting give Matlab error loading file?

If I have a dollar each time I find a conflict between Latex packages I would be a rich man. I added \usepackage[low-sup]{subdepth} and now I am starting to get errors from matlab-prettifier when ...
3
votes
1answer
33 views

How can I make a reserved word loose its special formatting in listings?

Consider the following example. \documentclass{minimal} \usepackage{listings} \begin{document} \begin{lstlisting}[language=sh] cat foo.c cat.c bar.c echo The cat ate the cheese \end{lstlisting} \...
0
votes
1answer
31 views

Listings titles in List of Listings

I have a question analogous to this one, but for listings instead of figures. In my TeX file, I have multiple listings defined as follows: \begin{lstlisting}[caption={A really, really, really, ...
3
votes
1answer
38 views

How to number program listings like figures

Is there a way to number program listings like figures and reference them? I have the following mwe: \documentclass{article} \usepackage{hyperref} \usepackage{listings} \begin{document} \autoref{...
4
votes
2answers
167 views

Problem with gobble listing option inside a tcblisting

Please, compare next two listings inside a beamer frame. The upper one is made with listings and the second with tcblisting (form tcolorbox). Both use same source and listing options. Following ...
0
votes
0answers
62 views

Latex lstlisting: stringstyle not working

I defined my own language Drools and I want that the words between "" have the color red. I used stringstyle to do that but this doesn't work. Am I forgetting something because I couldn't find any ...
2
votes
0answers
35 views

Empty list of listings [duplicate]

How can I add my Listings to the \lstlistoflistings?! Here is the Listing with example: \documentclass[a4paper,11pt]{article} \usepackage[ngerman]{babel} \usepackage[T1]{fontenc} \usepackage[utf8]{...
2
votes
1answer
39 views

How to make Latex recognize individual keywords in lstlisting without delimiter?

I want to add a few lines of G-Code (used for 3D-printing) to my latex file using the listing package. Unfortunately, g-code is not supported as a language and therefore has no highlighted commands. I ...
0
votes
0answers
27 views

minor missing star character incompatibility between lstlisting and mdbch mathdesign

Minor problem I ran into: Using \usepackage[mdbch]{mathdesign} \usepackage{listings} \lstset{language=C} and then look at the output of a /* **** */ C comment. I think it is because mdbch does ...
2
votes
1answer
77 views

\itshape is to \textit as ?? is to \mathit?

In the following example, I've set listing's basic style to \itshape. However, the + operator is italicized, and so are the parentheses: \documentclass{article} \usepackage[english]{babel} \...
4
votes
2answers
97 views

Why is text turning white (possible scope leak?) after page break and listings + tcolorbox + xelatex?

I had a very difficult time pinning this problem down, because it only exists when certain page-breaking conditions occur. Problem Text after environment mysteriously turns white under some ...
5
votes
0answers
23 views

lstlining changing font in moredelim

lstlisting is not using the identifierstyle font inside of the moredelim that makes the identifier name red. In the example, the first varname is in tt font but the second is in roman. I want the ...
16
votes
3answers
9k views

How to insert code with accents with listings?

I'm trying to insert source code in LaTeX with using listings, but my code has accents and pdflatex gives me this error: Unicode char \u8:�\expandafter not set up for use with LaTeX. This is a code ...
0
votes
0answers
26 views

Lining up character codes beside source code

I would like to create something similar to this structure: for (int i=0; i < 10; i++){ FOR05 System.out.println("Hello world"); OUT10 System....
1
vote
1answer
56 views

Give side by side minipages one (shared) caption instead of two

I have two lstlisting areas that are shown side by side by using two minipages: \noindent\begin{minipage}[t]{.43\textwidth} \begin{lstlisting}[...]{part1} // Code \end{lstlisting} \end{minipage}\...
2
votes
1answer
35 views

Title with counter for Listings

I am trying to add a title with counter to my Listings. This is what I have so far: \usepackage{listings} \usepackage[many]{tcolorbox} \tcbuselibrary{listings} \newtcblisting[auto counter,number ...
20
votes
0answers
246 views

How can I make a custom environment that wraps listings? [duplicate]

Thanks to this answer, I know it is possible to float and wrap text around a listing. I would like to setup an environment for mini-code snippets that always floats and wraps the same way. I can ...
3
votes
1answer
24 views

Listing with overlay only next to content not to title

I got this listing with a gray bar on the left side with line numbers in it. I want it not to be showen next to the title. Here is my code: \usepackage{listings} \usepackage[many]{tcolorbox} \...
1
vote
0answers
49 views

Define listings language with multiple keyword groups

I wanted to used syntax highlighting for a language unsupported by the listings package. Right now I have it almost working, but not completely. This is the MWE: \documentclass{article} \usepackage{...
3
votes
0answers
53 views

Warning: uncodable character in LyX lstlisting

The problem I'm trying to insert the output of the tree command into a Program Listing field of LyX. The text is the following: exampleFolder/ ├── 01.mp4 ├── 02.avi ├── 03.mov └── 04.mpg If this ...
2
votes
1answer
65 views

listings package: last whitespace removed before the newline character. How to keep it?

I've some sort of template/examples of bash scripts on my computer (.sh files on my hd) in which I put commands and commented outputs. This is my example.sh file: echo this is wide ...
1
vote
1answer
94 views

Margin notes in listing with float environment – Error: Float(s) lost

Based on this question: Margin notes in listing with float enviroment - Error: Float(s) lost I have now other question. The solution is working fine. But I want to use floats for listings, to prevent ...
5
votes
1answer
3k views

lstlisting in a tabular environment

I am following Adding C++ code in Latex for adding C++ code to the document. What I have is a table with the following format: \documentclass[12pt,a4paper,final]{report} \usepackage[utf8]{inputenc} \...