{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
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
51 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 ...
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 ...
7
votes
2answers
244 views

Change the background color of line numbers in a lstlisting?

Consider the following code which deals with a lstlisting. \documentclass{article} \usepackage[T1]{fontenc} \usepackage{listings} \usepackage{xcolor} ...
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
74 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 ...
0
votes
1answer
162 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. ...
2
votes
1answer
452 views

How can I typeset Greek letters in listings?

Is it possible (and if yes, of course how) to use Greek letters within lstlisting (of the listings package)? However, \epsilon, for instance, puts of course exactly that and not a Greek epsilon. I ...
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 ...
15
votes
1answer
396 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 ...
5
votes
2answers
2k views

Background overflows when using rounded corners for listings (package: `listings`)

I'm using listings to list code in my document, and I want the code to be displayed in a frame with rounded corners and a grey background color. But the background overflows the frame, as if the frame ...
4
votes
1answer
436 views

Make arrows inside lstlisting

Inside my lstlisting environment I want to make the assignment symbol an arrow instead of =. How can I do that? Adding just \leftarrow doesn't work, because then the whole word is displayed.
9
votes
1answer
98 views

How can I highlight \[…\] properly in LaTeX listings?

The listings package provides the option moredelim, allowing for custom styles for words enclosed by given delimiters. I would like to give $...$, \[...\] and $$...$$ custom colors. \[...\], however, ...
2
votes
3answers
317 views

How can I highlight text before a character with listing?

All is in the title. I would like to add a color to the text before a character with listing package. For example, I would like to add a color to text between the beginning of a line and : or =, in a ...
13
votes
4answers
3k views

lstlistings: framed code [closed]

I use lstlistings to write Pascal Code. I'd like my code to be numbered and framed. Here is what I have as of now : \lstset{numbers=left, numberstyle=\small, numbersep=8pt, frame = single, ...
3
votes
1answer
517 views

Rendering VHDL in latex

I have a VHDL code which I want to insert into my latex document. I need a package that takes care of syntax highlighting, indentation etc. Is there a package which serves this purpose?
2
votes
1answer
107 views

How to include program listings in C# with custom font and syntax highlighting in LyX?

I'm rather new to LaTeX and use LyX editor to create my documents. There are similar questions but none of them answer how to do that in LyX. I am wondering, how to include a program listing in ...
3
votes
1answer
59 views

Line breaks inside inline code break syntax highlighting. Any workaround?

I want to have both code snippets ABC and ABC_DEF in red (in both cases only ABC is red). If I remove the literate line it works but I also want to have automatic line breaks at underlines. How can I ...
1
vote
0answers
38 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 ...
3
votes
1answer
105 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 ...
4
votes
2answers
100 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 ...
4
votes
1answer
905 views

deletekeywords in Listings package sometimes doesn't work

Using the listings package, I can use deletekeywords to remove keywords, and so the keyword is not rendered in bold. For example, the for from the following is not in bold font: ...
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} ...
3
votes
1answer
45 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: ...
3
votes
2answers
218 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 ...
1
vote
1answer
48 views

Package “listings” command “morekeywords” doesn't work

I'm currently using the listings package to display my matlab code in Latex. However, when trying to add new keywords to the package, nothing happens. Here's a MWE: ...
4
votes
2answers
99 views

Issues when including matlab code in Latex

I am currently trying to implement my Matlab-Code into TeX. Weird enough, when programming a minimum working example, everything works pretty fine. However, when I use my real document, I only get ...
1
vote
0answers
37 views

Underscore not showing up in lstlisting [closed]

I have the following code: \begin{lstlisting} path/usearch -cluster_otus inp.fasta -otu_radius_pct distInPercent -otus outGroups.fasta -fastaout outpUSEARCH.fasta \end{lstlisting} The ...
1
vote
1answer
29 views

Have tableofcontents as PDF bookmark, but not lstlistoflistings

I want to have the "Contents" section appear as a PDF bookmark. I have found this question, and the following generally works: \makeatletter \usepackage{etoolbox} \pretocmd{\tableofcontents}{% ...
3
votes
1answer
41 views

Problem with listings package for Python syntax coloring

I am implementing the method I learned here for putting Python code in Latex. Everything works great except that I have problems with comments. Here's the code from the link I mentioned: ...
2
votes
2answers
33 views

Latex create a second keywordstyle using listing doesn't work

I need to insert some code in my latex document, using listings. I create my own set, for a java language \lstset{ language=Java, aboveskip=3mm, belowskip=3mm, showstringspaces=false, ...
6
votes
1answer
63 views

listings line numbers work with one lstlisting but not another

The first listing has its line numbers ignoring the stepnumber while the second is just fine. Guess it might have to do with using math mode but mathescape applies to both, so if that is the case it ...
3
votes
1answer
55 views

Problems with XML Syntax Highlighting

I want to highlight syntax in XML files. I found a nice definition from krlmlr which I changed to my needs. It works fine for Android's xml files: But the result of a xml file with values in ...
8
votes
1answer
260 views

How can I automatically highlight SuperCollider symbols and environment variables?

This question led to a new package: sclang-prettifier I've been poring over the listings manual, trying to figure out how to get some very specific types of formatting for the SuperCollider ...
2
votes
1answer
32 views

Overlaying a tabular on a lstlisting in a book

I am relatively new to LaTeX and am trying to move a tabular up by about 2cm to overlay a lstlisting. The \hspace command works as expected; the \vspace command however moves the text following the ...
3
votes
1answer
29 views

Change font size of lstlistoflistings heading

How can I change font size of lstlistoflistings heading? Currently it is smaller than normal chapter heading title. Any ideas? Unfortunately I need to use document class from my university, my MWE: ...
0
votes
1answer
66 views

Proper way to indicate code change in lstlisting

[Since the question was not clear] I have a piece of program code I would like to describe in my thesis. My problem is that the part I would like to explain is surrounded by simple code pieces not ...
1
vote
0answers
41 views

Using listings to display regexes [closed]

Is there any way to use the listings package (which I already use for Python) to highlight regexes? I.e. the regex appears in the document as if it were source code, but with some form of ...
4
votes
1answer
81 views

lstlistings does not work in a slide

I am writing a slide. I want to use lstlisting \documentclass[10pt]{beamer} \usepackage[utf8]{inputenc} \usepackage[english]{babel} \usepackage[T1]{fontenc} \usepackage{lmodern} ...
1
vote
1answer
70 views

How can I highlight keywords with special characters or numbers in them?

In the following MWE the declared keywords te-st and 999 are not highlighted as expected: \documentclass{scrartcl} \usepackage{listings,xcolor} ...
4
votes
1answer
71 views

Listings with keywords that contain both letters and numbers

I have a listing which needs to highlight keywords with both letters and numbers. Following the advice in this question I've used the otherkeywords to define the keywords which contain numbers. This ...
3
votes
1answer
421 views

Problem highlighting listings in beamer

I'm using listings inside beamer to typeset some Octave code. Because I want to apply overlay specifications to parts of the listing as I go through the slides (for highlighting purposes), I'm ...
2
votes
1answer
37 views

listings 'escapeinside'-option is not working for me

this is my first question here. I'm not exaclty new to LaTeX, but to be honest I've never really gotten too much into it. So here's my problem: I have this minimal example: \documentclass{scrreprt} ...
1
vote
0answers
39 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 ...
2
votes
2answers
81 views

Counters for Chapter and Section environments when using tcolorbox for listings

This is a followup question of this question. With my MWE I'm getting wrong Listing numbers, wrong toc (including Chapter and Section environments from listings) and wrong bookmarks in pdf toc. Any ...
0
votes
0answers
26 views

Using listing to include only some lines of a file [duplicate]

How can I use listings in order to include some lines from a file keeping the numeration right, that is, if I include lines 1-3,8,11-14 they should keep that numeration rather than 1,2,3... Is this ...
2
votes
1answer
84 views

Reading code from external file in tcolorbox and getting pdflatex> ! paragraph ended before \tcb@set@label was complete

I want to read code from external file in tcolorbox in new defined \texexptitled environment but could not succeeded (See MWE). Without this my MWE also throws two other errors pdflatex> ! ...
7
votes
2answers
172 views

Using listings with output

I wonder how to get the output of listings with code. Here is my MWE with output. Now I want to output of this listings too. Any help will be highly appreciated. Thanks Code ...
3
votes
1answer
84 views

listings using tcolorbox for beamer documentclass

I'm trying to get listings using tcolorbox for beamer documentclass. My MWE is given below but could not get it working. Any help will be highly appreciated. Thanks MWE \documentclass{article} ...
4
votes
1answer
70 views

listings using tcolorbox package without Chapter and Section environment effects

I want to get listings using tcolorbox package but without counting Chapter and Section environments. See in MWE, I used section environment withing listings which effects the counter for following ...