{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

5
votes
1answer
34 views

Lstlisting duplicate caption

I've been trying to insert the code to my LaTeX document. I used this piece of code: \begin{lstlisting}[label={lst:rws}, captionpos={bottom}, caption={Pseudo-code of RWS Selection}] r = Random(); /* ...
5
votes
1answer
33 views

How to force \lstinline to add a line break

I have an inline piece of code in my main LaTeX document that I have included using the \lstinline command: \lstinline{template<class UIntType, UIntType a, UIntType c, UIntType m> class ...
4
votes
1answer
34 views

Textcase, Listings, and Tilde

Consider the following MWE: \documentclass{scrreprt} \usepackage{textcase} \RequirePackage{listings} \usepackage[american]{babel} \begin{document} \MakeTextLowercase{A~B} \end{document} ...
6
votes
0answers
50 views

Exception from code syntax highlighting in listings

EDIT: The question is not really relevant for me any more, I decided to instead use the highlight package in R to export Code as LaTeX output. This still requires manual modifications, but at least I ...
1
vote
1answer
25 views

change caption of multiple listing styles

I want to have different listing environments, each with an own caption. My try was this (vorlage.tex): \documentclass{scrreprt} \usepackage{regexpatch}% http://ctan.org/pkg/regexpatch ...
3
votes
1answer
53 views

Conflict with unicode-math and listings

\documentclass{article} \usepackage{unicode-math} \usepackage{listings} \usepackage{fancyvrb} \begin{document} \lstset{fancyvrb} \begin{Verbatim}[commandchars=\\\{\}] \pm \end{Verbatim} ...
2
votes
2answers
48 views

Universal numbering for figures and lstlistings [duplicate]

I use ShareLaTeX for my thesis and I am facing a problem. I have used the following code to change figures' name to "Εικόνα" and lstlistings' name to "Εικόνα" too. ...
4
votes
0answers
43 views

Using the same line numbers in lstlisting on repeated beamer slide

In the following example, the line numbers on the second occurrence of the slide start from "3". But the references in the itemize item of the second occurrence of the slide show as "1" and "2" (i.e. ...
2
votes
1answer
114 views

How to prevent page break between listing caption and code?

How to prevent page break between listing caption and code (see the picture)? Minimal example illustrating issue: \documentclass[a4paper, 12pt, oneside]{report} \usepackage[a4paper, left=3.5cm, ...
0
votes
1answer
28 views

custom listof not in content

This is the initial part of my thesis: \documentclass[12pt, a4paper, openright]{report} \usepackage{amsmath,amssymb,amsthm} \usepackage{graphicx} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} ...
0
votes
0answers
29 views

matlab-prettifier with fancyvrb-style of label / frame

I wonder how to make the frame line around caption of listing not being printed (top line being broken into two by caption in the middle) when matlab-prettifier (or listings package) are being used, ...
2
votes
1answer
23 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} ...
3
votes
1answer
61 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 ...
4
votes
1answer
66 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. ...
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: ...
3
votes
1answer
41 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
0answers
54 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
66 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: ...
1
vote
0answers
50 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
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 ...
2
votes
2answers
48 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
46 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 ...
1
vote
1answer
42 views

Give side by side minipages one (shared) caption instead of two

I have two lstlisting areas that are shown side by side by using two minipages: \noindent\begin{minipage}[t]{.43\textwidth} \begin{lstlisting}[...]{part1} // Code \end{lstlisting} ...
2
votes
1answer
70 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
58 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
41 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
57 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
12 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 ...
5
votes
3answers
85 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. ...
3
votes
1answer
84 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
47 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 ...
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> ...
3
votes
1answer
35 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} ...
2
votes
1answer
61 views

listings package: last whitespace removed before the newline character. How to keep it?

I've some sort of template/examples of bash scripts on my computer (.sh files on my hd) in which I put commands and commented outputs. This is my example.sh file: echo this is wide ...
0
votes
1answer
38 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
105 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 ...
1
vote
1answer
67 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
41 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
61 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
31 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
36 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 ...
2
votes
1answer
44 views

Adding a special keyword that is ignored in lstinputlisting

I would like to know how to add a special keyword to be ignored in \lstinputlisting that is used in the listings package. The screen shot shows my problem. I am writing a tutorial document of the ...
0
votes
1answer
105 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 ...
0
votes
0answers
22 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 ...
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 ...