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

Beamer and listings… how to include \end{frame} multiple times

Following up on THIS QUESTION, I want to include code in my slides. The code includes "\end{frame}", so I had to box the code as suggested in the link, but if I want to include code including ...
2
votes
1answer
42 views

Defining a synonym for an environment name

I'm currently writing some assignments where I need to embed code fragments. I already found the listings package for that, which works fine. My "problem" is, that I want to ...
1
vote
0answers
27 views

Lstlisting caption: Number style [closed]

When adding a listing to my document, the caption style differs from figures or tables. E.g.: \begin{lstlisting}[language=C,captionpos=b,caption=This is foo,label=src:foo] ... \end{lstlisting} ...
2
votes
1answer
70 views

Why package listings does not work with Beamer? [duplicate]

I want to show LaTeX code inside a Beamer presentation. If I try the following MWE as an article, it works flawlessly: \documentclass{article} \usepackage{xcolor} \usepackage{listings} \lstset { ...
0
votes
0answers
489 views

How to replace (unicode) characters by ü,ğ,ş etc.?

\documentclass[11pt,a4paper]{article} \usepackage[utf8x]{inputenc} \usepackage{ucs} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{graphicx} \usepackage[T1]{fontenc} ...
2
votes
0answers
50 views

Python console code with minted

I am using minted to highlight source code in my document. I have defined \definecolor{codeyellow}{RGB}{255,251,204} \newminted{python}{linenos,breaklines,frame=lines,bgcolor=codeyellow} in the ...
1
vote
1answer
61 views

Using \lstinputlisting to include portion of file using labels instead of line numbers

I know I can include a portion of a code file like so: \lstinputlisting[language=XML, firstline=37, lastline=45]{source_filename.xml} But the line numbers will change if I modify the code file. Is ...
1
vote
0answers
30 views

Custom lstlisting highlighting for symbols

I using the Listings package to pretty print CUDA source code listings. CUDA is a dialect of C++, so I define my style as follows: \documentclass{article} \usepackage{listings} ...
6
votes
1answer
180 views

Preventing line break at the start of a long name in `\lstinline`

This question has developed from How to deal with very long lstinline-phrases like long class names?. That question is about line breaking inside a \lstinline phrase. I have provided an answer which ...
2
votes
1answer
70 views

Is there a way to extract some text from a .txt file (which is not a database) and displaying it in LaTeX?

Allow me to be more specific: I have quite a quantity of folder, each of them containing a .txt file. I would like to extract some text from the header of that file to put it in a LaTeX presentation ...
0
votes
0answers
49 views

Block comment using Latex's listings package to show Python code

I want to put a piece of Python code in Latex, using the listings package. In principle this works fine, except that it does not seem to recognize block comments, but these are shown as normal code. ...
6
votes
1answer
79 views

Problem in using \lstinline as description item

I'm writing a user manual with the documentation of some code written in XML. I would like to do this documentation within two nested description environment, highlighting the labels with my XML ...
3
votes
1answer
114 views

How to insert sourcecode?

For my internship, I have to print all the source of my iOS application to a LaTeX file. Now I'd like to do this in a structured way by having sections, subsections and subsubsections for each nested ...
2
votes
1answer
57 views

How to create boxed, captioned listing?

For a quick reference guide in which I want to include many small listings, each with a caption, How do I group them together, and prevent the code from being broken up? I'm sure there is some ...
40
votes
4answers
2k views

Has the time come for a LaTeX3 successor to 'listings'?

I'm currently looking for a nice and challenging open-source project to work/collaborate on after my thesis. I don't have a Comp. Sci. background, but I'd like to learn more about compiler ...
1
vote
1answer
31 views

how to include listings using \lstinputlisting

In a document embedding java code (actually processing) I can successfully embed listings using: \begin[language=java]{lstlisting} ... \end{lstlisting} In an attempt to increase convenience, I ...
3
votes
1answer
55 views

IEEE Latex Listing

Here is a minimal version of my code: \documentclass[10pt, conference, compsocconf]{IEEEtran} \usepackage{listings} \lstset{frame=single,language=C} \begin{document} ...
2
votes
1answer
84 views

matlab-prettifier only shows up black text

This is my preamble for my book documentclass: \documentclass[11pt,fleqn]{book} % Default font size and left-justified equations ...
2
votes
1answer
38 views

Problem with gobble listing option inside a tcblisting

Please, compare next two listings inside a beamer frame. The upper one is made with listings and the second with tcblisting (form tcolorbox). Both use same source and listing options. Following ...
1
vote
2answers
51 views

Problem with tcblisting: First listed LaTeX command is missing

Following code shows the problem. I've declared a \newtcblisting with an optional argument. \newtcblisting{codiltxb}[1][]{listing only, #1} When the optional argument is present in further ...
5
votes
3answers
172 views

Adding space after listings example

I'm using the showexpl package for creating codes with the displayed result. For the example settings I used pos=b, placing the output below the code, which is what I want. The problem is that now I ...
0
votes
1answer
70 views

Getting a frame with listings in beamer

According to my experiments the listings package no longer allows \begin{frame}[fragile] \begin{lstlisting} %CODE HERE \end{lstlisting} \end{frame} you can use ...
36
votes
5answers
31k views

XML syntax highlighting

I use the following code to include some XML code: \lstset{language=XML} \begin{lstlisting} <?xml version="1.0" encoding="utf-8"?> <xs:schema attributeFormDefault="unqualified" ...
0
votes
0answers
42 views

Listings package couldn't load Mathematica

I have the following code sample, \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{listings,xcolor} \lstset{language=Mathematica} \lstset{basicstyle={\sffamily\footnotesize}, ...
6
votes
2answers
4k views

Is there a good definition for highlighting PHP code in listings?

Does someone have a good definition for highlighting PHP code with the listings package?
0
votes
0answers
24 views

Stopping an lstlisting from breaking on a literate replacement

The default behaviour of the listings package is not to automatically break lines. However, I find that listings will still break lines after a literate replacement. An MWE: \documentclass{article} ...
4
votes
3answers
2k views

Why doesn't \newline work inside lstlisting?

I am new to LaTeX and am using a template provided by a friend: \subsection{P2P library} The library is implemented in C-Sharp and provides two basic facilities - maintaining a member list at every ...
4
votes
2answers
101 views

displaying ?? instead of the name of the lstlisting when using \cref

I change the name of the label of the lstlisting to Algorithm and it works fine for the caption. But when I use \cref, the instead of displaying algorithms 1 it shows ?? 1. \documentclass{scrreprt} ...
2
votes
2answers
53 views

Change `lstlistoflistings` numbering

I'm using the listings package to format program code in LaTeX and the list of listings at the end is numbered like this: 3.1 Code A 3.2 Code B 3.3 Code C 4.1 Code D 4.2 Code E It starts the ...
7
votes
1answer
7k views

Trying to include R Code with listings package

I was trying to include some R Code in a simple LaTeX document, but for some reason I could not do it. I put the R Code in the same directory (I also tried putting the full directory for my R Code) of ...
4
votes
0answers
43 views

Delimit comment on special character

I have defined a new language in Latex (Clojure) but I'm having some issues with delimiting keywords. A keyword in Clojure is any alphanumeric string starting with a colon. E.g., :foo-bar-baz. So far ...
0
votes
0answers
44 views

Listings not showing in \lstlistoflistings

My document looks like this when at the listings page (i dont get any errors, its just empty): My document is like this: \documentclass[a4paper,12pt]{book} \usepackage{apacite} \usepackage{natbib} ...
2
votes
1answer
51 views

How can I show listings even when the class option 'draft' is set?

The question Is it possible to configure the listings package to show the content in the lstlisting environment even if the global option draft is set? Context When working on a larger document, ...
1
vote
1answer
51 views

how to embed arbitrary code

I am using the listings package which does great things for C++, Java. but what about for a makefile, which isn't one of the supported languages? I just want the equivalent of listings, nothing ...
24
votes
2answers
8k views

How to center a listing?

I'm trying to get some console output in my homework. I put it in a listings environment but I want it to be centered horizontally on the page. The only thing I get centered is the caption ;-/ ...
0
votes
0answers
28 views

Force figure to be a listing

To center my listings on the page I followed a tutorial on tex.se.com and that resulted in the following code: {\renewcommand{\figurename}{Listing} \begin{figure}[H] % the figure provides the caption ...
5
votes
2answers
206 views

Adding Keywords to Existing Language for Listings Package

I would like to add more keywords to an existing language definition so that when I use \begin{lstlisting} ... \end{lstlisting}, the new keywords are highlighted along with the predefined ones. This ...
3
votes
0answers
36 views

minted or listings input a file between markers

Is it possible, using the minted or listings package to format a file between or till a certain textual marker automatically. E.g. consider a source file: code code //marker code ... //end marker ...
2
votes
1answer
58 views

Strategy for listings next to code comments

I'm looking for strategies to produce listings of code with comments on what's happening next to it. I've found other similar questions, but not quite what I'm looking for. See for example: Listing ...
1
vote
0answers
109 views

How can I typeset PowerShell code with the listings package?

I'm currently creating my diploma thesis, and used PowerShell to do some of the described work. I'd like to also put some of this code into the thesis and would therefore like to have syntax ...
2
votes
1answer
47 views

Listings “cannot load requested language” after newly-defined dialect

[Note that this is not a duplicate of ajeh's question] I have defined a new XSLT2 dialect of XML for the listings package which includes some extra keywords beyond XSLT, but I can't get it to ...
1
vote
0answers
65 views

Add caption and list of listings to own listings environment

With listings and caption packages I can set up caption for lstlisting with \captionsetup[lstlisting]{...} create list of lstlistings \lstlistoflistings I can also define my own environment ...
21
votes
1answer
299 views

How can I color parentheses depending on the nesting level (like emacs' rainbow-delimiters)?

Is it possible to have a custom setup for lstlistings for LISP-like languages and have matching parentheses coloured with a same colour taken from a palette? What I am looking for is something like ...
0
votes
0answers
32 views

Latex list of listings wrong formatting [closed]

I have a problem with my list of listings in Latex. I have changed the title of list of listings with this command: \renewcommand{\lstlistlistingname}{Seznam zdrojových kódů} For printing list of ...
1
vote
1answer
70 views

Define starting line number when using mcode.sty to display Matlab code and referring to the code

I want to include parts of my Matlab code in my LaTeX document using mcode.sty. Here's a MWE: \documentclass[b5paper, 10pt, twoside, openright, dvipsnames,cmyk]{report} \usepackage{listings} % Is ...
3
votes
1answer
105 views

Overfull \hbox in C++ code (listing-package)

I currently have a problem with writing C++ in latex. I have a very long string of text inside my code, that interferes with the space. So how do I fix this?? The code: ...
1
vote
1answer
49 views

XML code in a Box

Here is a minimal version of my code: \documentclass[12pt,a4paper]{book} \usepackage{listings} \lstset{ basicstyle=\ttfamily, columns=fullflexible, showstringspaces=false, ...
2
votes
0answers
22 views

Indentation marker for listings

I'm currently writing a document that contains several code samples. I included them as lstlistings and played around with the colors and everything, so they loot quite nice now. My only problem is ...
2
votes
1answer
679 views

Minted: customise listing name? [duplicate]

How do I customize listing name: Listing 1: thing -- when I use minted? Here's an MWE: \documentclass{article} \usepackage{minted} % \renewcommand{\lstlistingname}{Something} % doesn't work! ...
1
vote
0answers
51 views

lstlisting package indents code too much [closed]

I cannot figure out why this happens. I have been trying to figure it out for some hour now but I can't seem to find what is causing it. The lstlisting code snippet indents like crazy, which causes ...