{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
0answers
6 views

How to let minted break across pages but keep the caption together with the end of listing?

I want to create a listing using minted that has background colour and can be split across pages. The usual advice in that case is to use the mdframed environment and I have written a command that ...
1
vote
2answers
28 views

polish characters ą

I cannot get to work my special chars in listings, my texmaker is configurated to use utf8 in options, but I get error: ! Package inputenc Error: Unicode char \u8:�\lst@FillFixed@ not set up for ...
0
votes
0answers
38 views

inline listings line wrapping issues

I am having issues with inline listings line wrapping. As you can see in the linked image, the period ending the sentence is on the next line due to wrapping of the cite-website text. The listings ...
2
votes
1answer
26 views

listings \def problem

When I complile the following code with xelatex, %\end{lstlisting} is a necessary line to prevent error. What is the problem? \documentclass[a4paper,11pt, onecolumn, openany,]{memoir} ...
4
votes
2answers
53 views

Document doesn't show the list of figures (LaTeX)

I have the problem that LaTeX doesn't show the List of figures and List of Listings. I don't know where the problem is. I'm working with TeXstudio and the code was defined as follows: ...
0
votes
0answers
38 views

Bug with luatexja-fontspec and tcolorbox [on hold]

I found a bug with luatexja-fontspec and tcblisting of tcolorbox. Specifically, when I use "style=tcbstyle" and "\setsansjfont", I get a following error. ! Missing number, treated as zero. <to be ...
2
votes
1answer
37 views

Problem defining a new lstlisting environment

I'm relatively new to Latex and having a bad time using listings inside a beamer presentation. I know I have to use a [fragile] frame to get verbatim environment inside a frame, but for some reasons ...
4
votes
1answer
69 views

How can I display julia output in latex?

I've been able to typeset julia code using listings package as mentioned in the answer here. But I also wanted to display Julia output in my latex document, how can I achieve this ?
2
votes
0answers
45 views

Including C++ in AMS Book template

I've had a hard time incorporating my C++ code into a document which was formatted using the AMS book template. %----------------------------------------------------------------------- % Beginning of ...
1
vote
0answers
31 views

xparse verbatim argument removing multiple space

I am trying to define a command, using xparse that take as input some verbatim code and cite it using listing. However, the eventual multiple white spaces or tabulations at the beginning of a lines ...
4
votes
2answers
29 views

Space around escaped equations in listings?

I am using listings with mathescape=true to include some typeset output. However, I would like a little white space around that output. Currently I have \lstset{language=, keepspaces=true, ...
1
vote
0answers
46 views

Latex highlighting error for lstinline

it has been quite a while that I have this problem and I have searched everywhere online and couldn't find a solution. The problem is latex syntax highlighting doesn't work after this line: ...
3
votes
0answers
28 views

Syntax Issues with lstdefinelanguage

I have some issues defining a new language for the lstlisting package. The source code shall look like this in the end: And my latex definition looks like this atm: \documentclass[]{article} ...
3
votes
1answer
18 views

LaTeX listings Package Only gives Unbreaking Spaces when in tex4ht

I am trying to make a programming e-book, but the listings package is converting all of the spaces in the listings to non-breaking spaces. I have tried breakatwhitespace as both true and false, as ...
3
votes
1answer
39 views

New environment for Python source code

I am trying hard to create an environment for my source code. Here's my current state \documentclass[a4paper,fontsize=12pt]{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} ...
2
votes
0answers
19 views

conflict using matlab-prettifier and LaTeX beamer [duplicate]

I was trying to use the matlab-prettifier package with the LaTeX beamer package, and I noticed I was getting errors when trying to compile. Mainly I was getting an error when trying to use ...
3
votes
3answers
257 views

ASCII + Unicode art in LaTeX lstlisting

I have a small ASCII diagram in my LaTeX document. \lstset{literate={↓}{$\downarrow{}$}{1}} \begin{lstlisting} -1---2----3-----| ---s---------s--| ↓ ↓ ---1*--------3***| \end{lstlisting} ...
1
vote
0answers
16 views

Get source code as it is from output [duplicate]

I am trying to display my XQuery code in a latex document as follows: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{listings} \title{code} \date{January 2016} \begin{document} ...
1
vote
0answers
58 views

How can I define a new language? [closed]

i need to insert code into my document which is written in ST (structured text) (PLL language). Couldn't find any existing solution in the web. How to add the language to the package to use it? ...
0
votes
0answers
41 views

Place the content in a block with shadow frame

I am using latex beamer and trying to put the content of the listing in a block with white background and just with a shadow of the frame as the one of google (madrid weather). I tried with ...
2
votes
1answer
52 views

shrink the size of the font size in the listing

I am using the latex beamer and trying to reduce the font size of the listing to display the whole JSON code without reducing the font size of the sentence before. How can I get it to work? Code: ...
1
vote
2answers
69 views

listingsutf8's option inputencoding=utf8/latin1 leads to latin1.def to be read each time a listing is used

Edit: inputencoding=latin1 option initially written should have been inputencoding=utf8/latin1 If the listingsutf8's option inputencoding=utf8/latin1 leads to latin1.def file to be read each time a ...
5
votes
1answer
31 views

get all values of the JSON format red

I am using the latex beamer and trying to get the true value of the flag key in the JSON format red too but I am just getting it black as shown in the screen shot below. How can I get it red too? ...
0
votes
0answers
15 views

After using listings my country symbols moved to words front

So I used listings package to put my JSON script to a LaTeX file. Which looks like: \begin {1stlisting} { "wow": 30, išėjimas "nice": 1 kažkas }, ...
3
votes
2answers
37 views

“Figure” as name of listings in listoflistings with minted and newfloat

The following MWE gives me a List of Listings with "Figure" as name of listings. \documentclass{scrreprt} \usepackage{classicthesis} \usepackage[newfloat]{minted} \begin{document} ...
1
vote
0answers
56 views

Excessive vertical space after lstlisting

I have created a macro \piece to structure longer sections into smaller, numbered pieces. (I am using the macro in a set of lecture notes where I try to introduce one concept per piece.) The code, ...
1
vote
1answer
41 views

Format code listing package

I am documenting a script which has almost 43+ keywords. The output I want is something on the below lines... and the latex code I have is \documentclass[a4paper, onesided]{article} ...
4
votes
1answer
26 views

Beamer: Section used before declaration

I'm creating a presentation using beamer and listings - when I end a section with a {lstlisting} call, the next section title appears in the slide. Is there a way that I can specify when the next ...
1
vote
1answer
28 views

How to use lstlisting “moredelim” inside quoted text [RESOLVED, but with possible caveats for others]

update: Arun's answer, below, works for me, since I'm not using syntax highlighting anyway. Thanks! Here's my original question: I use the following setting to allow me to mark text as bold within ...
3
votes
1answer
34 views

Why does this listings command keep giving me this error?

\documentclass[titlepage]{article} \author{foobar} \title{foofoofoo} \usepackage{syntonly} \usepackage{verbatim} \usepackage{lipsum} \usepackage{listings} \begin{document} \maketitle \newpage ...
1
vote
1answer
19 views

Setting different environment setup depending on the location in two column (also considering the figure environment)

I asked about using listings environment to put the line numbers left or right side according to the location. Setting different environment setup depending on the location in two column The code ...
1
vote
1answer
30 views

Setting different environment setup depending on the location in two column

I have a lstlisting environment that shows a line number either left or right side of the document. Setting up lstlisting environment by passing parameters Setting the ruby code in a two-column ...
3
votes
1answer
24 views

Setting up lstlisting environment by passing parameters

I have listing setups (rubyl/rubyr) for ruby for the case the line numbering is on the left or right hand side. \lstdefinelanguage{rubyr}{ escapechar=\, basicstyle=\scriptsize\ttfamily, ...
0
votes
1answer
38 views

How can I use underscore in listings package properly?

I understand that underscore is a special character in LaTeX, but how can I input underscores within lstlisting blocks without changing the code block itself? Here is a short example: Settings: ...
2
votes
1answer
27 views

lstinputlisting not recognizing comment character

I have some code which I like to incorporate in to my latex document. I have set up the aesthetic so the code is easy to read as follows \lstdefinestyle{numbers}{numbers = left, stepnumber =1, ...
2
votes
1answer
38 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 ...
4
votes
2answers
186 views

Sourcecode colorization for more than one programming language

I want to colorize my source code. I followed this page and everything works fine. My problem is that I am using 4 different programming languages: Have I to define the \lstset{} tag separately for ...
1
vote
0answers
15 views

Listings With Two or More Sets of Keywords [duplicate]

I am looking for a way to create two different sets of keywords, because I want to assign each set of keywords a different color. The language of the code I want to import, is not supported by the ...
5
votes
1answer
36 views

Conflict with subcaption and sublisting?

In the code below, partially derived from Split subfigures from pgfplots groupstyle, I am not able to compile my code when I include the sublisting environment. I need this listing for my Python code ...
4
votes
1answer
77 views

Curly braces as comment delimiters

In the language I am defining in listings, text put inside {* and *} is commented out. I tried to implement this as morecomment = [s]{{*}{*}}, but understandably LaTeX gets the nesting confused. The ...
4
votes
1answer
81 views

Setting style for Python docstrings in lstinputlisting environment

I am using the listings package for source code in my LaTeX document. I am trying to set the style for docstrings in the Python programming language: \documentclass{article} \usepackage{listings} ...
1
vote
1answer
67 views

Ignore errors in environments in latex-suite in vim

I use the latex-suite vim plugin, which shows me errors inline in my vim editor. However, I get false positives for certain environments like lstlistings. How can I configure latex-suite to ignore ...
5
votes
1answer
111 views

How to reference source code listing

I am using the listings package to incorporate listings into my paper. However I'd like to reference individual parts of the code with a small circular number (such as say the number 1 in white ...
2
votes
1answer
39 views

listing in two-column mode

I want to place a listing, with colored background, in a two-columns document. For safety (for cases when the width of listing only slightly exceeds column width) I put the listing in a \maxsizebox. ...
2
votes
2answers
109 views

Some problem with listings and C++

I have to insert a C++ code in a .tex file but I want that is written with the text coloured like in the C++ program. If I use lstlisting there is the C++ program but in b/w. Any idea?
1
vote
0answers
49 views

Re-using tikzmark names?

It seems that tikzmark names can't be re-used. In the code below, I try to draw a box outline in the first lstlisting section, and a filled box in the second lstlisting section. In each lstlisting, ...
3
votes
1answer
56 views

How to dump listings to a file?

I thought to share my solution to a problem I had. (This is one of those “answer your own question” things, plus, this way, people can improve upon it – dual-licence under The MirOS Licence please. ...
4
votes
2answers
73 views

Drawing a rectangle around text inside lstlisting

I'd like to draw a rectangle (outline only, not filled) around a few words inside an lstlisting environment. I've tried the following, but it doesn't treat the text inside the box as "verbatim" as ...
2
votes
0answers
36 views

How to fix “Dimension too large” error with lstlisting

I use listings as the verbatim enviroment. However, I get the "Dimension too large" error with very long lines. The following is a sample code. \documentclass{article} \usepackage{listings} ...
0
votes
0answers
30 views

Forcing page break of a minted listing with \centering on

I am using minted to create a code listing. I need the listing to be centered so according to this solution, I use the \RecustomVerbationEnvironment to escape the verbatim environment so that it can ...