{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.
3
votes
1answer
618 views
Custom numbering of listings
I have a number of listings in my document, numbered 1, 2, 3 and so on.
I need a table with three listings (say, three different variants of the same algorithm), that will be numbered as 2a, 2b, 2c. ...
3
votes
2answers
798 views
Changing side of line numbering in two columns documents
I'm trying to type some report and I have a small problem with the twocolums document class and the line numbering in listings.
The document is on two columns :
...
2
votes
1answer
86 views
Add keywords to an existing language in listings
I've already read extending a language with additional keywords and I have found kind of a solution, but I'm not quite sure if it's the right way and if I won't have problems in the future.
The ...
2
votes
1answer
134 views
regular expression in listings
I'm looking for a possibility to find a way to colorize data. If a text starts in a line with XYZ from that point until the next blank line the text should be set in a defined colour. With the comment ...
2
votes
1answer
127 views
Creating a custom environment
I'm using the following syntax for my code snippets
\begin{minipage}{\textwidth}
\begin{lstlisting}[caption=<something>, label=<something>]
The REST Endpoint URL
is ...
2
votes
1answer
210 views
LaTeX listing of command line syntax
I have a LaTeX document using the listings package for some bash scripts. I'd like to create a different styling for text that is meant to show the syntax of a command. For instance, I have the ...
2
votes
1answer
208 views
How to add a keyword with a blank space in Listings package?
I am trying to define a listing style in order to have fortran source codes which look like vim style colors.
For example, I would like to give a specific color to end program or end module or ...
2
votes
1answer
248 views
Background color in inline code listings with linebreak
I want to highlight code inline with a gray background. Preferably with listings.
This question is related to Colored background in inline listings.
But as my MWE shows it doesn't work with line ...
2
votes
1answer
146 views
How to escape backslash in rangeprefix?
I want to escape backslash to be used as a rangeprefix as follows. The current MWE does not work as expected because it still imports all codes rather than the codes sandwiched by document ...
2
votes
1answer
2k views
Adjust bottom margin of a listing environment
I use the following settings for code listings.
\usepackage{listings}
\usepackage{textcomp}
\lstset{language=Java,
keywordstyle=\color{RoyalBlue},
basicstyle=\scriptsize\ttfamily,
...
2
votes
1answer
903 views
Lstlistings: Getting pretty equations in display mode
I am currently trying to print my algorithms using the listings package. For clarity I always try to display the more complex mathematical expressions as formula instead of plain code. This results in ...
2
votes
1answer
666 views
Using the “combine” document class with the listings package
I am trying to use the combine document class (manual) to combine several pre-existing documents into a single file with consistent formatting. It works great, except that there is a conflict of some ...
2
votes
1answer
1k views
How to make tabsize also affect lstinputlisting?
I noticed that tabsize only affects lstlisting and lstinline macros.
Here is the output. The top figure is displayed using lstinputlisting and the bottom one
is displayed using lstlisting. The ...
1
vote
0answers
30 views
Mixing multiple programming languages with different styles in same document [duplicate]
Possible Duplicate:
Defining lstset parameters for multiple languages
What's the easiest way to include code, using listings, from more programming languages?
\lstset{ %
language=Python,
...
1
vote
1answer
165 views
Using package listings with sciposter
Could you please provide a working example in which a source code delimited by listings environment word wraps its lines, without breaking the column layout of sciposter?
Whenever I put a long line ...
1
vote
1answer
153 views
Listings, problem with rendering embedded strings
this is my style defined for C#:
\lstdefinestyle{CSharp}{
language=[Sharp]C
,captionpos=b
,columns=fixed
,morekeywords={var,get,set}
,basicstyle=\footnotesize\ttfamily
...
1
vote
1answer
256 views
Why does pdfLaTeX fail when I try to use `begin{lstlisting}` inside a user-defined environment?
I'm having trouble with the listings package. I can't compile the following minimal example through pdfLaTeX:
\documentclass[a4paper, 11pt, twoside, openright, english]{memoir}
\usepackage{listings}
...
1
vote
2answers
997 views
Listing inside tabularx?
I have a tabularx environment where I want to put an lstlisting into. But Latex fails to compile it. Testcase:
\documentclass[a4paper,12pt]{scrreprt}
\usepackage[utf8x]{inputenc}
...
1
vote
1answer
224 views
How to make my unusual environment accept one argument?
I cannot find a good title to express my question. Therefore, please parse the following code first.
Minimal Code
\documentclass[dvips,dvipsnames,cmyk,table]{book}
...
1
vote
2answers
674 views
Define a new environment to combine tikzpicture and lstlisting
I would like to define a new environment to combine the tikzpicture environment from package pgf/tikz and the lstlisting environment from package listings. The result would be to first produce the ...
1
vote
1answer
326 views
Without defining a new command for each setting, is it possible to pass the set of settings to the optional argument of lstinputlisting ?
Screenshot
Scenario
I want to define two sets of settings for \lstinputlisting--One setting for CSharp A and the other one for CSharp B. They are different only in the color settings.
...
0
votes
1answer
98 views
Standard single quotes for code in listings [duplicate]
In my code, I have curved quotes (see screenshot). Can I replace them with vertical quotes?
This is my formatting code:
\lstset{%
% General design
backgroundcolor=\color{lightgray},
...
0
votes
1answer
102 views
Changing code in listings dynamically
I need to change dynamically the code in the listing by adding just one key word to the code. I tried to do it like this:
\begin{lstlisting}[escapechar=|]
class MyThread extends Thread {
private ...
0
votes
1answer
174 views
\afterpage issue with \lstlisting
I have issue with \afterpage command and \lstlisting, it's add one blank page after beginning code listing, and after blank page is two of my command.
\appendix
\section*{APPENDIX A}
...
0
votes
1answer
299 views
Highlighting line ranges in listings
I've put here one adaptation for "no-beamer" documents of this code. Thanks a lot for the indications given below by Daniel.
% Sources :
% 1) ...
0
votes
1answer
548 views
Code fails with Emergency stop, when using \expandafter\csname and such in listings
I am further working on my code for LaTeX Examples. I want to use the package showexpl for the simultaneus printing of code and results. Unfortunately I get an '! Emergency stop.'
...
0
votes
5answers
547 views
How to prevent extendedchars=\true from producing a blank line?
My previous question How to suppress BOM effect in the output? has been solved by @Vaulty. Enabling extendedchars=\true, however, produces an unnecessary blank line at the first line as shown below.
...
0
votes
1answer
304 views
Align normal text inside a listing
I need a way to correctly align the escaped strings that I put inside of this listing. The problem is that they are presented right aligned. I want that this lines keep the indentation of the previous ...

