{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

0
votes
0answers
50 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. ...
2
votes
1answer
71 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 ...
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 ...
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 ...
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
56 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
85 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 ...
0
votes
1answer
71 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 ...
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}, ...
5
votes
3answers
174 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
0answers
25 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} ...
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 ...
2
votes
1answer
41 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 ...
4
votes
2answers
102 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} ...
3
votes
1answer
118 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
2answers
55 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 ...
0
votes
1answer
40 views

lstlistings: Regexp quotation mark/apostrophe error

I am attempting to display a long Python Regexp in LaTeX lstlistings. When compiling I get the following error message though. ! Package inputenc Error: Unicode char \u8:�\lst@FillFixed@\lst@EC� not ...
4
votes
0answers
44 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
52 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, ...
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 ...
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
59 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
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 ...
1
vote
0answers
110 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 ...
1
vote
0answers
66 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 ...
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 ...
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 ...
3
votes
1answer
111 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 ...
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 ...
1
vote
1answer
53 views

Python code block outside of margin

I want to include some Python code to my Latex document. I have read this Tex Stackexchange question and added the following code to get syntax highlights: \usepackage{color} ...
4
votes
2answers
42 views

Paragraph indentation after lstlisting environments

I tried to indent first paragraph after a customized lstlisting environment \documentclass{article} \usepackage{listings,lipsum} \lstnewenvironment{mycode}{}{\par} \begin{document} \lipsum[1] ...
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 ...
2
votes
0answers
34 views

How to highlight php code in a HTML document and the document itself?

how can I highlight php code in a HTML document and the document itself? Example: <!DOCTYPE html> <html lang="de"> <head> <meta charset="utf-8"> ...
5
votes
1answer
93 views

Referring with cleveref to a custom listing (\lstnewenvironment)

I use cleveref's \cref command for referencing, and \lstnewenvironment to create a new listing type. My document has multiple types of listings, each of them with their own counter. However, cleveref ...
2
votes
1answer
60 views

Problem with tcblisting at page break

I use a tcolorbox to display my listings and thats actually works pretty well. But if in my listing a page break occurs, then my predefined "basicstyle" property will be removed. And I have no idea ...
1
vote
1answer
41 views

Verbatim/listings in beamerposter?

I have prepared some nice posters using beamerposter, but now I came to a poster where I would like to add a few lines of code. By just adding [fragile] to the frame I get an error: File ended while ...
1
vote
1answer
26 views

References not working for \lstinputlisting

I may be doing something wrong but can't realize what... I want to set a label for a piece of code represented by: \lstinputlisting[language=Python, label={lst:control_os_call}, firstline=231, ...
3
votes
1answer
71 views

tikz/pgf upgrade and decorations

Since a major upgrade in pgf, my code does not compile any more. I am trying to make "decorated" source listing, where the decorations can be like highlighting some lines (see the MWE), balls on some ...
3
votes
1answer
61 views

Custom List of Listing Page Numbers Not Working

So I have been using this particular latex template for a while now and I keep adding and changing it to be what I want. Recently I tried reformatting to get rid of the leading dots in the TOC, LOF, ...
2
votes
1answer
59 views

How to make listings package break TeX code only after control sequences?

Package listings always likes to break TeX code after backslashes. How to make it always break before backslashes? \documentclass{article} \usepackage{listings} \begin{document} ...
2
votes
1answer
72 views

Colorful prebreak and postbreak tokens with listings package

I want to get colorful prebreak and postbreak tokens with listings package, but the following code doesn't work: \documentclass{article} \usepackage{xcolor,listings} \begin{document} ...
1
vote
1answer
105 views

Error compiling code matlab in latex [closed]

good morning, someone help me? MWE: \documentclass[preview]{standalone} \usepackage[latin1]{inputenc} \usepackage[spanish]{babel} \usepackage{latexsym,amsmath,amssymb,amsfonts} ...
4
votes
0answers
71 views

\inputminted: distinct file parts in one listing (equivalent to linerange in listings)

I want to include code from a file into my document. However, several distinct line ranges should appear in the same listing. Also, I want to use gobbling, and it would be nice to include some blank ...
7
votes
2answers
106 views

New Command For Inline Code

I am using the listings package to enter large blocks of code into my document, however I am trying to write a custom command that uses my current settings to do inline code. For example I want to be ...
0
votes
1answer
54 views

How to number listings by section number? [duplicate]

I want to include several listings in my document with sections. I also want each listing to have labels like Listing 2.1 where 2 is section number and 1 is number of given listing within that ...
1
vote
0answers
57 views

How to add function names to listings package

I have some MATLAB code in my tex file, which I am highlighting with the listings package. However, there are some functions, such as "vision.CascadeObjectDetector", "imcomplement", "bwboundaries", ...
1
vote
0answers
64 views

List Of Listings Overlapping Text

I'm attempting to generate a list of listings for my dissertation. The university doesn't have a standard LaTeX template, but there is a pretty good one generated sometime ago that does the trick. The ...