{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

0
votes
0answers
20 views

Listings requires installing manually JSON language?

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
21 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
23 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
67 views

Ascii punctuation characters in listings [on hold]

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
45 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
41 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 ...
1
vote
0answers
26 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
52 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
188 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
39 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
68 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
33 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
98 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
25 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 ...
0
votes
0answers
49 views

Horizontal space issue after using \lstinputlisting [closed]

I experienced this issue after using \lstinputlisting in my project. In particular, the definition in preamble is this: \usepackage{listings} \usepackage{color} \definecolor{mygreen}{rgb}{0,0.6,0} ...
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
90 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 ...
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
43 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
80 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
84 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
38 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
67 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
400 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
40 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
36 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
61 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
40 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} ...
1
vote
1answer
41 views

Disable formatting for a selection inside listing?

I am typesetting my MATLAB code with package matlab-prettifier, which is essentially listing. However, sometimes I do not want the formatting. I simply want pure unformatted text. For example, in the ...
0
votes
0answers
54 views

Font shape 'OT1/cmvtt/bx/n' undefined

I'm getting the following warning: Latex Font Warning: Font shape 'OT1/cmvtt/bx/n' undefined (Font) using 'OT1/cmvtt/m/n' instead on input line 25 How can I suppress that warning? Or: ...
3
votes
1answer
36 views

Package listings and Perl here documents with apostrophes

I sometimes write ordinary English prose in my here documents in a Perl usage sub, for example --[no]alias [don't] use the alias list in the ini file (default noalias) The problem is the a ...
3
votes
1answer
60 views

Why do minus signs vanishes in listings typeset with matlab-prettifier? [duplicate]

I am typesetting my MATLAB code with package matlab-prettifier. However, the - sign are gone. How can I get it back? MWE \documentclass[12pt]{article} % For MATLAB code ...
3
votes
1answer
172 views

TeX capacity exceeded with listings package

In trying to find the source of the following error in my LaTeX document, the listings package seems to not be runnable The minimal example, which I implied but did not include was: ...
1
vote
1answer
54 views

How can I set a font size smaller than \tiny in lstlisting?

I'm writing a presentation using LaTeX and beamer. In some slides I put an image and some code using the listings package and the lstlisting environment. I'd like to use a font size smaller than \tiny ...
2
votes
1answer
47 views

tcblisting: two listings side by side

can anybody tell me, how to place two source doe listings side by side within a tcblisting? Something like: \begin{tcolorbox}[colback=red!5!white,colframe=red!75!black,sidebyside, listing ...
1
vote
0answers
29 views

How to make listing program ConTeXt at LaTeX ?

I want make listing program Context at LaTeX, my MWE like this : \documentclass[]{article} \usepackage{listings} \usepackage[dvipsnames]{xcolor} \lstset { frame=single, framesep=\fboxsep, ...
4
votes
2answers
71 views

Unnecessary line break with listings and prebreak

A lstlisting environment with prebreak may break lines unnecessarily. Here is an MWE: \documentclass[draft]{article} \usepackage[final]{listings} \begin{document} \begin{lstlisting} 1 3 5 7 9 1 3 5 ...
3
votes
1answer
39 views

Using listings within a \only section

Is there any way to use listings within \only sections of Beamer presentations? The following is an example of what I'd like to achieve: \documentclass{beamer} \usetheme[height=7mm]{Boadilla} ...
2
votes
1answer
42 views

Vertical border between number and code in lstlisting

what I am trying to achieve is a vertical line between the line numbers and the code in a lstlisting. I have experimented with the frame option a lot, but i guess it is not possible this way, if at ...
5
votes
1answer
62 views

Can you specify a word separator for variables in listings?

Depending on the language specified, the listings package may or may not bold keywords inside of variable names. Python is fine \documentclass{article} \usepackage{listings} \begin{document} ...
0
votes
0answers
30 views

Error in tabularx+listings example with TexLive 2014, which compiles in TexLive 2011 (! Missing { inserted)

Consider this MWE: \documentclass{article} \usepackage{trace} \usepackage{tabularx} \usepackage{booktabs} % \toprule etc; \let\botrule\bottomrule % temp hack \newcommand{\tn}{\tabularnewline} % for ...
1
vote
1answer
42 views

how to use verbatim within a list

I tried to use verbatim within a list like this: \begin{lstlisting} Search(HTMLpage, \begin{verbatim}``<TITLE>*</TITLE>''\end{verbatim}); Copy(HTMLpage); Paste(Title); \end{lstlisting} ...
3
votes
1answer
75 views

Should I use \lstinline for the language keywords embedded in text?

When writing about programming languages, there are examples to format as listings. That works fine and produces beautiful results. Sometimes I want to mention the keywords used in the listing further ...
5
votes
1answer
56 views

Can I avoid source formatting with the listings package?

Is there a way to use the listings environment, without resorting to a specific language formatting? (but instead use the usual Latex commands being formatted correctly.) The reason I want to do it ...
0
votes
2answers
70 views

Listing spanning two columns with ieee template

I'm writing an article with the IEEEtran template, which have two columns. I'd like to have a listing with source code that spans the two columns of the article, like in the attached figure. I'm ...
1
vote
3answers
72 views

How to make listings with mathematics notations?

I have a problem about make a listing program and I want make it like this: For my example: \documentclass{article} \usepackage{listing} \usepackage{amsmath} \begin{document} ...
0
votes
1answer
20 views

Script error in latex and appendix subsections

I have two queries; I need to put a 628 line script in Latex which contains special characters(!,_). For example, !M11 is M_theta (moment about meridian(2) axis) but this gives me ERROR: ...
16
votes
1answer
298 views

How can I draw arrows within a listing to explain positional association?

I need nice drawing in lstlisting C/C++ code. I'm trying to make something like this This is what i have made so far \documentclass[11pt]{article} \usepackage{listingsutf8} \usepackage{tikz} ...