{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

3
votes
1answer
25 views

beamer problem with combining columns, listings, and overlays

I am trying to come up with a beamer frame where some listing appears at the left column on overlay 1 and some other stuff appears in its place in overlay 2, while some stuff appears in the right ...
2
votes
2answers
62 views

How to use the degree symbol in programming listing?

I'm using lyx and get the error message, that the ° symbol got excluded, when I'm trying the following example: \usepackage{listings} \begin{lstlisting} 10°C \end{lstlisting} EDIT: as asked, here ...
2
votes
0answers
22 views

Listings - Getting the colors right for custom language

I have lots of bookkeeping transactions that I would like to typeset in a color coded format. I am using the listings package to accomplish what I want. I tried the following code. ...
0
votes
1answer
24 views

Listings moredelim / morestring options doesn't work with included file

I don't know how to fix the double quote character (’"’) with the listings package when the code is in a separated file. Listing get this as the beginning of a string but it is not. Many thanks to ...
3
votes
1answer
56 views

Exclude lstinputlisting

I want to save paper when I print my LaTeX file. That's why I want to hide all my code, inserted wtih lstinputlisting{} I already know how to exclude tables and images or math but the ...
5
votes
0answers
98 views
+300

Specific color for different tags and comments using Listings package

Problem: The > symbol for HTML tags in the MWE has a different color than the < symbol. Would like to have both the same color. Minimal Working Example: \documentclass{scrreprt} \makeatletter ...
1
vote
1answer
32 views

Set up [Sharp]C language for listings

Why must I use style work-around to set C# language in listings? Why \begin{lstlisting}[language=[Sharp]C] cannot be processed by LaTeX? \documentclass[a4paper,12pt]{article} ...
1
vote
0answers
13 views

incorporating R code in latex, commentstyle not working

I have an issue with no all my R comments being colored in my latex file. I am using the listing package. My pre-amble code is \lstset{ % language=R, basicstyle=\footnotesize, ...
1
vote
0answers
33 views

Typeset code within a simple macro?

I want to use a macro to typeset programming code with the usual characteristics (particularly lines should be obeyed - this is the most important issue; highlighting and such stuff is - for now - not ...
0
votes
0answers
20 views

Defining specific color for certain symbols in PHP using listings package

Problem: Trying to give certain symbols in PHP a specific color using the listings package. For instance, I want to be able to give <?php and ?> a specific color, while giving the object arrow ...
0
votes
0answers
34 views

Remove “Lst.” from list of listings

I've renewed the title of my list of listing and the caption of my code snippets with the following commands: \renewcommand{\lstlistingname}{Code} \renewcommand{\lstlistlistingname}{List Of Code} ...
0
votes
0answers
22 views

Listings with some notes

I would add some "notes" to a listing. I mean, I have a listing and in some parts of the code (on the left side) I would add a "symbol". I'm thinking something like a circle with inside a letter ...
1
vote
0answers
33 views

Unwanted space around punctuation in copied & pasted listing

When I compile the .tex file below into .pdf using rubber -d mwe.tex and try to copy & paste the contents of the listing, I get spaces around . characters that were not present in the original ...
5
votes
1answer
43 views

Exclude caption from listing margin in IEEEtran v1.8a

I have the following setup for the listings package, including a left margin to have the line numbers stay within the column. \documentclass{article} \usepackage{color} \usepackage[final]{listings} ...
0
votes
0answers
16 views

Defining keywords for SQL using listings

Problem: I use listings package to highlight SQL code but for some reason, unknown to me, I can't get certain keywords in SQL to highlight in a different color. Minimal Working Example: ...
1
vote
1answer
21 views

Add description to code tag

I didn't find answer how to add description to my simple code listing. It looks like that: \lstnewenvironment{code}[1][]% { \noindent \minipage{\linewidth} \vspace{0.5\baselineskip} ...
1
vote
0answers
26 views

Define listings for PHP

Problem: 1) Getting the following error messages: (a) Package Listings Error: Couldn't load requested language (b) Package Listings Error: language phpalsodigit undefined. 2) Unable to figure out ...
2
votes
0answers
54 views

Unhighlighted syntax with listings package

I have some trouble with making documents with syntax highlight. Here is the MWE: \documentclass{article} \usepackage{xcolor} \usepackage{listings} \lstset{% language=[LaTeX]TeX, % I also tried ...
1
vote
0answers
21 views

Is there any smart way to dynamically define lines in listing? [duplicate]

I'm using lstinputlisting to include code examples in my thesis, but as I'm working on the text and the code simultaneously, the code is not yet fixed in length. Is there any way that I can define a ...
0
votes
1answer
22 views

Handling 'underscores' and special characters in latex listing package

How to handle the 'underscore' and the special character in latex listing. I am working on a simple prolog style code \begin{lstlisting}[label=LE, name=R_E] $\alpha_{1}$ = *M1* °h1°(^A^, ^B^) ...
0
votes
0answers
27 views

How do I get this scheme code package into my listings package?

I'm relative new to LaTeX and I want to add this https://github.com/stuhlmueller/scheme-listings scheme-Package into my listings package. But how does it work? I don't get the installation manual for ...
2
votes
1answer
26 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
41 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
25 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
60 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 { ...
1
vote
0answers
26 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} ...
2
votes
0answers
39 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 ...
0
votes
0answers
42 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
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 ...
2
votes
1answer
56 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
29 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
73 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
43 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
79 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
67 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
34 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
169 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
22 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
49 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
35 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
87 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
96 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
39 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
37 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
42 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
32 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
39 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
25 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
33 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
56 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 ...