{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

11
votes
0answers
452 views

TeXLive and MikTeX behave differently in handling BOM

It is a followup of my answer that has been converted to comment (click) posted several decades ago. Shortly speaking, MikTeX does not remove leading BOM but TeXLive does as shown in the following ...
11
votes
0answers
124 views

How can I make a custom environment that wraps listings?

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 ...
4
votes
0answers
89 views

\inputminted: distinct file parts in one listing (equivalent to linerange in listings)

I want to include code from a file into my document. However, several distinct line ranges should appear in the same listing. Also, I want to use gobbling, and it would be nice to include some blank ...
4
votes
0answers
48 views

Add vertical space only if there is no pagebreak

I'd like to define a new listings environment where the listing has an \hrule before and after the listing itself. In order to do this I've defined this environment: \lstnewenvironment{haskell}[1][] ...
4
votes
0answers
152 views

(Clickable) cross-reference in lstlisting

To generate documentation for an 'application programming interface', I would like to have a syntax highlighted area (with the class declaration), which has clickable links to the documentation (which ...
4
votes
0answers
101 views

Unicode and listings - still no luck

Although there are already some discussions on this issue, I can't get any of the proposed solutions to work for me. Take this document and compile it with xelatex: ...
3
votes
0answers
45 views

How can I make listings look like minted?

Up until now I used the listings package for my code-listings. Today, I tried minted and I'm pleased with the default look. Since I'd have a lot to do to switch from listings to minted at this stage ...
3
votes
0answers
43 views

How to add my listings to the table of contents?

I am using the thesul class. I would like to add my listings to the table of contents. I found a way to do that by using the \addcontentsline{toc}{spsection}{Listings} command: \tableofcontents ...
3
votes
0answers
38 views

minted or listings input a file between markers

Is it possible, using the minted or listings package to format a file between or till a certain textual marker automatically. E.g. consider a source file: code code //marker code ... //end marker ...
3
votes
0answers
77 views

Drawing arrows using tikz package (fine tuning coordinates)

I am making some lecture slides for my class and sometimes I need to label the different components of the C/C++ program. For this I have referred to the post How can I draw arrows within a listing to ...
3
votes
0answers
69 views

How to use same font-style with escapechar in lstlisting?

Original Question I want to highlight something inside a C++-comment in a code-listing. \documentclass[a4paper, 12pt]{article} \usepackage{color} \usepackage{listings} ...
3
votes
0answers
81 views

Can I use “moredelim” in package “listings” to fetch a regular expression?

I would like to know if it is possible to use the listings package to highlight regular expressions in order to make them look like a normal string object. Note: The syntax of a regexp is not context ...
3
votes
0answers
256 views

fancyvrb + listings inside a list

I'm trying to put Verbatim environment from fancyvrb package, with activated interface to listings package, inside enumerate environment. When Verbatim environment is first element in \item, item's ...
3
votes
0answers
77 views

Listing sourcecode - two columns, associations with colored background

I stumbeled over a way of formatting sourcecode in a book I am currently reading. It looks like this: So basically we have a following structure: There are two columns. Left column contains the ...
3
votes
0answers
202 views

listings: How can I highlight Makefiles?

I am trying to typeset a makefile using listings. Now I would like some differential highlighting, e.g. for variables and ordinary commands in the target body. In this snippet, want to have different ...
3
votes
0answers
86 views

Relatives/absolute path for listing with subfiles

I have problem with path management. Let me explain you: I work with subfiles that are arranged in this way: REPORT --Main.tex --lab1 ----Matlab ------CodeLab1.m ----Report ------Report_P1_1.tex ...
3
votes
0answers
290 views

How to make listings display characters special characters

I am trying to show a directory structure of a tree using the listings package like so: ├── controllers │   ├── application_controller.rb what I get looks like this: controllers ...
2
votes
0answers
34 views

Listings - Getting the colors right for custom language

I have lots of bookkeeping transactions that I would like to typeset in a color coded format. I am using the listings package to accomplish what I want. I tried the following code. ...
2
votes
0answers
61 views

Unhighlighted syntax with listings package

I have some trouble with making documents with syntax highlight. Here is the MWE: \documentclass{article} \usepackage{xcolor} \usepackage{listings} \lstset{% language=[LaTeX]TeX, % I also tried ...
2
votes
0answers
62 views

Python console code with minted

I am using minted to highlight source code in my document. I have defined \definecolor{codeyellow}{RGB}{255,251,204} \newminted{python}{linenos,breaklines,frame=lines,bgcolor=codeyellow} in the ...
2
votes
0answers
23 views

Indentation marker for listings

I'm currently writing a document that contains several code samples. I included them as lstlistings and played around with the colors and everything, so they loot quite nice now. My only problem is ...
2
votes
0answers
39 views

How to highlight php code in a HTML document and the document itself?

how can I highlight php code in a HTML document and the document itself? Example: <!DOCTYPE html> <html lang="de"> <head> <meta charset="utf-8"> ...
2
votes
0answers
51 views

How to mix LaTeX listings numbering with custom characters?

In order to display a command-line GAP session using the listings package, I need to distinguish between input and output. I tried to do this by appending a marker in front of every output line, so ...
2
votes
0answers
27 views

Listings package and forcing inclusion of empty lines at end of line ranges?

By default, the listings package suppresses empty lines at the end of the file, and this behavior can be switched off with the option showlines. However, listings also suppresses empty lines at the ...
2
votes
0answers
84 views

linewrap included Javafile with lstinputlisting

I've spent few days already trying to properly include a Java source file dynamically in a tex file. The text is included. However the lines don't wrap. The following is the "srinked" project ...
2
votes
0answers
29 views

XeLaTeX Listings package tabsize not correctly shown

I'm using XeLaTeX and I used the listings package to display some source code. In \lstset I set the tabsize to 4: \documentclass[a4paper, 11pt]{article} \usepackage{filecontents} ...
2
votes
0answers
116 views

Use dollar sign in verbatim environment within auctex

I am using something similar to the following, \documentclass{article} \usepackage{listings} \lstnewenvironment{shellsession}[1][] {\lstset{language=bash basicstyle=\small\ttfamily, ...
2
votes
0answers
102 views

Different display of listing's background (Texmaker internal PDF viewer & Adobe Reader)

I have following code: \documentclass[10pt,a4paper]{article} \usepackage{color, eso-pic, tikz} % Create commutative diagrams \usepackage{listings} \definecolor{light-gray}{rgb}{0.95,0.95,0.95} ...
2
votes
0answers
93 views

Listings: color numbers only out of keywords

With the listings package, I would like to color the integers out of strings and comments and out of keywords too. The question for coloring numbers has been asked several times. Some answer handle ...
2
votes
0answers
118 views

Code alignment using listings with proportional fonts is poor

I would like to typeset code using proportional fonts and the listings package, but no matter what I do, alignment is always off. Here is an example in Java (taken from Wikipedia): ...
2
votes
0answers
87 views

Different colours for each argument and value in listings

This recent question (Print blue brackets in one language and black in another) made me come up with (up to) two more questions regarding the listings package: Is there an option similar to opstyle ...
2
votes
0answers
114 views

How can I apply different custom caption styles to different listings?

In the MWE below, is it possible to define different caption formats for the two listings? In the example the first listing should use a blue caption background (like it is now) while the second ...
1
vote
0answers
28 views

Problems with PHP tags (and code) in listings with HTML

I want to highlight PHP and HTML in the same code. In my attempts I experience three challenges: Seems like listings treats <?php and ?> as one large HTML tag. How to tell listings that the ...
1
vote
0answers
24 views

incorporating R code in latex, commentstyle not working

I have an issue with no all my R comments being colored in my latex file. I am using the listing package. My pre-amble code is \lstset{ % language=R, basicstyle=\footnotesize, ...
1
vote
0answers
37 views

Typeset code within a simple macro?

I want to use a macro to typeset programming code with the usual characteristics (particularly lines should be obeyed - this is the most important issue; highlighting and such stuff is - for now - not ...
1
vote
0answers
31 views

Define listings for PHP

Problem: 1) Getting the following error messages: (a) Package Listings Error: Couldn't load requested language (b) Package Listings Error: language phpalsodigit undefined. 2) Unable to figure out ...
1
vote
0answers
37 views

Custom lstlisting highlighting for symbols

I using the Listings package to pretty print CUDA source code listings. CUDA is a dialect of C++, so I define my style as follows: \documentclass{article} \usepackage{listings} ...
1
vote
0answers
122 views

How can I typeset PowerShell code with the listings package?

I'm currently creating my diploma thesis, and used PowerShell to do some of the described work. I'd like to also put some of this code into the thesis and would therefore like to have syntax ...
1
vote
0answers
67 views

Add caption and list of listings to own listings environment

With listings and caption packages I can set up caption for lstlisting with \captionsetup[lstlisting]{...} create list of lstlistings \lstlistoflistings I can also define my own environment ...
1
vote
0answers
63 views

How to add function names to listings package

I have some MATLAB code in my tex file, which I am highlighting with the listings package. However, there are some functions, such as "vision.CascadeObjectDetector", "imcomplement", "bwboundaries", ...
1
vote
0answers
74 views

List Of Listings Overlapping Text

I'm attempting to generate a list of listings for my dissertation. The university doesn't have a standard LaTeX template, but there is a pretty good one generated sometime ago that does the trick. The ...
1
vote
0answers
37 views

Use listing with automatic page break

I want to put some of my python-code in the appendix of my latex file. For that I use the following code: \begin{minipage}[c]{0.95\textwidth} \lstinputlisting[caption=Python script used for fitting ...
1
vote
0answers
66 views

Verbatim vs Listings for Thai Font

I have a problem about verbatim and listings. I need write some codes by using Thai font but it shows in picture \documentclass[12pt,a4paper,oneside]{book} \usepackage{verbatim} \usepackage{listings} ...
1
vote
0answers
22 views

How to get listings package line number behavior of v1.3 in v1.5?

In the listings package v1.3, when including lines from a file, the numbering is that from the file, even if lines are omitted (absolute numbers). But in v1.5, the numbering ignores the location in ...
1
vote
0answers
41 views

Inserting a stand alone code file using lstlisting

I am in the process of writing a report on a project and need to include the final code used in an appendix. The final code while not yet complete, is lengthy enough that I would like to just use ...
1
vote
0answers
58 views

Using xtable with listings package

I am the listings package as suggested by the following solution provided in this question: Getting Sweave code chunks to stay inside page margins? More specifically, I am using the following piece ...
1
vote
0answers
60 views

use path with spaces in listings fails when \usepackage[dutch]{babel} is used

EDIT: I just discovered that it is not due to the spaces but the " ": {"E:/Cloud storage/GitHub/JS_PCI/afronden2.js"} this line works if Babel is disabled and this one: {E:/Cloud ...
1
vote
0answers
50 views

Changes sides of lstlisting line numbering when switching pages

I am currently writing some tesxt for my masters thesis. I have a coste listing which expands on two pages. I would like the listing to change sides of line numbering when switching the page. Is there ...
1
vote
0answers
70 views

Highlight indentation level in code listings

I try to highlight the indentation level of some code listings to explain indentation behaviour of my language. My language is whitespace sensitive. Indentation indicates block structure similar to ...
1
vote
0answers
106 views

Extra space in \lstinline

When using the \lstinline macro from listings, like \lstinline|subl| some extra whitespace is added to the intended text. It is especially painful at the end of the line: it behaves as if it were ...