{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
16 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 ...
0
votes
0answers
40 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: ...
3
votes
1answer
27 views

Package listings and Perl here documents with apostrophes

I sometimes write ordinary English prose in my here documents in a Perl usage sub, for example --[no]alias [don't] use the alias list in the ini file (default noalias) The problem is the a ...
3
votes
1answer
47 views

Why do minus signs vanishes in listings typeset with matlab-prettifier? [duplicate]

I am typesetting my MATLAB code with package matlab-prettifier. However, the - sign are gone. How can I get it back? MWE \documentclass[12pt]{article} % For MATLAB code ...
3
votes
1answer
150 views

TeX capacity exceeded with listings package

In trying to find the source of the following error in my LaTeX document, the listings package seems to not be runnable The minimal example, which I implied but did not include was: ...
0
votes
0answers
15 views

Argument of lstlisting [closed]

I'm defining an environment which takes an optional parameter like this: \documentclass[a4paper,12pt]{book} \usepackage{listings} \usepackage{etoolbox} \usepackage{xstring} \usepackage{xparse} ...
1
vote
1answer
33 views

How can I set a font size smaller than \tiny in lstlisting?

I'm writing a presentation using LaTeX and beamer. In some slides I put an image and some code using the listings package and the lstlisting environment. I'd like to use a font size smaller than \tiny ...
2
votes
1answer
34 views

tcblisting: two listings side by side

can anybody tell me, how to place two source doe listings side by side within a tcblisting? Something like: \begin{tcolorbox}[colback=red!5!white,colframe=red!75!black,sidebyside, listing ...
1
vote
0answers
24 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, ...
4
votes
2answers
59 views

Unnecessary line break with listings and prebreak

A lstlisting environment with prebreak may break lines unnecessarily. Here is an MWE: \documentclass[draft]{article} \usepackage[final]{listings} \begin{document} \begin{lstlisting} 1 3 5 7 9 1 3 5 ...
3
votes
1answer
29 views

Using listings within a \only section

Is there any way to use listings within \only sections of Beamer presentations? The following is an example of what I'd like to achieve: \documentclass{beamer} \usetheme[height=7mm]{Boadilla} ...
2
votes
1answer
34 views

Vertical border between number and code in lstlisting

what I am trying to achieve is a vertical line between the line numbers and the code in a lstlisting. I have experimented with the frame option a lot, but i guess it is not possible this way, if at ...
0
votes
0answers
52 views

TexMaker compiles without errors, but not updating PDF after new package installed [closed]

I want to implement MATLAB source code into my LaTex document, and I know that I need listings package in order to be able to do that. However if I use the \usepackage{listings} and/or ...
5
votes
1answer
56 views

Can you specify a word separator for variables in listings?

Depending on the language specified, the listings package may or may not bold keywords inside of variable names. Python is fine \documentclass{article} \usepackage{listings} \begin{document} ...
0
votes
0answers
25 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 ...
1
vote
1answer
39 views

how to use verbatim within a list

I tried to use verbatim within a list like this: \begin{lstlisting} Search(HTMLpage, \begin{verbatim}``<TITLE>*</TITLE>''\end{verbatim}); Copy(HTMLpage); Paste(Title); \end{lstlisting} ...
3
votes
1answer
63 views

Should I use \lstinline for the language keywords embedded in text?

When writing about programming languages, there are examples to format as listings. That works fine and produces beautiful results. Sometimes I want to mention the keywords used in the listing further ...
5
votes
1answer
54 views

Can I avoid source formatting with the listings package?

Is there a way to use the listings environment, without resorting to a specific language formatting? (but instead use the usual Latex commands being formatted correctly.) The reason I want to do it ...
0
votes
2answers
54 views

Listing spanning two columns with ieee template

I'm writing an article with the IEEEtran template, which have two columns. I'd like to have a listing with source code that spans the two columns of the article, like in the attached figure. I'm ...
1
vote
3answers
67 views

How to make listings with mathematics notations?

I have a problem about make a listing program and I want make it like this: For my example: \documentclass{article} \usepackage{listing} \usepackage{amsmath} \begin{document} ...
0
votes
1answer
13 views

Script error in latex and appendix subsections

I have two queries; I need to put a 628 line script in Latex which contains special characters(!,_). For example, !M11 is M_theta (moment about meridian(2) axis) but this gives me ERROR: ...
16
votes
1answer
256 views

How can I draw arrows within a listing to explain positional association?

I need nice drawing in lstlisting C/C++ code. I'm trying to make something like this This is what i have made so far \documentclass[11pt]{article} \usepackage{listingsutf8} \usepackage{tikz} ...
0
votes
0answers
46 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, ...
2
votes
1answer
53 views

LuaLaTeX and listings do not work while XeLaTex works fine

I am trying to move from XeLaTeX to LuaLaTeX. I have some listings with special delimeters (an underscore). The following MWE compiles perfectly under XeLaTex, but gives the following error under ...
6
votes
1answer
42 views

Code listing inside of tabu environment

I'm trying to insert a small code listing into a tabu table, however I'm unable to build a PDF. The code I'm trying to use (well- a simplified form of it) is as follows: % !TEX encoding = UTF-8 ...
1
vote
1answer
27 views

Custom caption for lstset to use in table of contents [duplicate]

I would like to use the functionality of figure captions (that can have two captions: one for table of contents and one for the caption below/above the figure) with my custom filecode environment. ...
0
votes
1answer
94 views

Beamer: How to showcase LaTeX-Code and results that look like scrartcl

We are currently working on a beginner's course for LaTeX. We are using LuaLaTeX and Beamer for the slides. We typeset code with the listings-package. We often show Code on the left and a result ...
3
votes
0answers
30 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][] ...
1
vote
1answer
93 views

Problem listing (List of Listings) in the table of contents [closed]

I am writing a document using Latex. I have group pf codes in my document and I wanted to show it in the list of contents. I managed to do so, but I still have (contents) appearing in table additional ...
3
votes
1answer
47 views

listings-package custom language delimiter match left-side

I'm trying to define a new language cli-like interface, but I can not figure out how the use the delimiter to match my prompt. I want to apply tree different styles to the text. In the example below ...
6
votes
2answers
37 views

How to skip first line lstlistings

I need help for lstlistings. I have a code that start with: INPUT: c, m rest of code... I want that the first line doesn't view the number line. This is my lstset: \lstset{language=Java, ...
5
votes
1answer
72 views

Strange “Undefined control sequence” message

I am using biblatex for the first time. When I do quick compile on the document it compiles no problem, after that I run the BibTeX command and it also works. After that I try a quick compile again in ...
2
votes
1answer
53 views

Unable to define scala language with listings

I'm using the solution here for scala support, but this fails to properly color the scala code, and throws a number of errors when processing lstset - % ! Package keyval Error: breakatwhitespace ...
5
votes
1answer
52 views

Multiple literates in a listings style definition [duplicate]

I have a style defined for a language which has lot a lot of literate replacements. In the individual listings that use this style I would like to introduce more listing-specific literate ...
0
votes
1answer
56 views

Including both XML code and Java code in a document using lstlisting package

I am writing a document which has both java and xml codes, I managed to highlight my java code but unfortunately I was unable to do the same with xml, so far I have tried more than one way either by ...
0
votes
0answers
32 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 ...
2
votes
1answer
81 views

Coloring tables without xcolor, colortbl and tabu while using listings package

currently, I want to color my tables. However, presumably since I'm using the listings package, I can't apply the abovementioned packages, as they totally mess up the default table looks (lines ...
3
votes
1answer
52 views

Customize Color for lstset morekeywords

I have done some extensive searching and have yet to find the answer to changing the color for lstset morekeywords. I want them to be a different color than my regular keywords. Here is what I have ...
0
votes
1answer
45 views

Weird symbol in white spaces inside listings environment [duplicate]

I get that symbol inside quotes in listings environment. It seems to appear only inside quotes.Outside of them it seems that is not happenning the same thing. Why do I have that problem and how can I ...
1
vote
1answer
75 views

How to avoid Greek letter symbols in lstlisting

I am using the lstlisting package, but I don't want it to show Greek letters by its symbol. For example: \begin{lstlisting} Parameter.delta_x = 0.002e-6; \end{lstlisting} I want that line ...
1
vote
1answer
67 views

How can I prevent page breaks from occuring inside the body of a function?

Is it possible to tell the listings package not to insert page breaks inside the body of a function? For instance, void foo() { // Do not insert page break here } //But here is fine An ...
4
votes
2answers
146 views

How can I automatically replace subscripts and highlight GoTo labels?

I have to show a lot of autogenerated code throughout my document. The generated code represents loops with explicit block labels and gotos. The following code applies function f to each element of ...
1
vote
0answers
39 views

keyval error for listings/color? [closed]

When I try to compile this in my code, the compiler tells me Package keyval Error: backgroudcolor undefined. I really don't understand why it is telling me that when I know the package is installed. I ...
4
votes
2answers
103 views

Bad Character code (256)/ \select@language{greek}

I was trying to install minted package in TeXLive. I installed it and then run sudo tlmgr update --all. It was running slow so I stopped it using Ctrl+Z in an ubuntu terminal and then I run sudo tlmgr ...
3
votes
1answer
108 views

How can I replicate the syntax-highlighting style of the Kate editor?

I am trying to add a java and c++ code in a LaTeX document. I am using listings package and I will define a different style for each language using \lstdefinestyle{myStyle}{<options>}. What I am ...
3
votes
1answer
46 views

How can I reduce the line spacing in a listing?

I have some listings in my beamer presentation. Sometimes, the last line of the code I want to explain doesn't fit on the slide. I've already configured the font size to scale .7: ...
15
votes
1answer
399 views

Is there a good reason for lstlistings code to look so ugly by default?

I thought, the purpose of LaTeX was to make it easy to create beautiful documents. Yet every time I see one of those lstlistings I can't help but wince at the mutilated kerning. Take for example this ...
3
votes
2answers
220 views

Read integers from external data file to document programming code in LaTeX

I am attempting to document my MATLAB programming code in LaTeX. For this, I use the mcode package, which defines the MATLAB lstlisting environment. With the commands ...
5
votes
2answers
88 views

Remove margin from listings in beamer

I am including some code in my beamer document. I would like to get rid of all margins, so I can include as much code as possible. This is the code I am trying: \documentclass[]{beamer} ...
0
votes
1answer
164 views

How to place the caption of a lstlisting in the margin? (scrreprt, floatrow)

In the following mwe I am using the floatrow package to place the figure captions in the margin. How can I do the same for listings? Update: Some listings are spread over two pages. ...