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

How to create a listing like this: [on hold]

What package do i need ? And what are the code lines i need? Thank you!
2
votes
2answers
14 views

How can I get matching curly double quotes using listings?

I'm having a strange problem with listings. I'm trying to use matching double quotes around strings, as in this minimal example: \documentclass{article} \usepackage{listings} \lstset{ language=...
4
votes
2answers
44 views

Using \input inside environment fails

I'm trying to use the filecontents package in combination with listings as suggested in How to define macro that only makes argument substitution? in order to produce a side-by-side view of LaTeX code ...
0
votes
1answer
12 views

Lstinputlisting, ranges and unicode characters

I am using unicode characters in some code examples. If I set the listing completely, everything works as expected when the font supoorts the characters. But once I want to omit lines with lsitings'...
4
votes
1answer
25 views

Display wrapped unix commands that can be selected with double click

Not sure if this is possible at all. I have to display UNIX commands in a user manual, some of them quite long. These will not fit in a single line so they have to wrap. To display them I tried both ...
4
votes
1answer
14 views

Quotation marks in an escaped sequence of a lstlisting don't appear properly

I'm trying to make some parts in HTML code in a lstlisting coloured by using \textcolor in an escaped sequence. I've used this technique in another code snippet where everything worked out fine. For ...
1
vote
0answers
28 views

Syncing Python code with LaTeX document using Listings package

I have a Tex document that uses the listings package to print a Python source code. I also want to separately print certain Python function signatures in my document. I do not want to use the line ...
3
votes
1answer
45 views

How to force source code to be written LTR in a RTL document?

I am writing an Arabic book in LaTeX where I have to put much C code in it. I am compiling it using XeLaTeX. To have a proper Arabic support I use polyglossia package. For source code, I use listings, ...
1
vote
0answers
33 views

“This file requires `listings.sty' version 1.6”

I have written my paper in LyX, and exported to LaTeX. When I compile on the journal website, the resulting pdf says: This file requires `listings.sty' version 1.6. You have a serious problem, ...
0
votes
0answers
29 views

Define new column type in which content is surrounded by an environment

Building on this example: \documentclass{article} \RequirePackage{longtable,nameref} \usepackage{amsmath} \usepackage{xcolor} \usepackage{listings} \lstset{ frame=single, breaklines=true, ...
2
votes
1answer
29 views

listings with R: keywords in variable names are highlighted when using underscores?

When using language=R as a lstlistings style, if a variable name contains a keyword surrounded by underscores it will be highlighted. See the image and code example below. What can I do to prevent ...
2
votes
1answer
24 views

Set format of the document as the format for the listing

I would like to set the text format of the document as the format for the listing. The words in the listing accross my tex document have a bigger space between the characters. I want them to the have ...
4
votes
1answer
124 views

Use dollar sign as well as the math mode in lstlisting

Is it ever possible? I want display the dollar sign correctly in the beginning in the bracket, then I want to display a right arrow and display another bracket. \begin{lstlisting} //basic ...
1
vote
1answer
63 views

Colored word with listings

I added to the list of keywords by the colorful package listings (python) some functions of scipy.signal library using the otherkeywords control, I added the lti order, this order is put in color but ...
4
votes
1answer
27 views

How to hide path in lstlistoflistings?

When I am making a list of listings in my latex report, using: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{listings} \lstset{language = Matlab, inputpath=./Code/} \begin{document}...
1
vote
0answers
29 views

Two different listings at the same time

I would like to show two different pieces of listings at the same time in a slide. With the following code the second listing only shows up at the end, while I would like it to alongside with the line ...
0
votes
1answer
16 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? ...
2
votes
2answers
88 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]{...
1
vote
0answers
34 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
1answer
24 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-...
0
votes
1answer
37 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 ...
0
votes
1answer
27 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). ...
3
votes
1answer
34 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 \...
1
vote
0answers
18 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 ...
2
votes
1answer
59 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 ...
4
votes
1answer
30 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
45 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
38 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
42 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 ...
1
vote
0answers
37 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 ...
1
vote
1answer
40 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 ...
4
votes
1answer
37 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} \...
4
votes
1answer
44 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
0answers
62 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 & ...
0
votes
1answer
52 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
22 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={/}{...
0
votes
1answer
35 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 ...
1
vote
1answer
28 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, ...
9
votes
2answers
68 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: ...
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}{}} \...
3
votes
1answer
82 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
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 "* *\".
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{...
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 ...
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,... ...
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
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{...
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 ...