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

Listing sourcecode - two columns, associations with colored background

I stumbeled over a way of formatting sourcecode in a book I am currently reading. It looks like this: So basically we have a following structure: There are two columns. Left column contains the ...
4
votes
1answer
21 views

listings package: auto indexing

I studied the documentation but was not clever enough to understand how to automatically index multiple kinds of keywords. I give a MWE below. When I run the document, only class [1] keywords appear ...
4
votes
0answers
50 views

Highlighting a backslash with showexpl or listings

Is there a way to highlight a single backslash (\) within LaTeX code with listings or showexpl? In the following example, \LaTeX is correctly highlighted, but not the following backslash. ...
1
vote
1answer
37 views

Turkish (İ) character inside code listings

I'm using listings package to put java code in my tex files. There are some Turkish characters in the code. So, I'm using the literate directive for them to appear correctly. Everything works fine ...
2
votes
1answer
49 views

Avoid insertion of space below section title with aboveskip, belowskip in listings environment

I was using the listings package to place source code in my document and I noticed that the space between the text and the lstlisting environment was to little. So I changed the \aboveskip and ...
4
votes
1answer
38 views

lstlisting R keywords

I want to write R source code in my latex file so I'm using the listings package. The problem is that I want R keywords to appear in blue but for instance a variable named abc.log.de appears with log ...
0
votes
0answers
24 views

My lstset wont wrap words [closed]

Im am trying to make my Listings to wrap in my document, but they wont. They just go over the margins. Can anyone see any missing things in this code? \lstset{ language=C, ...
0
votes
1answer
56 views

How to insert matlab code with listings?

You know that Matlab save .m file with ANSI encoding. I have a sample .m file, and want import it to Latex with UTF-8 encoding. How to convert ANSI file encodifg to UTF-8 and input it, without ...
3
votes
1answer
52 views

Typeset listings with preamble (Preferable using the listings package)

At the moment I use the listings package to typeset my listing. The listings are floats, use line numbers and have a top and bottom rule in order to be set apart from the surrounding text. What I ...
2
votes
0answers
36 views

Listings: color numbers only out of keywords

With the listings package, I would like to color the integers out of strings and comments and out of keywords too. The question for coloring numbers has been asked several times. Some answer handle ...
5
votes
3answers
80 views

numbering tcolorbox toc

I'm writing a quite large document and would like to make a toc of used boxes. I'm using the tcolorbox package because i like the way it gives you freedom to modify the appearance of the boxes. While ...
5
votes
1answer
103 views

Using the sourcecodepro font with Beamer listings

I would like to use the sourcecodepro package to typeset source code in Beamer. The following code gives the same fonts, regardless whether sourcecodepro is loaded or not. I would like to stick to ...
2
votes
2answers
28 views

Problem with package Listings with Czech letters compiled by XELATEX engine

When I try to use czech letters defined like this {Ř}{{\v{R}}}1, I'v got this: My problem is that that letters with hook are not have the right position in the word. When I try compiling MNWE with ...
3
votes
1answer
53 views

Cannot see colors in LaTeX output - lstlistings

Can you give me some help? In the following I only see black text, although I set lots of things with different colors... Why isn't this working? \documentclass[10pt,twoside,a4paper]{article} ...
3
votes
1answer
42 views

Skip line numbers and resume from specific number

I'm a total latex noob, I would like to accomplish something similar to what has been asked here, but rather than resuming numbering from where it was left off, I'd like to pass the new line number as ...
3
votes
1answer
40 views

Highlight variables prefixed with % and $ lstlisting

I'm trying to get syntaxhighlighting comparable to this: (with $-prefixed variables as well) But I'm having issues with the %-prefixed identifiers. I tried doing it with ...
3
votes
1answer
48 views

UTF characters in listings

I use lstlistings for code and a lot of special characters can be displayed with literate. See my MWE \documentclass{scrartcl} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} ...
2
votes
0answers
36 views

listings: How can I highlight Makefiles?

I am trying to typeset a makefile using listings. Now I would like some differential highlighting, e.g. for variables and ordinary commands in the target body. In this snippet, want to have different ...
6
votes
1answer
89 views

What is the difference between \usepackage{mcode} and \usepackage{listings} for MATLAB codes?

I know there is available in the MATLAB Central File Exchange site the mcode.sty package, which allows to put MATLAB codes into TeX files. ...
0
votes
1answer
48 views

I have some weird output instead of “blank space ” it appears unknown symbol in LaTeX [duplicate]

I'm writing code c++ in LaTeX using listing...but I have some weird output instead of "blank space " it appears unknown symbol, here is the code of the list: \defverbatim[colored]\lstI{ ...
1
vote
0answers
37 views

How can I typeset JSON code with the listings package? [duplicate]

I got this error with the listings package (v 1.5c). Should I install the language manually? ! Package Listings Error: Couldn't load requested language. See the Listings package documentation for ...
1
vote
0answers
54 views

listings - highlighting additional keywords inside own delimiters (like Doxygen annotations)

According to listings - use different style for normal comments /* and doxygen comments /** I used listings package to set style for /** Doxygen comments */ as user defined delimiter moredelim = ...
2
votes
1answer
33 views

listings - use different style for normal comments /* and doxygen comments /**

listings package allows setting basicstyle, keywordstyle, identifierstyle, commentstyle, stringstyle. Is it possible to set different style for comments that start from /** not just /*? To make my ...
1
vote
1answer
95 views

Ascii punctuation characters in listings [closed]

Let me explain. When I put some listings using listings package, then simple signs are replaced with similar, but more fancy signs, for example: ' into ` and so on, therefore there is no way to copy ...
4
votes
1answer
50 views

How can I make a whole listings line into a hyperlink?

Let's say I have a document with a listings. And I want to convert that listing into a hyperlink (e.g. to the source code). The first instinctive attempt will be something like: ...
3
votes
1answer
53 views

Floating lstlisting - Getting it to split if longer than a page

When I put a long code in my file using a floating lstlisting, it is forced to be in only one page at the end of the chapter, and then some of the code is truncated and outside of the page. If I ...
3
votes
1answer
48 views

Getting WinEdt to ignore lstlisting

WinEdt 9.0 gives me incorrect TOC in its side panel when I use listings package to illustrate a piece of LaTeX code: How can I get WinEdt to ignore \begin{lstlisting} ...\end{lstlisting} (and ...
5
votes
1answer
71 views

How to display code formatted with lstlisting in a bussproofs proof tree?

I wish to include Java-code formatted with lstlisting as a conclusion in a bussproofs proof tree. The code has to be in boxes so two peaces of code can be displayed next to each other in the same ...
7
votes
1answer
212 views

How can I typeset Julia code with the listings package?

I'd like to typeset some Julia code, syntax highlighting and all, with the listings package. For information, the Julia language is a strong contender for MATLAB, and is free and open-source. ...
0
votes
2answers
55 views

Listing in Beamer Frame - halts after warning

This minimal example does not compile and I don't know why. There is a package warning Package Listings Warning: Text dropped after begin of listing on input line 8. And then there is no output ...
5
votes
1answer
80 views

Incorrect tree view of document structure with Winedt, VerbatimPlus and listings package

I´m having some trouble working with Winedt 8 and 9 and VerbatimPlus add-on. Here is my MWE. File "main.tex" \documentclass[a4paper]{article} \usepackage[utf8]{inputenc} % Codificação da entrada ...
2
votes
2answers
54 views

Choosing lines from a Matlab file using matlab-prettifier

I have been using the matlab-prettifier package a couple of times. So far I have only imported the entire .m-file to be shown in my documents using: \usepackage[numbered,framed]{matlab-prettifier} ...
7
votes
2answers
127 views

Listings “cannot load requested language”

If my understanding that it is possible to specify the programming language for the listings globally as well as on the listing by listing basis is correct, than the following should work: ...
3
votes
1answer
31 views

Increase width of caption's horizontal lines in algorithmic and listings

I've been able to increase the width of the horizontal lines honoring the second answer in LaTeX tables: How do I make bold horizontal lines (typically \hline)?. Now, I'd like to do the same in ...
1
vote
0answers
25 views

Custom color in keywordstyle for listings under LyX [duplicate]

There are several Questions and Answers regarding the use of listings under LyX. And they mention, or explain, how to enable syntax highlighting. While this is easy to achieve, my attempt to use a ...
2
votes
1answer
146 views

How to set up listings for use code from Arduino?

Well, I'm creating notes from a course of Arduino in LaTeX and I was reading about the listingspackage and I want to use it with the code of the exercises of the course. I know Arduino uses a language ...
1
vote
0answers
3 views

lyx program listing whitespace character

In ubuntu 14.04, I used lyx to write documents in which have source code(C language) embedded. I wrote code by using Insert->Program Listing. For example #include <stdio.h> int main() { ...
4
votes
2answers
54 views

Why does un-commenting the last sentence move the period to the new line?

The last sentence in the MWE below is commented out. This paragraph then renders just fine. \documentclass[11pt,letterpaper]{book} \usepackage{listings} \usepackage[left=1.50in, right=1.00in, ...
0
votes
1answer
52 views

Weird problem with lstlisting (xelatex) [duplicate]

I've got something really weird. Here is MWE: \documentclass[a4paper,oneside]{book} \usepackage[english,russian]{babel} \usepackage{inputenc} \usepackage{listings} \usepackage{fontspec} % fonts ...
2
votes
1answer
82 views

Listing for TeX : how to add every tex command as keywords?

I'm looking for a way to color all LaTeX commands in a listing. I'm currently using a bad way to do it : \lstset{ language=TeX, ...
7
votes
1answer
86 views

How can I make the width of the caption match that of the listing?

How can I fix the captions width to match the listing? As in the picture below: Code is here: \documentclass{article} \usepackage{xcolor} \usepackage{listings} ...
2
votes
0answers
39 views

Is there a solution to the differences between listings and verbatim [duplicate]

My code is here, \documentclass{article} \usepackage{listings,xcolor} \lstnewenvironment{code} {\lstset{language={Matlab}, lineskip=-1pt, belowskip=3pt, breaklines=true, ...
4
votes
1answer
69 views

How can I get a macro (e.g. for a function parameter) to gracefully expand within a listing?

I try to pass a parameter to code environment (lstlisting): \documentclass{standalone} \usepackage{listings} \def\parameter{home/Desktop/example_01/} \begin{document} \begin{lstlisting} \parameter ...
16
votes
4answers
428 views

Bash lstlistings treats “$#” as a comment

Background: In Bash, $# represents the number of arguments, and # starts a comment. Consider the following Bash script: # This is a comment while [[ $# -gt 0 ]]; do echo $1 shift done Note ...
4
votes
2answers
47 views

Adding a Caption to \lstnewenvironment using \mdframed

I found on the Internet the piece of LaTeX code I really liked : \documentclass{article} \usepackage{listings,mdframed,xcolor} \definecolor{codeBackground}{rgb}{0.9, 0.9, 0.8} ...
1
vote
0answers
37 views

increase margins of floats page

I have several sections in my article, each with a sizable (~22 lines) code listing explaining the concept of that specific section. I do want to float my listings, as they look nasty if broken off ...
2
votes
1answer
62 views

How can I show only an arbitrary set of lines of my listing (e.g. lines 1-10 and 15-30)?

I want to make a listing with a interval, this mwe : \begin[firstline=5, lastline=10]{lstlisting} <inkscape-extension> <_name>Export to TikZ path</_name> ...
1
vote
0answers
18 views

Problem with spacing above some, but not all, “\paragraph” headers [duplicate]

I am writing a text using \paragraph, and I am completely baffled as to why the 1st paragraph has no space between it and the above text whereas the 2nd does! If I add one more paragraph after the ...
1
vote
0answers
41 views

Spacing between words in listings package and emphasizing identifiers

I have written some source code using listings package but is stretching out of the page. This package leaves huge spaces between the words, so is there a way to make them smaller? At least like the ...
0
votes
0answers
48 views

A problem about typesetting Mathematica code [duplicate]

I want to typesetting the words as below: My code: \documentclass[b5paper,UTF8]{article} \usepackage{graphicx} \usepackage{geometry} \usepackage{fancyhdr} ...