{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

2
votes
2answers
54 views

tcolorbox and Vietnamese

I am using tcolorbox with Exercise and Solution in Vietnamese, but I can't compile this code. What am I doing wrong? \documentclass[12pt,a4paper]{article} \usepackage{fouriernc} \usepackage[utf8]{...
0
votes
1answer
12 views

Keywords in Perl-POD breaking listing

I'm trying to include a perl-script with pod. It seems liks the listings-package does not detect the pod-documentation part as comment which breaks the rest of the listing. How to fix this behaviour? ...
0
votes
1answer
35 views

How to put a listing bloc and an image side-by-side? [duplicate]

for the finetuning I have to show a codelisting and the result as an image next to each other, otherwise it will be displayed on the next page and i have to crop it extremely. Here's my progress so ...
1
vote
1answer
19 views

Package listings and new language definition

I tried to define a few PowerShell cmdlets for the lstlisting environment, but it seems that the - breaks the definition. So when I try: \lstdefinelanguage{powershell}{ keywords = {Get-...
1
vote
0answers
31 views

Change the name of Listings [duplicate]

I have the following MWE: \documentclass{article} \usepackage{listings} \begin{document} \lstlistoflistings \end{document} It produces a listing header called "Listings". Is there a way to ...
1
vote
0answers
28 views

What is wrong with \lstinline (or my code :) )

I am using a package which makes some decoration on top of listings. It works fine, until I start to use \lstinline. The MWE works fine, until I remove the % in front of \global. Then \lstinline is ...
0
votes
1answer
24 views

How to change color of html tags in lstset?

I have a piece of code: "></li></a><script>alert(123);</script> that I would like to color using \lstset (i.e => the HTML tags like "li" "a" "script" would be dkblue color). ...
5
votes
1answer
103 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 ...
4
votes
1answer
40 views

error using tcblisting inside tabular when numbers is set

tcblisting gives error when adding numbers=left, but it does this only when inside tabular or longtable. This compiles OK \documentclass{article} \usepackage{amsmath} \usepackage{listings} \...
2
votes
1answer
53 views

How to automatically adjust font size for listings, so it fits gives amount of textwidth?

For code listings, I often change the listings parameter basicstyle to adjust the font size so that listing fit within the container it is in. I mainly use a cell in a table to display small listing ...
2
votes
1answer
22 views

Float package screws up list of listing format/style

Can anyone explain the following behavior: MWE: \documentclass[12pt]{report} \title{List of listings problem} \author{Gerjan} \date{June 2016} %\usepackage{babel} % Use dutch, british or english \...
2
votes
0answers
59 views

Code crashes on Mac OSX, not linux?

Using TexWorks. 2 people using Mac OSX, one El Capitan, one Yosemite. 1 person using linux. The following code works on linux: \begin{tabular}{|l|l|l|} \hline Scalar form & Meaning & ...
1
vote
0answers
13 views

Adjusting the text width of R listings in LaTex

Hi I have R codes that I am listing in my LaTex file with \begin{lstlisting}[language=R] R code \end{lstlisting} I have no specific listing setting in my preamble. My R code is very wide and ...
4
votes
1answer
28 views

Categorizing Listings

Is it possible to group listings by type? I have a document with two types of listings, namely one for source-code and one for series of shell-commands (and their outputs). So is it possible to have ...
3
votes
2answers
43 views

List of listing space before title

I know I can control the space of my listing titles with: \setlength{\cftbeforetoctitleskip}{35pt} % TOC: Table of Contents \setlength{\cftbeforeloftitleskip}{35pt} % LOF: Listing of Figures \...
3
votes
1answer
32 views

some corruption using \tcbinputlisting after repeated use

I could not make a smaller MWE than the following. I noticed at random places in the document, the listing comes out corrputed, then it becomes ok for a while, then it goes bad. I am basically using ...
0
votes
0answers
36 views

How to create a specific code listing macro

I am trying to reproduce a macro in latex that would allow to insert code in this format: So there is a header with listing number that is starting from the left side of the document. It is between ...
4
votes
1answer
112 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; \end{...
4
votes
1answer
32 views

Number listings the same way as figures and tables

For numbering figures and tables with 1 depth level like this: Figure 1.2 Table 3.13 I use the package: \usepackage{chngcntr} \counterwithin{figure}{section} \counterwithin{table}{section} \...
1
vote
1answer
33 views

using \tcbinputlisting shows first page only when hbox is set

I'd like to use the hbox option with \tcbinputlisting since it automatically adjust the background color and the box to the width of the code listing. The problem is that if the code listing is more ...
1
vote
0answers
34 views

Changing multiple properties within lstlisting in annimations

Currently I am in the process of preparing a C++ training with the beamer package. So far everything is great! From the answer to How can I highlight some lines from source code I grabbed a nice ...
9
votes
2answers
66 views

Inline links in code listings

I would like to include links inside source code listings by providing URLs within the listing source text. That is, I would like to be able to generate something that looks like the following: ...
2
votes
1answer
64 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 ...
3
votes
1answer
81 views

“Table of Figures” Title and “Table of Codes” Title not in the same line

Hello! I have the following problem: the title of my table of listings (codes) is not in the same position as the title of my table of figures is. You can see the 2 pages of the tables in the pic. I ...
0
votes
1answer
47 views

Space difference between list of figures and list of listings

See attached gif You got any clues how to fix that? I’m using a Koma class.
0
votes
0answers
21 views

Listings - collisions between literate and comment delimiter

Scenario: I want to get the listings environment to perform line breaks at forwards slashes "/" so that it will wrap long paths, which I can do by using the 'literate' option as follows: literate={/}{...
1
vote
1answer
24 views

Listings numbering in Appendix

Currently, I have an issue that in my thesis the numbering of listings in the appendix is not as desired. I currently only get Listing 1 as the numbering of the first listing in the first Appendix, ...
0
votes
1answer
25 views

Correct numbering of figures/tables/listings in Appendix

In my thesis I have several appendices, which are defined via \section{First Appendix}, \section{Second Appendix}, etc. latex statements. The appendices have the following titles (hence, appear like ...
3
votes
1answer
36 views

Conditionals work, Listings work, but when put together, no [duplicate]

In an earlier question I learned the following code to define conditionally compiled text (for a teacher guide) \newtoggle{teach} \toggletrue{teach} \NewEnviron{teachr} {\iftoggle{teach}{\BODY}{}} \...
9
votes
1answer
5k views

Is there a possibility to make reference to the line in the lstlisting environment?

I was wondering if it is possible to refer to the lines of the code enclosed in lstlisting environment rather than just manually write a number of the line I want to describe. I have never met with ...
0
votes
0answers
18 views

Getting package error when importing source file

I have a problem with import source code into my tex document. The source code is in language C with lots of comments like "\" and "* *\".
9
votes
2answers
97 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
53 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
33 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
38 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
135 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
29 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
38 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
35 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
20 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
39 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
41 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
41 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
560 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
16 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
110 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
34 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}} ... ...