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

NewEnviron, \BODY and lstlisting [duplicate]

I was trying to understand egreg's answer to Hide content to show later, and I noticed that there were some problems when using lstlisting or tcblisting environments inside the solution environment ...
3
votes
0answers
48 views

Getting Swedish letters to work in LaTex

Problem: Issue 1 (solved): The Swedish letters ÅÄÖ/åäö do not print out correctly when used with listings package. Issue 2: How can it be solved so that the Swedish letters also get orange color ...
2
votes
1answer
23 views

How should multiline pieces of code be put into a table?

I have the following two pieces of information that I would like to present side-by-side in a Beamer slide. I think I'd like these two things in two cells of a two-column table. Is there a good way to ...
1
vote
1answer
36 views

How to prevent line breaks in code listings?

I am adding a big Linux terminal output as a listing and would like to prevent these line breaks from happening: e.g. user@pc ~ $ top PID USER PR NI VIRT RES SHR S %CPU %MEM ...
1
vote
1answer
23 views

Margin notes in listing with float enviroment – Error: Float(s) lost

Based on this question: Margin notes in listing with float enviroment - Error: Float(s) lost I have now other question. The solution is working fine. But I want to use floats for listings, to prevent ...
8
votes
3answers
90 views

Include a footnote in verbatim text

I have seen how to add verbatim text to a footnote: How to obtain verbatim text in a footnote? What I would like to do is the opposite, include a footnote in a verbatim section. I am using the memoir ...
1
vote
0answers
13 views

Is it possible to include a lstlisting code block inside an lstlisting? [duplicate]

I am trying to include a LaTeX code within an lstlisting. But the problem is that the LaTeX code includes an lstlisting, so the \end{lstlisting} within the included code is terminating the actual ...
5
votes
1answer
50 views

Rewrite \begin{foo}\end{foo} to \begin{bar}{opts}\end{bar}?

I know this is likely a simple Latex macro question. I've got a large document with a ton of lstlisting blocks, and I'd like to use minted instead. That means turning blocks that look like this: ...
3
votes
1answer
34 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
64 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
26 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
25 views

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

----------------------------------------------------------------------------- -- -- Version 1.0 -- ----------------------------------------------------------------------------- Code like the above ...
1
vote
0answers
39 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
36 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
45 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
44 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
36 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
87 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
29 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
34 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
64 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
182 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
37 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
17 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
36 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
25 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
39 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
48 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
47 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
20 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
24 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
27 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
57 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
27 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
29 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
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 { ...
1
vote
0answers
29 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
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 ...
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. ...
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
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
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
83 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 ...