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

Reproduce lhs2tex’s code indentation in LaTeX

The preprocessor lhs2tex has a very neat way of aligning code. Consider this snippet: let t1 = foo x in let g x = if x > 10 then t1 else let t2 = bar x ...
5
votes
3answers
69 views

Centered line code with numbering

How I can center a line code and numbering it like in the picture? Is there a command that works inside a lstlisting environment? Really thanks in advance
0
votes
1answer
38 views

referencing listing with custom caption using autoref

I'm trying to use the listings package to show some pseudocode. For that I want to add some keywords and a special environment which is used for all pseudocode listings. Additionally the referencing ...
0
votes
0answers
27 views

Listing package making one long dash from multiple dashes (also breaks margins)

----------------------------------------------------------------------------- -- -- Version 1.0 -- ----------------------------------------------------------------------------- Code like the above ...
1
vote
0answers
45 views

How can I highlight something inside a listing? [closed]

I need to call attention to parts of code that don't get highlighted as keywords, strings, etc. inside a listing. I've found a few relevant questions on TeX.SE I and tried to apply the solutions ...
0
votes
1answer
39 views

Float placement for lstnewenvironment

I've defined this environment: \lstnewenvironment{pddl3}[1][] { \lstset{ keywordstyle=\color{black}, commentstyle=\color{black}, language= VBScript, ...
4
votes
1answer
47 views

Length operation within a newtcblisting

Consider the following code: \documentclass[10pt,letterpaper]{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage[french]{babel} \usepackage{calc} \usepackage{tikz} ...
1
vote
0answers
47 views

why is the text green in my code listing? [closed]

I use \begin{lstlisting} Type readable_t, writable_t \end{lstlisting} I want the text color to be black, but instead I get green:
3
votes
1answer
38 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
3answers
110 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
34 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
51 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
71 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 ...
8
votes
1answer
213 views

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
49 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
24 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
37 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
28 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
41 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
1answer
58 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
52 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
22 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
29 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
33 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
62 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
22 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
30 views

Handling 'underscores' and special characters in latex listing package [duplicate]

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
36 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
44 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
45 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
36 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
87 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
37 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
63 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
59 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
76 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
63 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
34 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
82 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
70 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
92 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
78 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
45 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
180 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
26 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
53 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
47 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
110 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
130 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 ...