{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

7
votes
1answer
84 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
51 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
56 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
58 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
45 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} \end{minipage}\...
2
votes
1answer
72 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
63 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
45 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
64 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]{} \begin{...
0
votes
0answers
13 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
106 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
93 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.\\ c....
1
vote
1answer
54 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
40 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
64 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
41 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
108 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
73 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
46 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
75 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} \definecolor{keywords}{RGB}{...
1
vote
0answers
34 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
36 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 [fragile]),...
2
votes
1answer
50 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
107 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
25 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 \lstinline.....
0
votes
1answer
70 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 ...
4
votes
0answers
78 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
52 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
70 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
43 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} \usepackage[...
5
votes
2answers
142 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: \usepackage{...
2
votes
1answer
83 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
151 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
67 views

Including C++ in AMS Book template [closed]

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
48 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
39 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
102 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
294 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
25 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
51 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} \usepackage{...
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 matlab-...
3
votes
3answers
339 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} ...