{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
79 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} ...
1
vote
1answer
42 views

Disable formatting for a selection inside listing?

I am typesetting my MATLAB code with package matlab-prettifier, which is essentially listing. However, sometimes I do not want the formatting. I simply want pure unformatted text. For example, in the ...
10
votes
0answers
405 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
48 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 ...
5
votes
0answers
152 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 ...
4
votes
0answers
106 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
81 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
34 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
62 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
32 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
35 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 ...
2
votes
0answers
75 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
68 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
93 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
239 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
53 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
3 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
37 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
40 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
37 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
44 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
38 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
52 views

List of Listings (LOL) multiple entries with the same name

I splitted some source code into various listing all with the same name "Company ontology" (to use the firstnumber=auto), now in my LOL I have multiple repeated entries, is there a way to solve, maybe ...
1
vote
0answers
93 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
62 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
35 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
50 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
66 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
132 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 ...
0
votes
0answers
59 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
280 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} ...