{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
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
48 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 ...
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. ...
3
votes
1answer
77 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
45 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
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} ...
2
votes
1answer
59 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
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
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 ...
1
vote
1answer
61 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
37 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 ...
2
votes
1answer
37 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
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 ...
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 ...
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 ...
0
votes
1answer
49 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 ...
3
votes
0answers
55 views

How to let minted break across pages but keep the caption together with the end of listing?

I want to create a listing using minted that has background colour and can be split across pages. The usual advice in that case is to use the mdframed environment and I have written a command that ...
2
votes
2answers
44 views

polish characters ą

I cannot get to work my special chars in listings, my texmaker is configurated to use utf8 in options, but I get error: ! Package inputenc Error: Unicode char \u8:�\lst@FillFixed@ not set up for ...
0
votes
0answers
65 views

inline listings line wrapping issues

I am having issues with inline listings line wrapping. As you can see in the linked image, the period ending the sentence is on the next line due to wrapping of the cite-website text. The listings ...
2
votes
1answer
34 views

listings \def problem

When I complile the following code with xelatex, %\end{lstlisting} is a necessary line to prevent error. What is the problem? \documentclass[a4paper,11pt, onecolumn, openany,]{memoir} ...
5
votes
2answers
98 views

Document doesn't show the list of figures (LaTeX)

I have the problem that LaTeX doesn't show the List of figures and List of Listings. I don't know where the problem is. I'm working with TeXstudio and the code was defined as follows: ...
2
votes
1answer
72 views

Problem defining a new lstlisting environment

I'm relatively new to Latex and having a bad time using listings inside a beamer presentation. I know I have to use a [fragile] frame to get verbatim environment inside a frame, but for some reasons ...
4
votes
1answer
119 views

How can I display julia output in latex?

I've been able to typeset julia code using listings package as mentioned in the answer here. But I also wanted to display Julia output in my latex document, how can I achieve this ?
2
votes
0answers
58 views

Including C++ in AMS Book template

I've had a hard time incorporating my C++ code into a document which was formatted using the AMS book template. %----------------------------------------------------------------------- % Beginning of ...
1
vote
0answers
41 views

xparse verbatim argument removing multiple space

I am trying to define a command, using xparse that take as input some verbatim code and cite it using listing. However, the eventual multiple white spaces or tabulations at the beginning of a lines ...
4
votes
2answers
36 views

Space around escaped equations in listings?

I am using listings with mathescape=true to include some typeset output. However, I would like a little white space around that output. Currently I have \lstset{language=, keepspaces=true, ...
1
vote
0answers
77 views

Latex highlighting error for lstinline

it has been quite a while that I have this problem and I have searched everywhere online and couldn't find a solution. The problem is latex syntax highlighting doesn't work after this line: ...
3
votes
0answers
127 views

Syntax Issues with lstdefinelanguage

I have some issues defining a new language for the lstlisting package. The source code shall look like this in the end: And my latex definition looks like this atm: \documentclass[]{article} ...
3
votes
1answer
24 views

LaTeX listings Package Only gives Unbreaking Spaces when in tex4ht

I am trying to make a programming e-book, but the listings package is converting all of the spaces in the listings to non-breaking spaces. I have tried breakatwhitespace as both true and false, as ...
3
votes
1answer
46 views

New environment for Python source code

I am trying hard to create an environment for my source code. Here's my current state \documentclass[a4paper,fontsize=12pt]{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} ...
1
vote
0answers
21 views

conflict using matlab-prettifier and LaTeX beamer [duplicate]

I was trying to use the matlab-prettifier package with the LaTeX beamer package, and I noticed I was getting errors when trying to compile. Mainly I was getting an error when trying to use ...
3
votes
3answers
302 views

ASCII + Unicode art in LaTeX lstlisting

I have a small ASCII diagram in my LaTeX document. \lstset{literate={↓}{$\downarrow{}$}{1}} \begin{lstlisting} -1---2----3-----| ---s---------s--| ↓ ↓ ---1*--------3***| \end{lstlisting} ...
1
vote
0answers
16 views

Get source code as it is from output [duplicate]

I am trying to display my XQuery code in a latex document as follows: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{listings} \title{code} \date{January 2016} \begin{document} ...
1
vote
0answers
62 views

How can I define a new language? [closed]

i need to insert code into my document which is written in ST (structured text) (PLL language). Couldn't find any existing solution in the web. How to add the language to the package to use it? ...
0
votes
0answers
53 views

Place the content in a block with shadow frame

I am using latex beamer and trying to put the content of the listing in a block with white background and just with a shadow of the frame as the one of google (madrid weather). I tried with ...
2
votes
1answer
81 views

shrink the size of the font size in the listing

I am using the latex beamer and trying to reduce the font size of the listing to display the whole JSON code without reducing the font size of the sentence before. How can I get it to work? Code: ...
1
vote
2answers
102 views

listingsutf8's option inputencoding=utf8/latin1 leads to latin1.def to be read each time a listing is used

Edit: inputencoding=latin1 option initially written should have been inputencoding=utf8/latin1 If the listingsutf8's option inputencoding=utf8/latin1 leads to latin1.def file to be read each time a ...
5
votes
1answer
61 views

make all values of the JSON format red

I am using the latex beamer and trying to get the true value of the flag key in the JSON format red too but I am just getting it black as shown in the screen shot below. How can I get it red too? ...
0
votes
0answers
16 views

After using listings my country symbols moved to words front

So I used listings package to put my JSON script to a LaTeX file. Which looks like: \begin {1stlisting} { "wow": 30, išėjimas "nice": 1 kažkas }, ...