{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
0answers
64 views

Colors for integers in listings package [duplicate]

Possible Duplicate: How can I change the color of digits when using the listings package? Listings package: How can I format all numbers? Is it possible to have colors for integers using ...
0
votes
1answer
586 views

Problems using listings package [closed]

I'm using the listings package to include some source code files in a LaTeX document. I'm having 2 problems: characters - are not shown in the resulting file characters % are shown overlapped with ...
4
votes
1answer
303 views

listings caption is distorted

I used listing for listing the codes like: \documentclass[prodmode,acmtecs]{acmsmall} % Package to generate and customize Algorithm as per ACM style \usepackage[ruled]{algorithm2e} ...
3
votes
1answer
694 views

Latex listings R: need mono-spaced font with bold keywords and correct caret (^)

I am using the listings package to display R code. I would like a monospaced font, bold keywords, and I would like code that works when the user cuts and pastes from the pdf file into rstudio. The ...
4
votes
1answer
269 views

Can I use \lstinline for table column?

I want to apply \lstinline to one of the columns. I don't like idea to put it in every cell manually. I am trying to do \begin{table} \begin{center} \begin{tabular}{| >{\lstinline}l | ...
5
votes
2answers
968 views

Package Listings Warning: Text dropped after begin of listing when calling function

I'm trying to this: \newcommand{\code}[1] {\begin{lstlisting} {#1} \end{lstlisting} } But I keep getting this error: Package Listings Warning: Text dropped after begin of listing I'm calling ...
3
votes
1answer
865 views

Problem with alignment in listings

I have a follow up question to this post I am using listings in beamer. The content in listings is being pushed further left than the other contents on my slides. I am using the code below to correct ...
1
vote
1answer
263 views

listings font in pdflatex

I'm using \ttfamily but it renders listing with the Times New Roman. What am I doing wrong? I'm getting a warning message: Font shape T2A/fi4/bx/n' undefined(Font) usingT2A/fi4/m/n' instead on ...
8
votes
2answers
3k views

Python code in LaTeX document

I want to include some Python code into LaTex document, so I "imported" the listings package with \usepackage{listings} and \lstdefinelanguage{Python}{ keywords={typeof, null, catch, switch, in, ...
2
votes
1answer
624 views

Removing horizontal black line in listings

I'm using listings for code snippets and I can not seem to find a way to remove the horizontal line on the bottom of a listings environment. My code: \lstset{ ...
3
votes
1answer
601 views

listings incorrectly highlights PHP keywords

I have definitions as below: \lstset{ commentstyle = \color{gray}, extendedchars = \true, inputencoding = utf8x, language = php, keepspaces = true, keywordstyle = \bfseries } ...
3
votes
1answer
719 views

Problem with lstlisting in beamer… What am I doing wrong?

I am trying to to put an lstlisting environment in the left column, but I'm getting errors. Are lstlisting and the columns environment in beamer incompatible? Or is it something else? ...
6
votes
1answer
1k views

Inserting TeX code into beamer - Problem with otherkeywords

I am preparing a beamer presentation and using the lstlisting environment in order to put in TeX code. I am using the following code which is largely copied from here: ...
8
votes
1answer
1k views

Beamer - Using \pause within lstlisting

I am preparing a beamer presentation and using the lstlisting environment in order to put in code. However, I would like to use the \pause command within lstlisting. By definition that is not ...
11
votes
2answers
917 views

highlight lines in listings

I have code that i have included into my document using the texcode below \begin{minipage}{.48\textwidth} \centering \lstinputlisting[numbers=left,xleftmargin=2em,frame=single,framexleftmargin=2em, ...
4
votes
1answer
113 views

How to edit latex-generated text in Captions?

I want to take the answer to the question LaTeX source code listing like in professional books one step further, and change the (latex-generated) text in the caption from Listing n to something more ...
4
votes
1answer
436 views

Set styles for numbers in listings package

I am using the listings package for Smalltalk programming language but since it does not come out of the box, I am trying to do it by hand. Now I have a problem with numbers. No matter if I change: ...
4
votes
2answers
432 views

How to detect words starting with # in listings package?

I am writing some code with the listings package and I need to detect the words starting with the number sign (#) and apply certain style. For example, if I have this code: something #foo ...
2
votes
1answer
295 views

treating multiple code listings as one figure (listings package)

Please note that I am quite new to tex/latex. For my paper I need to reference specific parts of my source code as one code listing. This allows me to skip specific lines of the source code that are ...
4
votes
1answer
123 views

listing's lst@BeginWrite gobbles '->' and '=>' from input [closed]

I'm trying to write a package that takes verbatim input and appends it to several files. My current approach is based of off an answer by Martin Scharrer to a similar problem. The difficulty arises in ...
6
votes
2answers
298 views

How to detect a tab character when processing a literate in lstlistings?

In the solution to Making more easy the itemized of item with tabulation system, I am counting up the number of spaces in order to determine the type of leading character to insert. However, if the I ...
2
votes
1answer
221 views

listings ignore final newline

When I write listings in my LaTeX code I usually follow this format \begin{lstlisting} foo bar baz \end{lstlisting} and when I put this inside a normal LaTeX document, things look fine. But when I ...
5
votes
1answer
2k views

lstinputlisting does not include file within lstnewenvironment?

I want to use lstinputlisting to include a file with code within an lstlisting block, which is defined through a new environment. However, the lstinputlisting command itself, not the code, is ...
1
vote
1answer
363 views

Quotation mark in \lstinputlisting becomes white

How can I fix this issue with everything inside and including the "quotation mark" itself becomes white, in my case invisible due to the white background. Thanks in advance. I almost forgot that im ...
1
vote
1answer
250 views

Using listings package without installing it

I am finishing writing a paper that uses the listings package. Sadly, the submission system I have to use for submitting my paper does not come with this package. Is there any way to use the features ...
9
votes
2answers
320 views

How do I prevent conflicts between accsupp and hyperref?

This question is related to the answer to the question Is there a LaTeX trick to prevent a PDF viewer from copying the line number? Unless you turn hyperref off, the following MWE ...
61
votes
3answers
2k views

Is there a LaTeX trick to prevent a PDF viewer from copying the line number?

A PDF output is obtained by compiling the following code. \documentclass{article} \usepackage{xcolor} \usepackage{listings} \lstset { language={[LaTeX]TeX}, numbers=left, ...
18
votes
4answers
4k views

LaTeX Source Code Listing

I want a code listing, but the code I'm listing is LaTeX. When I simply use: \usepackage{listings} ... \begin{lstlisting} ...LaTeX document goes here... \end{lstlisting} The listing looks like ...
5
votes
1answer
300 views

How to share a counter for a subfloat

I am trying to make a listing float containing 3 subfloats. I have managed to to make the actual float by combining the answers from question1 and question2. Now I only need to make mylisting use the ...
5
votes
1answer
682 views

avoid linebreak in \lstinline if possible

By using \lstinline{mysourcecode} I put some code within my document. I would like to avoid that this code is broken to a new line, if possible. so, if the codeline itself is less long than a full ...
7
votes
1answer
609 views

C preprocessor commands in listings package

I am using the listings package, which is mostly formatting things nicely. However, it fails to syntax highlight indented preprocessor commands correctly. For example, \documentclass{article} ...
4
votes
1answer
856 views

Highlight certain texts in listings or minted [duplicate]

Possible Duplicate: Manual highlight of TeX code in a verbatim environment I want to highlight certain parts of a program output listing which represent user input. For example I want to ...
0
votes
0answers
73 views

My lstlisting environment only shows “2” above the first line, instead of numbers before each line, when Hebrew is enabled [duplicate]

Possible Duplicate: backgroundcolor in lstset does not work I've recently changed my document skeleton and now my code segments, defined with \begin{lstlisting}...\end{lstlisting}, changed ...
4
votes
1answer
1k views

How can I get lines to break automatically using the LaTeX listings package?

I am using the listings package to include sample Perl source code in LaTeX. I included the package with \usepackage{listings}, and used the following code: \lstset{language=Perl} ...
6
votes
3answers
448 views

Invisible listing captions

Short version: how can I make a listing's caption show up in the List of Listings but not in the body of the document where the listing is? I'm writing a university report, and many of my subsections ...
3
votes
1answer
7k views

Package listings: Error “Undefined control sequence.” because of single-quote-symbol?

I'm using the package listings and came across a problem displaying an SQL statement within an java environment. This is the MWE. \documentclass[]{report} \usepackage{listings} ...
0
votes
1answer
230 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} ...
4
votes
1answer
934 views

Strange character when using listings package

I'm seeing an odd character like a very flat U, where there should be a space, with the listings package. See example below. Does anyone have any idea why this is happening, or how to get rid or work ...
7
votes
1answer
2k views

Set font in listings in XeLaTeX

I want to set specific font just for listings in XeLaTeX. \newfontfamily\consolas{Consolas} \lstdefinelanguage{MyLanguage}{ basicstyle=\ttfamily, .... % my language definition } ...
6
votes
1answer
3k views

Is there a good definition for highlighting PHP code in listings?

Does someone have a good definition for highlighting PHP code with the listings package?
7
votes
3answers
724 views

An environment for writing regular-font pseudocode

I want to create a pseudocode environment that looks like this: Basically, the font doesn't change - it's just the same as that of the surrounding text. It allows mathmode. And there is a box ...
3
votes
1answer
4k views

\usepackage{caption} breaks references to tables

I'm formatting the listings captions as follows: \usepackage{caption} \DeclareCaptionFont{white}{\color{white}} \DeclareCaptionFormat{listing}{\colorbox{gray}{\parbox{\textwidth}{#1#2#3}}} ...
3
votes
1answer
708 views

How to set frame size in a listing

I'm trying to put a frame around my code, but the frame has the wrong dimension. How can I set them right? ...
5
votes
2answers
606 views

Add keyword with special character

I'm trying to add a language (Scheme) in the lstlisting package. \section{Scheme} \lstdefinelanguage{Scheme} {morekeywords={,lambda, cond, case, display, let, import, quote, quasiquote, unquote, ...
4
votes
2answers
423 views

Problems When Escaping from Listings

I would like to use LaTeX to document my C++ code, since I am able to typeset mathematics easily, as well as create diagrams using TikZ. I made a minimal LaTeX template for testing, but I have already ...
3
votes
2answers
2k views

Lyx is ignoring typewriter font setting for program listings

I'm using Lyx's Insert|Program Listing to insert a code listing into my document. Unfortunately, Lyx seems to ignore the Typewriter font selection I made in DocumentOptions under Fonts ⇒ ...
2
votes
1answer
1k views

Micro symbol µ in lstlisting

I'm writing a report about a website I'm working on to play cards online. I use lstlisting to display my PHP, JavaScript and HTML code. The problem is that I'm using a lot of µ's in my JavaScript ...
3
votes
1answer
1k views

Custom divider between 2 minipage and lstlisting

I am using the following code to have 2 boxes beside each other for code comparison: \documentclass[12pt]{article} \usepackage{listings} \begin{document} \begin{singlespace} ...
10
votes
2answers
205 views

Including sections of source code as a listing, while being robust to source code edits

Is there a way to input particular sections of source code using \lstinputlisting (from the listings package) in a flexible way? It's possible to use the firstline and lastline options to input ...
1
vote
1answer
679 views

Pointing to Java files not in root latex folder using listings

I am trying to use listings to point to a Java source code file. The file path is different from the Latex document. Below is an example of what I am trying to do, though it doesn't compile it says it ...