{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.
9
votes
2answers
245 views
Two code blocks working syncronously
I need two code blocks in my beamer frame. One will be the code and other will be the output for each line of code.
I want to uncover each code line and corresponding output line.
So, first it will ...
1
vote
0answers
99 views
highlight listings in beamer
While trying to use listings and beamer, for highlight some parts of the code I found the following: How to make overlay still work inside lstlisting environment?
However I notice that I can't ...
2
votes
1answer
72 views
How can I create wrapper macro for lstinline?
Using \lstinline I can include inline code snippets in a paragraph. I would like to provide a macro that selects formatting, etc, for lstinline so I can just do, say, \codeinline{snippet}.
I had ...
1
vote
0answers
38 views
\lstlistoflistings does not add spaces by chapter [duplicate]
I'm quite new in LaTeX and ended up with this problem: I'm using list of tables and list of lstlistings (\listoftables, \lstlistoflistings), both numbered by chapter. List of tables does add spaces ...
3
votes
1answer
51 views
listings package : highlight word composed by an alphabetic and a numeric part
I would like to highlight several keywords with an alphabetic and a numeric part with different color.
My problem is the number of keywords can become huge from r0 to r191 for example.
And I have ...
4
votes
1answer
70 views
Why keywordstyle is not taken into consideration no bold, no red color?
When I have this code with .sty file from here
\begin{lstlisting}[language=Go, firstnumber=1, captionpos=b, caption=Golang, label=amb]
// You can edit this code!
// Click here and start typing.
...
4
votes
1answer
82 views
Line breaks in listings with long lines
This is a follow-up question to Line breaks in listings
My MWE with a very long line demonstrate the problem:
\documentclass{report}
\usepackage{listings}
\lstdefinelanguage{text}{}
...
2
votes
1answer
95 views
How to define HTML keywords in \listings
I'm working on the implementation of a HTML5 code style for \listings.
Currently I have the problem that there are different ways to define HTML tags. In my example, I don't get /p in ...
4
votes
1answer
68 views
Command to insert filename in caption of a listing
I would like to have a command to insert listings that contain the filename in the caption. This works well as long as there is no "_" etc. in the filename.
I also tried the suggestion from a ...
2
votes
1answer
132 views
minted list of listings and TOC conflict
I am using minted for source code highlighting. I want a List of Listings, and I want the List of Listings to itself have an entry in the main Table of Contents. I thought I could do this with ...
3
votes
1answer
129 views
How to use angle brackets for a keyword in \listings?
I've got a code of a HTML website that I want to show in my LaTeX document. The problem is, that the HTML code has a tag called <canvas> and the JavaScript code inside the HTML document has a ...
5
votes
1answer
92 views
How to use alsolanguage in \listings package?
I defined keywords for the JavaScript programming language and HTML.
I have read that it is possible to use the keywords of both languages in a \listings code snippet. But in my example, the ...
10
votes
1answer
441 views
\listings code style for HTML5 (CSS, HTML, JavaScript)
I would like to create a code style for HTML5 that can be used with the \listings package.
An HTML5 document consists of three languages: CSS, HTML and JavaScript. That makes the whole thing a bit ...
1
vote
2answers
108 views
Keyword-Highlighting of C++ using Listing
I have a little problem in my settings. I cannot locate the error and need some additional eyes to tell me where I should look. I use listing to show my c++ code but when I try to add additional ...
2
votes
1answer
118 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 ...
0
votes
1answer
121 views
LaTeX source code listing with less Space between characters
I'm trying out LaTex and I want to write shell Code in my document.
Therefore I took this code from: http://stackoverflow.com/a/742069
\documentclass{report}
\usepackage{color}
\usepackage{xcolor}
...
3
votes
1answer
89 views
odd displays of accentuated characters in lstlisting environment
when i try to write accentuated characters (éà...) in a lstlisting environment,
hence :
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
...
2
votes
2answers
112 views
Multiline listing within multicolumn row
I have a problem putting a listing (using lstlisting package) within a table. The problem is that I want to put a multiline listing in a row taking 2 columns.
The following minimal example shows ...
3
votes
1answer
81 views
Changing lstlistoflistings title [closed]
I'm having difficulty getting the list-of-listings section to display the proper title, it simply says "Contents" no matter what sort of changes I make. Here is the command I put in the preamble at a ...
4
votes
1answer
54 views
Dynamically created program listing
Is there a way to have a easy to change value in program listing?
Something along these lines:
\newcommand{\variable}{2}
And then having somewhere
\begin{lstlisting}
...
i *= \variable;
...
...
2
votes
1answer
70 views
lstlisting: mathescape and Erlang
I am trying to combine to use mathescape together with the Erlang syntax highlighting in the package lstlisting, as described in Section 4.14 of its manual:
\documentclass{article}
...
0
votes
1answer
95 views
Bug? Colored frame in mcode package
While using mcode.sty, I recognized that at linebreaks with long comments parts of the surrounding frame got colored green or were even left white at using mathematical formulas, e.g. in the following ...
7
votes
1answer
123 views
Line breaks in listings
Is there a way like wrap the line after at most 60 letters but it should not break inside some commands like listings does?
Example:
\documentclass[a5paper]{article}
\usepackage[T1]{fontenc}
...
1
vote
1answer
72 views
\lstinline break at punctuation
I need listing package (\usepackage{listing}) to break at punctuation
namespace::subnamespace::class
^ ^
at either these two locations
4
votes
1answer
102 views
Creating a table around a java script code highlighted using minted
I would like to create a block around javascript code in latex.
I use minted package for format highlighting.
Here is my example code:
\documentclass[]{article}
\usepackage{minted}
%opening
...
3
votes
2answers
168 views
How to use a colon in lstlisting keywords?
for the use of CSS code I've defined the following style:
\lstdefinelanguage{CSS}{
sensitive=true,
alsodigit={-},
keywords={transform, transition-property, transition-duration, ...
3
votes
1answer
172 views
How to add \lstlistoflistings to the table of contents?
can someone tell me, how to create an entry for the \lstlistoflistings command in the TOC? I want, that you can see the page number where the list can be found.
3
votes
1answer
157 views
How to tweak the LOF and LOT without using any packages?
The list of figures/tables in default book class looks like:
Default looking:
List of Figures
1.1 Snapshots .................. 2
1.2 Snapshots .................. 4
1.3 Snapshots ...
6
votes
1answer
167 views
Making Source Code Copyable with listings
I'm using listings to display some matlab code in my latex document but i'd like to have syntax highlighting. I've tried two ways of getting syntax highlighting and neither make the code copyable. The ...
0
votes
1answer
86 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},
...
2
votes
0answers
44 views
Override properties of a predefined listing style
I use the listings package and I want to override an attribute of the HTML style.
Unfortunately my code overrides the whole HTML style and not just a single property:
\lstloadlanguages{HTML}
...
1
vote
1answer
54 views
How to use listings with multiple languages?
I've got a HTML document with JavaScript inside that I want to show in my article.
For that I would like to use my JavaScript and HTML formatting. How can I get the listings package to use two ...
2
votes
0answers
42 views
Listings: Format part of a string differently (markup language inside a string)
I made a new language definition for a .NET template engine where part of the strings in the C# code are markup.
Example:
string templateString = @"{% for name in names %}
Hallo {{ name }}
{% ...
0
votes
0answers
24 views
Can I define styles of the listings package hierarchically? [duplicate]
Possible Duplicate:
listings: General settings for a language seem to be overwritten/not respected
With the listings package I can define styles or environments. Now I wonder if I can ...
0
votes
1answer
71 views
Can I mark specific lines in lstlisting?
I want to give listings and somehow mark a particular set of lines. My preference would be to make them italic. (The purpose of wanting to do this is so I can say "these lines are required but you do ...
6
votes
1answer
147 views
Treat grammar as listing
I have a grammar in my document using the package syntax like described in the answer to How to type a Backus-Naur form in LaTeX.
Now I want it to be treated like the listings I have in my document. ...
1
vote
2answers
137 views
framebox does not work for lstlisting environment
I am looking a way to wrap something with a frame. I try different approaches but finally choose to use fancybox package and minipage (because I need to control the width of the frame). It works ...
0
votes
1answer
92 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 ...
3
votes
1answer
79 views
How to control latex appendix environment when placing R code in?
I am having a problem with latex environment. When I place r code using \begin{lstlisting} ... code..\end{lstlisting} other objects like tables are displayed only after the script subsections, despite ...
3
votes
1answer
56 views
bug in listings package?
It seems as if the listings package can not be loaded after all other packages using \AtBeginDocument
\documentclass[]{scrbook} %
\AtBeginDocument{\RequirePackage{listings}}
\begin{document}
...
0
votes
1answer
92 views
Why does using lstinline inside mathescape inside lstlisting not work?
I'm trying to typeset some code. That code has some embedded mathematics, but in the embedded mathematics, I need to reference variables from the code. I would like for the variables in referenced ...
4
votes
1answer
57 views
test if a listings or glossaries style is valid
I want to test in my template if a call of
\lstinputlisting[style=mystyle,...
or
\printglossary[style=mystyle,...
is valid or will fail because of an unkown style.
However I could no find out ...
3
votes
0answers
104 views
About autoindent and postbreak in the package listings
I am using the package listings to show my Matlab code. The code was pre-typed in a file and everything will be loaded from the file and a .tex file will be generated automatically to show the code ...
0
votes
0answers
57 views
Is that any way to make verbatim environment line breaking automatically and justify left and right [closed]
I am trying to show the text literally in verbatim environment with line breaking automatically. I Googled this and people recommended using the listings package. I am following the instructions in ...
4
votes
1answer
82 views
label within lstlisting prefix gives strange output on \ref
I have all kinds of labeltypes for my own convenience defined like "sec:", "cha:", "fig:", "lst:" and so on.
Now I wanted to point to a certain line of code within one of my listings. There is no ...
2
votes
1answer
97 views
Define listings language using variable
I'm using the listings package to document excerpts from my programs. I have been creating new environments for the various programming languages and wondering whether there was a way to hack the ...
0
votes
1answer
58 views
Avoid page break in listing [duplicate]
Possible Duplicate:
How can I ensure that a listing is not going to be split?
My listing goes at the bottom of a page and fits good. But the header is separated and moved to another page. ...
2
votes
1answer
115 views
Center just one line of code (e.g. comment)
In my lstlisting I want to place a comment in the form of
/*====== some section ====== */
but having it centered and not like the rest of the lines of code which are left aligned.
Using the escape ...
3
votes
0answers
69 views
place symbol or some command on page break within lstlisting
Whenever I have a page break splitting my lstlisting on different pages, I would like to have a symbol or generally spoken some command inserted automatically. I can accomplish that manually by using ...
3
votes
1answer
67 views
text dropped after beginning of listing
How do I fix this haunting message?
"text dropped after beginning of listing"
In my preamble I use:
\usepackage{listings}
\lstset{basicstyle=\ttfamily,breaklines=true}
Then within the document ...

