{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

1
vote
1answer
8 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} ...
2
votes
2answers
22 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
16 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
25 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
30 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. ...
5
votes
0answers
38 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 ...
5
votes
1answer
56 views

how to crop background color in listings to the longest line in the code?

listings package allows one to put background color to the code listing. The problem is that the background color extents to the as large as the text area the code listings happened to be in. This can ...
3
votes
0answers
37 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
31 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
546 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
15 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
108 views

Isolate Latex Environments [on hold]

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
27 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}} ... ...
3
votes
1answer
102 views

LaTeX, two-column listing in an array

I am trying to display to codes side-by-side, using this: \begin{center} \begin{tabular}{c|c} \begin{lstlisting} while (x > 0) do x++; \end{lstlisting} & \begin{lstlisting} x = 0; ...
4
votes
1answer
29 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 ...
0
votes
1answer
25 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
22 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
51 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
26 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
58 views

Using an overlay on lstinputlistings in latex

I want to have to multiple overlayed lstinputlistings on one slide in a presentation, created with latex and documentclass beamer. The only solutions I find are for lstlistings, but those don't work ...
2
votes
1answer
44 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
34 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
23 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
25 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
28 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
32 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
22 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
36 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} ...
3
votes
2answers
147 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
31 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
34 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} ...
2
votes
1answer
24 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
24 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
70 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
86 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
20 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
8k 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
15 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 ...
1
vote
1answer
42 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} ...
2
votes
1answer
30 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
40 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} ...
3
votes
0answers
38 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
61 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
83 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} ...
1
vote
1answer
220 views

Combine listings package with my own environment [duplicate]

Possible Duplicate: How to use different lstset settings for listings? I have defined my own environment as: \newenvironment{codegui}[3]{% \def\tmplanguage{#1}\relax ...
4
votes
1answer
198 views

breaking lines in listings environment

I am trying to make listing environment brake lines. Unfortunately breaklines=true does not work for me. Here is my code: \usepackage{listings} \begin{document} ...
3
votes
2answers
53 views

List of listings similar to list of figures

After learning on the net I managed to get this type of list of figures : And I want exactly the same with the list of listings, but here is what I get : My code is this one : ...