{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
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 ...
0
votes
1answer
53 views

How to create a listing like this:

What package do i need ? And what are the code lines i need? Thank you!
4
votes
1answer
3k views

How to include Maple code in LaTeX?

At here Fanciest way to include Mathematica code in LaTeX we can include Mathematica in LaTeX. I want to include the code restart: with(geom3d): eqS:=Equation(sphere(S,(x-1)^2 + (y-1)^2 +(z-1)^2 -...
2
votes
2answers
13 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 ...
4
votes
1answer
62 views

Using the same line numbers in lstlisting on repeated beamer slide

In the following example, the line numbers on the second occurrence of the slide start from "3". But the references in the itemize item of the second occurrence of the slide show as "1" and "2" (i.e. ...
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
31 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, ...
2
votes
1answer
27 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 ...
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, ...
47
votes
2answers
5k views

minted vs. texments vs. verbments

Regarding the typesetting of syntax-colored source code, I know that listings is inferior because it doesn't utilize a full lexer. Instead the Python-based solution is recommended. It seems there are ...
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
123 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 ...
0
votes
1answer
71 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 ...
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
27 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 ...
3
votes
1answer
33 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
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]{...
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? ...
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 ...
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-...
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 ...
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). ...
5
votes
1answer
108 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
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
1answer
58 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
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 & ...
1
vote
0answers
17 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
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
44 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
41 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
113 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
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} \...
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 ...
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 ...
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: ...
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
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
1answer
51 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={/}{...
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, ...
0
votes
1answer
34 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 "* *\".