{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
2answers
56 views

Latex listings - breaklines divides parenthesis, wrong space near parenthesis

When using listings package, there is a wrong spacing after parenthesis and, when a line breaks, the parenthesis are very often divided from what comes before. What can I do to change that? The ...
1
vote
0answers
31 views

Inserting code using listings, goes off page [duplicate]

When I use \begin{lstlistings}, the code is too long and goes off the page, will I have to go through every line and fit it onto the page ? The code is incredibly long and this will take a very long ...
1
vote
0answers
49 views

I have unwanted “stripes” using lstlisting

(First of all I apology for my bad english, french guy here) I am using LaTeX for my university and I have a bug using the package lstlisging, those grey stripes : Here's my LateX code : ...
0
votes
0answers
107 views

Line numbers in listings (lstlisting) based on actual appearence in PDF file

I'm using the listings package to insert source code into my TeX files. I also set the option \lstset{numbers = left} in order to have the line numbers next to my source code and be able to refer to ...
2
votes
0answers
38 views

Listings - Including only part of an external file between certain points [duplicate]

I've just started using LaTeX and am using the Listings package to include external source code. I would like though to only include certain parts of the source code. I know that certain parts of the ...
3
votes
1answer
228 views

Listings style for INI (conf) files

I'm trying to create a simple style for Windows INI files using the listings package I'd like this results: purple [sections] tags red assignment operators (= and :) gray comment lines starting ...
0
votes
0answers
28 views

Color “(,),:,;,=,+” in lstlisting [duplicate]

how do I color these characters ():;=+ in lstlisting? I've tried to use literate={(}{\textcolor{yellow}{(}}1 but it doesn't work. Greetings!
1
vote
1answer
84 views

Ignore indent of itemize for figures, lstlistings etc

I have a list of items where some of the items contain figures, listings, etc. How can I make these environments ignore the additional indent in an itemize environment? My code looks like this: ...
2
votes
1answer
50 views

Frame a line in an environnement lstlisting

I defined an environnment \lstset{...} to put some code in a beamer presentation. I would like to frame a specific line in my code, this way: How can I do that? Have I to use tikz package in ...
1
vote
0answers
32 views

Issue with lstdefinestyle{XML} and margins [duplicate]

i am having troubles inserting XML code in Latex because the code lines appear out of the margins. First at all, i have defined the style, by the following way: \documentclass[a4paper,11pt]{book} ...
1
vote
0answers
25 views

What can I use to typeset a part of MATLAB code (m file) in my document? [duplicate]

I have a .m file and call .m file with ‎\lstinputlisting{****.m}. but I want LaTeX to show lines 13 to 25. How is it possible?
4
votes
2answers
73 views

How can I avoid the use of default styles when no listings language is set?

When global listings styles have been defined identifiers are coloured differently from numbers even if no language is in effect. How can this be avoided? \documentclass{minimal} ...
2
votes
2answers
53 views

How to split 3 spaces ligature in lstlisting

Code: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage[english]{babel} \usepackage{listings} \begin{document} \begin{lstlisting}[language=PHP,breaklines] $a === $b; \end{lstlisting} ...
3
votes
1answer
76 views

How to use onslide in a listing?

I need to animate single contiguous code listings by showing and hiding parts of code using \onslide. However, TeX is complaining. How can I achieve this? I tried the advice here but it didn't work. ...
5
votes
1answer
222 views

Skipping line numbers in lstlisting

Referring to Skip line numbers and resume from specific number I tried to skip several line numbers in my listings and continue with a specific number. But in my case there is a really bad side ...
0
votes
1answer
134 views

Using setmonofont with Bera Sans Mono in Beamer produces garbled output

I am using Bera Sans Mono as the monospaced font for typesetting code listings using the listings package. This is done for slides which are produced using beamer and XeLaTeX. My preamble includes the ...
5
votes
1answer
184 views

Can't escape curly braces in \lstinline

Upon trying to typeset the following TeX I get the error: Too many }'s. ...handleClick } >Button component} TeX: \lstinline{<Button onClick=\{this.handleClick\}>Button ...
2
votes
2answers
151 views

Highlight asterisk in lstlisting

I would like to emphasise the asterisk used in \begin{equation*} in lstlisting. I have tried using emph, also including the alsoletter macro, but it doesn't work. Why not? \documentclass{article} ...
0
votes
0answers
17 views

How to get Unicode in code listings? [duplicate]

I want to use Unicode text (a mixture of cyrillic and japanese characters) in a code listing that uses default LaTeX fonts (in other words, source code fonts are left to default). However, for all ...
0
votes
0answers
8 views

lstlisting indentation versus editor-formatting [duplicate]

Whenever I use the listings package to typeset code, I encounter the problem that the way lstlistings work collides with the formatting my editor likes (I use vim). For instance, see this code: ...
2
votes
0answers
98 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 ...
3
votes
1answer
96 views

lstlistoflistings is unformatted

I habe a problem to get a list of listings that looks like the normale table of figures or basically like any other list of anything. As I am not a tex or latex pro, i tried several packages and ...
3
votes
1answer
88 views

How to set the label for listings?

Hi I'm new in Latex and I'm using this code from the Board everything is working, but I don't know how to set the label for the listing with this code \usepackage[many,minted]{tcolorbox} ...
1
vote
1answer
73 views

How to lstinput a text file path and get content of ext file into pdf

I tried to insert some data using listings package labels(lstset) into pdf which was successful but if the same data is put into a text file ans lstinput it as follows is not successful .Can some one ...
1
vote
1answer
94 views

Listings and verbatim-like environments in a tikz node using newcommand

I have seen answers to this question floating around but none of them appeared to solve the problem. I want to be able to throw a code block into an already defined tikzpicture. So I attempted to ...
0
votes
1answer
56 views

Font size of inline code-listings too small

I'm using the listings package and am satisfied with how my code listings look. The font in my inline-listings however is too small compared to the rest of the text. How can I only increase the font ...
3
votes
2answers
95 views

Setting lineskip affects the caption in listings

If I specify a lineskip in lstlisting, it affects the caption too. How can I prevent it? Example: \documentclass[a5paper]{article} \usepackage{listings} \begin{document} \begin{lstlisting}[float, ...
4
votes
1answer
338 views

Why is listings' frame width a little larger then \textwidth?

Here is the sample code: \documentclass[]{article} \usepackage{listings} \lstset{ basicstyle=\ttfamily\footnotesize, frame=single, % adds a frame around the code } \begin{document} ...
0
votes
0answers
40 views

removing linebreak listing (e-mail, eml)

I tried to use an eml-file as an listing but because the encoding doesen't really work I had to include some German Umlaute (ä,ö,ü), unfortunately there is still a problem with the line break symbol ...
1
vote
1answer
76 views

Why doesn't listings' breaklines work, here?

see the sample code and the screen shot: \documentclass[UTF8]{article} \usepackage{listings} \usepackage{color} \begin{document} \lstset{ basicstyle=\ttfamily\footnotesize, language=Python, ...
2
votes
1answer
123 views

how to wrap a long terminal command without real line breaking?

this may look like a duplicate question to this one and many, but really I had a hardtime in finding the desired solution. The breaklines=true didn't work as it breaks the long command. Hence simple ...
0
votes
0answers
48 views

Is there a nice way to split an algorithm float over multiple pages? [duplicate]

I am using the algorithm float with an lstlisting in it containing the code. Unfortunately, the code is just a little too long to fit on one page. I'd like to keep the layout provided by the ...
4
votes
1answer
166 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 ...
0
votes
0answers
21 views

Call environment lstlisting without begin-end [duplicate]

I want to create a command for calling the lstlisting environment without the use of \begin{lstlisting}...\end{lstlisting}, i.e. I want to write something like \lst{text in enviromnent}. I have tried ...
1
vote
1answer
37 views

Coloring of @param and @return with Listings

Here is a MWE of what I have, along with a screenshot \documentclass[paper=a4, fontsize=11pt]{scrartcl} \usepackage{color,soul} % For text coloring and highlighting ...
2
votes
1answer
137 views

Filename in line 0 of a lstlisting

I'm trying to write a lstlisting-environment which sets the filename as line 0. I tryed \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{listings} \lstset{numbers=left} % @param 1 : ...
4
votes
2answers
167 views

Emphasizing all occurrences of given word in document

Please forgive my naivety, but I have a fairly large TeX document and I was hoping that there was an easy way to do the following. I can create code blocks in the text using the following: ...
2
votes
1answer
56 views

hyperref to line number in listing imported from file

Can I refer to a line number from the imported file without escaping chars inside the file? Say, I import my file like this \lstinputlisting[language=c]{main.c} and I want to \hyperref{} line 50 ...
6
votes
2answers
102 views

Renewing the \thelstlisting command when hyperref is on

I'm trying to change the appearance of the cross-ref to a listing in the appendix, so that it prints as \textsc{a}.1, not just A.1. The redefinition ...
4
votes
1answer
97 views

How to have free accents in `lstlisting`

There are quiet some questions about getting accents like è into the lstlisting environment. But I actually want to have a free floating accent. However, Latex always changes it to some other symbol ...
3
votes
1answer
104 views

Listing inside table does not work after upgrade to MacTex 2015

I have updated my Latex installation to MacTex 2015 and the following latex code does not compile anymore: \documentclass[10pt]{article} \usepackage{listings} \lstset{language={java}, ...
6
votes
1answer
294 views

Align a floating lstlisting to the very top

The following code does not align the lstlisting entirely to the top, but keeps some unwanted space between the page's top and the listing. How can I align the lstlisting to the very top? ...
2
votes
1answer
205 views

Customizing the list of listings from minted

This question is in regards to customizing the format of the list of listings produced with the minted package. In particular, I want to replicate the formatting produced via the tocloft for Figures: ...
4
votes
1answer
59 views

How to make linenumber referencing in lstlisting work with autoref

This Link provides an answer to the question how to make line-number referencing work with lstlisting. However, if I use \autoref it will only return the number and not something like Line 31.
1
vote
1answer
47 views

Formatting changes

I want some text to appear as below I am not getting the exact output. The code I have written is as follows (Please pardon me for lack of knowledge of Latex) \hspace{2mm} A simple paragraph of ...
1
vote
1answer
80 views

Inline listing in ams environment drops space before mathescape

In http://tex.stackexchange.com/a/127018/83257 there is a patch to make inline listings work in math mode. When using this together with listings' mathescape option, the space after a math escape is ...
0
votes
1answer
77 views

Remove “space symbol” [duplicate]

I'm trying to write: LCD_write_String_to_Buffer("Esperando \nconfiguracion..."); but what I get is: I get like horizontal square brackets. Is there any way to remove all symbols and leave ...
2
votes
1answer
439 views

Formatting R chunks when using knitr

How can I apply the same formatting with R chunks that I apply to regular listings? The following example shows a nicely formatting listing and an (IMHO) awful looking R chunk. I already loaded ...
3
votes
1answer
51 views

How to set optional argument for caption in a lstlisting environment

Usually, if I set a caption, I use \caption[short]{long} to have only a short description in my list of figure for example. But how do I do it with listings? Here a MWE which has a very long caption ...
3
votes
1answer
97 views

Allowing line break at C++ operators ('::', '->', …) in \lstinline

The following picture shows my problem: How can I tell \lstinline to break lines at specific C++ operators? For example: FooFactory::instance()->createFoo() should be broken as follows: ... ...