{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
20 views

listings breaking line despite breaklines=false

For some reason the listings package is breaking lines in the minimal working example below despite the fact that the breaklines=false option is set. \documentclass{article} \usepackage{listings} ...
0
votes
1answer
15 views

Excessive space in lstinline after using Reactivatenumber

I'm using the code presented by this answer (which itself is based on this) to suppress line numbers on some lines in lstlisting. This works, but after I use it, the spacing in lstinline is messed up: ...
10
votes
1answer
1k views

Is there an equivalent to \graphicspath for listings?

How can I make the \lstinputlisting to search for files in a given directory? I'm thinking of a solution along the lines of the solution to this question. I would like to have a solution like ...
3
votes
1answer
60 views

Listings & unicode characters

I want to write some unicode characters to lstlisting environment but they are displayed inline in the output which isn't what I am expecting. How can I make it work like standard characters? Thanks. ...
2
votes
1answer
51 views

listing background color not exactly the same

I like SO code section colors. so I wish to use it as code listings box background color. I use a screen capture tool to capture the code background color to png, then use GIMP tool to check the RGB ...
15
votes
1answer
1k views

Source Code Margin Comments

In the paper "Beautiful Code Compelling Evidence", by J.R. Heard -- Code is formated in a particular way which includes margin comments. I am looking for a way to do this as I think it is a very clear ...
0
votes
1answer
104 views

Any new packages for code listings

There are many questions (and answers) on this site about packages for showing listings of source code. But all the answers I have found are at least five years old, and I was wondering if any newer ...
2
votes
1answer
36 views

Using lstlisting with T2A

I would like to display a code listing using the package listings. It all work nice, except if I had the fontenc T2A. When I do, the listing stop being displayed using \ttfamily font and is shown ...
2
votes
2answers
130 views

Unwanted space around punctuation in copied & pasted listing

When I compile the .tex file below into .pdf using rubber -d mwe.tex and try to copy & paste the contents of the listing, I get spaces around . characters that were not present in the original ...
3
votes
1answer
3k views

“Wrong” numbers while referencing lstlistings in text

I'm using the lstlisting package to put sourcecode in my pdf file: \documentclass{scrbook} \usepackage{listings} \lstset{ % language=xml, basicstyle=\footnotesize, % the size of the fonts that ...
1
vote
0answers
47 views

XeLaTeX - special unicode characters

I found that work with unicode characters is a lot easier using xelatex than pdflatex, therefore I'd like to use it. Most of the content is displayed correctly but I have a problem with some special ...
2
votes
0answers
47 views

How to prevent parts of source from being automatically indented? [closed]

EDIT Rephrased question to be more abstract and less specific to only fragile-frames. Context: While recompiling a presentation, the process halted with err-msg file ended while scanning use of ...
7
votes
1answer
49 views

bold just one line inside of lstlisting

How can i bold just one line in this code? \begin{lstlisting} //Algoritmo 2 int f2 ( n ): local i , j , r =0; para i = 1 a n -1 para j = i +1 a n r = r + 2; ...
0
votes
0answers
25 views

Listings package does not break with my own class

I have created a class based on the article class so: \NeedsTeXFormat{LaTeX2e} \LoadClass{article} \RequirePackage{../../mypackage.sty} According to that, I have done following example document: ...
12
votes
2answers
616 views

How to use showexpl with an external class?

The showexpl package defines LTXexample environment which allows to define a latex code and shows its result side by side. The problem is that it uses the same document class where the LaTeX code is ...
5
votes
2answers
4k views

Missing \endgroup inserted error in a table

I am getting Missing \endgroup inserted morekeywords={class,run}] on line 16 while compiling the tex. I am using TexStudio. How can I solve that problem? \documentclass{article} ...
34
votes
2answers
24k views

How to highlight Python syntax in LaTeX Listings \lstinputlistings command

I am using package listings to import my Python source code into my LaTeX document. I use the command \lstinputlistings. I have a Python source like class MyClass(Yourclass): def __init__(self, ...
2
votes
0answers
29 views

Spaceing Issue with listings

I am having a bit of trouble putting python code into a latex document using listings. The code is appearing with a large indent on the left so that it has to go onto multiple lines. Here is an ...
5
votes
3answers
73 views

Conditional list of listings - lstlistoflistings only if listings are present

As shown in this thread and this thread it is possible to conditionally create lists of figures and tables only if these items are used in a document. I would like to extends this to listings. ...
2
votes
2answers
37 views

How to set thickness of rounded frame in listings?

I'm using listings package for source code listings in my master's thesis. How to set frame thickness for lstlisting environement when frameround is set to tttt? When frameround is other than nnnn, ...
3
votes
1answer
40 views

listing title under itemize exceeds page width

I want to put listings under enumerate environment. For the lstlisting title's background color i took from this post. However, after putting the lstlisting under item, the title with colored box ...
2
votes
0answers
41 views

`\itshape` is to `\textit` as ?? is to `\mathit`?

In the following example, I've set listing's basic style to \itshape. However, the + operator is italicized, and so are the parentheses: \documentclass{article} \usepackage[english]{babel} ...
2
votes
1answer
19 views

(Even doubled) Backslash in listings allowed within footnotes but not within fixed footnotes

As shown by the following example, a (doubled) backslash in a listing is allowed within footnotes but not within fixed footnotes: \documentclass{article} \usepackage{fixfoot} \usepackage{listings} ...
0
votes
1answer
51 views

Using \lstinline inside a new command or environment

I use the listings package to render code in LaTeX documents. I am trying to define a new command or a new environment that uses \lstinline inside. I have read numerous questions about this on ...
3
votes
1answer
38 views

Elaborate C++ parsing and the listings package

I would like to have the colors the gruvbox coloring scheme for (g)vim uses in a lstlisting environment. Is the listings package too dumb to differentiate e.g. between "template", "const" and other ...
3
votes
0answers
47 views

How can I highlight certain words in minted with different colors?

I would like to highlight some specific words inside the minted environment when using beamer. \documentclass[14pt]{beamer} \usepackage{minted} \begin{document} \begin{frame}[fragile]{} ...
0
votes
0answers
10 views

How to fix multiple literates in lstlistings?

Similar (same) questions: How can I define additional literate replacements without deleting existing ones? Multiple literates in a listings style definition Situation I have defined my own ...
11
votes
2answers
1k views

Listings line numbers that match the linerange specification

This is a follow-up question to First line number in lstinputlisting environment. Consider the MWE: \documentclass{article} %\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox ...
3
votes
1answer
75 views

Listing with monospaced font (Dejavu Sans Mono) and background color

I will setup my document to the Sans Serif Font Helvet and additionally all source codes should display with Dejavu Sans Mono and grey background color (on \lstinline{} too). How can I setup listings ...
0
votes
1answer
20 views

Underfull\hbox (badness10000) in paragraph at lines 31--43

a.) Probetas de acr\'ilico transparente, con escala de alturas graduada y con tap\'on de hule.\\ b.) Tubo irrigador de acero inoxidable, provisto de un tramo de manguera de hule y con un sif\'on.\\ ...
1
vote
1answer
43 views

Can't apply monospaced font to listings (when using pdflatex)

I'm a newbie to LaTeX and I can't find the cause of a problem described below. I need to insert several C++ code snippets into my document, so I use the listings package for this purpose. The ...
3
votes
1answer
98 views

Allow break anywhere with no hyphenation in a listings in-line command

Here, I use the function \txtbrut to write in typewritter font certains things such as file names or functions in python, matlab, etc. I use listings for the colouring of the code and because it does ...
3
votes
1answer
32 views

Is it possible to have two separate listings?

I have defined two listings environments, one for Python and other for Bash, both have different settings, this is a minimal example of what i'm using: \documentclass[a4paper,12pt]{article} ...
0
votes
0answers
17 views

Listings not displaying punctuation [duplicate]

I'm having some issues with the listings package. If I try to display some C++ code the punctuation won't display properly. For example: \begin{lstlisting}[language=C++] template <int dim> ...
0
votes
1answer
33 views

lstinline - source code

I want to use \lstinline for displaying inline source code in text. This code can contain various characters from different programming languages. For example while{$a || $b} This text doesn't work ...
3
votes
1answer
52 views

force at least two lines on a page in using lstlisting

I use the lstlisting package a lot in my theses. Unfortunately, it sometimes renders the caption (at bottom of the listing) on the next page or starts the listing at the end of a page, renders no line ...
1
vote
1answer
58 views

error using lstlisting inside minipage inside align*

I am trying to use a lstlisting environment inside a minipage, inside an align* (fromo amsmath)... However, lualatex throws an error. This is the minimum working examp \documentclass{article} ...
2
votes
3answers
36 views

strange interaction (bug ?) between mdframed and listings

I have a weird behaviour when I try to include some lstlistings inside a mdframed box. Most of the time, it works as expected, but under some conditions, I get incorrect output, or even a latex error ...
1
vote
2answers
46 views

2 column layout with python code inside- overlapping problem

I am using following latex code to write my appendix to which I need to add python code. \section{Appendix} \begin{landscape} \begin{multicols}{2} \subsection{Source Code} ...
1
vote
0answers
28 views

How can I set multiple languages in listings?

Can anyone tell me how to properly set multiple languages in listings package? In my document I have some source code of C-sharp, VBA and JavaScript and need to color the keywords. But in my case I've ...
1
vote
0answers
35 views

How to start a new line in latex in the listings environment?

How do I start a new line in the LaTeX listings environment? When I type the usual commands to start a new line (\\ or \hfill) it reads it as code instead of a command?
0
votes
0answers
34 views

How to let listings “pop up” in Beamer frames?

I'm making a lot of use of beamers "pop-up" [<+->] functionality. And I'd like to make also lstlisting envrionments pop-up. How can I do so? Displaying listings works fine (thanks to ...
0
votes
0answers
20 views

How to add a rule/command to not color text in <> in tcblisting?

I have the following listing with some code inside: \documentclass{article} \usepackage[T1]{fontenc} \usepackage{beramono} \usepackage{xcolor-solarized} \usepackage[many,listings]{tcolorbox} ...
0
votes
0answers
8 views

Preferred way to make a shortcut command for \lstinline [duplicate]

I want to be able to use \lstinline[style=specialinlinestyle]|...| as \sisinl|...|. When I use \newcommand as in \newcommand{\sisinl}[1]{\lstinline[style=specialinlinestyle]|#1|} \sisinl|...| won't ...
5
votes
2answers
3k views

Continue line numbers in listings package?

I have been using the listings package to present my source code in LaTeX. However, I can't get the line numbers to continue between two separate user-defined listings that have been given the same ...
1
vote
0answers
31 views

Line break inside lstinline?

is there a way to define inside lstinline line breaks globally? I only found this solution Listing / lstinline and line breaks where i should use \begin{sloppypar} ... your paragraph with ...
5
votes
2answers
8k views

How do I prevent LaTeX from showing a whitespace following a quote when in an lstlistings environment? [closed]

When I am inside the lstlistings environment, it seems that using a quote such as (') or (") will toggle on the showing of whitespace indicators (small little half rectangles). Am I doing something ...
5
votes
1answer
228 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 ...
3
votes
2answers
136 views

Verbatim vs Listings for Thai Font

I have a problem about verbatim and listings. I need write some codes by using Thai font but it shows in picture \documentclass[12pt,a4paper,oneside]{book} \usepackage{verbatim} \usepackage{listings} ...
0
votes
1answer
47 views

Listings internationalization (spanish): List of listings and caption labels not translated

I'm trying to make a latex document in spanish, I've successfully imported the babel package for the language, but the \listoflistings command does not get translated to spanish. Also captions for ...