{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

6
votes
1answer
160 views

Preventing line break at the start of a long name in `\lstinline`

This question has developed from How to deal with very long lstinline-phrases like long class names?. That question is about line breaking inside a \lstinline phrase. I have provided an answer which ...
2
votes
1answer
107 views

showexpl not showing caption of a lstlisting within

How can I make the LTXexample environment to show the caption (like it does with other environments) of a lstlisting that is inside it. Consider the following code \documentclass{article} ...
10
votes
0answers
413 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 ...
6
votes
0answers
57 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
122 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
88 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
58 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
49 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
37 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][] ...
3
votes
0answers
70 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 ...
2
votes
0answers
55 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 ...
2
votes
0answers
71 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
21 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
93 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 ...
2
votes
0answers
36 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
60 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
56 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
91 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
74 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
98 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 ...
2
votes
0answers
249 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 ...
1
vote
0answers
20 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
36 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
24 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
47 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
69 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 ...
1
vote
0answers
31 views

Listing caption numbers are reverse in the list of listings

Consider the following code: \documentclass[a4paper,10pt]{book} \usepackage{listings} \usepackage{xepersian} \settextfont{FreeFarsi}% http://sourceforge.net/projects/fpf/ \DefaultMathsDigits ...
1
vote
0answers
93 views

listings - highlighting additional keywords inside own delimiters (like Doxygen annotations)

According to listings - use different style for normal comments /* and doxygen comments /** I used listings package to set style for /** Doxygen comments */ as user defined delimiter moredelim = ...
1
vote
0answers
18 views

lyx program listing whitespace character

In ubuntu 14.04, I used lyx to write documents in which have source code(C language) embedded. I wrote code by using Insert->Program Listing. For example #include <stdio.h> int main() { ...
1
vote
0answers
44 views

increase margins of floats page

I have several sections in my article, each with a sizable (~22 lines) code listing explaining the concept of that specific section. I do want to float my listings, as they look nasty if broken off ...
1
vote
0answers
45 views

Spacing between words in listings package and emphasizing identifiers

I have written some source code using listings package but is stretching out of the page. This package leaves huge spaces between the words, so is there a way to make them smaller? At least like the ...
1
vote
0answers
59 views

How to make listing program ConTeXt at LaTeX ?

I want make listing program Context at LaTeX, my MWE like this : \documentclass[]{article} \usepackage{listings} \usepackage[dvipsnames]{xcolor} \lstset { frame=single, framesep=\fboxsep, ...
1
vote
0answers
46 views

Aligning listing frame width between two listings

I'm trying to get two listings side by side. One is shorter than the other, but I would like to have them aligned, meaning that the frame height of the short one should be longer to reach the baseline ...
1
vote
0answers
173 views

Pandoc: Markdown to PDF: select code without select number into code block

i want to generate the code block and i try example and it work. but when i try to select the code from the pdf, the number also get selected. how to generate code block that when select the code w/o ...
1
vote
0answers
59 views

Work around 'Dimension too large' using `framed` with `listings`

I'm including an external source code file as an appendix using the listings package. The framed package is being used to ensure multi-page listings frames are fully closed. The problem is if my ...
1
vote
0answers
98 views

How to undo the feasible breakpoints of `lstlisting`?

Is there a way to prohibit pagebreaking at the beginning/end of an lstlisting environment? I'm trying to keep together the following two pairs of lines: the first line of lstlisting and the line ...
0
votes
0answers
15 views

lstinputlistings mark parts of the code

I am including my source code with the listings package and \lstinputlisting[options]{path/to/code.c} Now I want to mark some parts of the code with a different background, or a different text ...
0
votes
0answers
43 views

Many \lstinputlisting[..]{…} — but need standalone *.tex file

For the final submission to a journal of our manuscript, they need one foo.tex file (plus a foo.bib, the figures as *.pdf). Our manuscript however uses dozens of ...
0
votes
0answers
88 views

Font shape 'OT1/cmvtt/bx/n' undefined

I'm getting the following warning: Latex Font Warning: Font shape 'OT1/cmvtt/bx/n' undefined (Font) using 'OT1/cmvtt/m/n' instead on input line 25 How can I suppress that warning? Or: ...
0
votes
0answers
47 views

Error in tabularx+listings example with TexLive 2014, which compiles in TexLive 2011 (! Missing { inserted)

Consider this MWE: \documentclass{article} \usepackage{trace} \usepackage{tabularx} \usepackage{booktabs} % \toprule etc; \let\botrule\bottomrule % temp hack \newcommand{\tn}{\tabularnewline} % for ...
0
votes
0answers
54 views

How do I hide page numbers when overlapped?

I'm trying to add an environment for code listings to stay on one page as described in "How to prevent lstlisting from splitting code between pages?". When my listing is at the bottom of the page, ...
0
votes
0answers
81 views

How to install listings.sty in tex-live DVD version. Ubuntu/Fedora

I run tex-live (pdfLatex) at home on Ubuntu and on Fedora in college. And this error comes up every time and forces me to go to the WriteLatex website. I know the Windows solution of running MPM. But ...
0
votes
0answers
67 views

Layering/twocolumn conflict using tikzmark

LaTeX gurus, inspired by the ideas and code in Automatic background coloring in listings using tikzmark, I attempted to create my own macros for teaching programming. What I really wanted, just to ...
0
votes
0answers
347 views

How to replace (unicode) characters by ü,ğ,ş etc.?

\documentclass[11pt,a4paper]{article} \usepackage[utf8x]{inputenc} \usepackage{ucs} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{graphicx} \usepackage[T1]{fontenc} ...