Questions tagged [listings]

{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.

Filter by
Sorted by
Tagged with
0
votes
0answers
38 views

Some characters have strange behaviour in listings with lualatex

The following MCE points out that some characters (for instance €, → or ←) have strange behavior (shifted on the left) in listings with lualatex (up to date TeX Live 2020). Do you know why? \...
0
votes
0answers
36 views

Don't recognize text as keyword if it's surrounded by double quotes

I'm trying to define language formatting for C#, but I'm having a problem. While it works fine for the most part, I don't want text that is in quotes to be characterized as keywords. Here's my ...
1
vote
0answers
28 views

Add style to pseudo-class keywords in CSS with listings

Problem: Adding specific color to pseudo-class keywords in CSS using listings. For example, the pseudo-classes :link, :visited, etc should be colored differently. Minimal Working Example (MWE): \...
1
vote
1answer
42 views

Not all UTF8 symbols work in lstlistings

I am on Linux and I have this document that I compile using xelatex main.tex: \documentclass[12pt]{article} \usepackage{color} \usepackage{xcolor} \definecolor{code_linenumbers_b}{RGB}{215,215,...
0
votes
1answer
29 views

Listings Keyword Can't Be Removed

I have the following sample of code. \begin{lstlisting}[ language=SQL, showspaces=false, basicstyle=\ttfamily, numbers=left, numberstyle=\tiny, commentstyle=\...
0
votes
0answers
20 views

latex/listings extend/add to a literate rule

I was looking at this question here Listings: syntax for literate but when I try the mew of the solution, it crashes if I insert special characters like the German ä. Since these should be escaped by ...
0
votes
0answers
29 views

assembler, highlight labels

I'm having trouble to activate some highlighting for labels set in assembler. I use the definition language=[x86masm]Assembler but I don't get how to get all labels (indefinite whitespace in front, ...
0
votes
0answers
13 views

Why does Lstlisting show me this ugly characters for each tabular?

I am using beamer to create my presentation and wanted to include some code in one slide. I added the \begin{frame}[fragile] and these are my options: \lstset{ breakatwhitespace=false, ...
1
vote
1answer
32 views

Combining linerange, firstnumber and consecutivenumbers leads to non-consecutive numbers

If I use linerange, firstnumber and consecutivenumbers with line markers it results in non-consecutive line numbers. MWE: \documentclass[a4paper]{article} \usepackage{listings} \begin{filecontents}{...
0
votes
0answers
17 views

Displaying errors when writing code using listings package

I'm trying to write code using this that I found on Google: \usepackage{listings} \usepackage{color} %red, green, blue, yellow, cyan, magenta, black, white \definecolor{mygreen}{RGB}{28,172,0} % ...
2
votes
1answer
31 views

Reduce vertical space between the caption and a two-column code listing

Any suggestion about how to reduce the vertical space between the bottom line of the caption and the code? Thanks in advance, Humberto Here is my current code \documentclass{article} \usepackage[...
0
votes
0answers
51 views

Overfull hbox when centering lstlisting (using tabular)

I would like to center code listings when they are narrower than the full page, but wrap them when they are not. I am using a table to do so, following the advice from this answer. As breaklines is ...
0
votes
0answers
15 views

How doing line breaks in \lstinlines?

\documentclass[12pt,a4paper]{scrartcl} % scrartcl ist eine abgeleitete Artikel-Klasse im Koma-Skript % zur Kontrolle des Umbruchs Klassenoption draft verwenden % die folgenden Packete erlauben den ...
2
votes
1answer
109 views

How do I make listing from “Listing 1:” to “1. listing.”

Now, by default listing package produces listing names like: Listing 1: some text How do I make it to produce names like: 1 listing. Some text Package: \usepackage{listings} I guess it should ...
2
votes
1answer
64 views

Combining lstinline escapes with a macro

I tried to use the escapechar option with lstinline. In order to "activate it", I used the approach described here. However, when using it within a macro, it breaks. This is shown below. Is there a ...
2
votes
0answers
35 views

How to get zebra effect in ‘listings’? (‘listlinebgrd’ seems broken with recent ‘listings’ update)

I have just install TeXlive 2020 listings have been changed and so lstlinebgrd seem not work. How can we get back the beautiful zebra effect? \documentclass[12pt,a4paper]{article} \usepackage{...
0
votes
1answer
75 views

Putting purple color to MATLAB font and code structure [duplicate]

I have this MATLAB code: After sysms the variables turn purple and I cannot make that in the MATLAB script I have in Latex: \documentclass{article} \usepackage[T1]{fontenc} \usepackage{bigfoot} % ...
0
votes
0answers
19 views

Move lstlisting to the left instead of center?

I have a lstlisting and it always appear at the horizontal center. How can I change this positioning such that it begins at the left like the rest of my text out lstlisting environment?
0
votes
0answers
12 views

lstlisting long line wrapping [duplicate]

I would like to wrap "2cf24dba5fb0a30e26e83b2ac59e29e1b161e5c1fa7425e73043362938b9824" into the frame of lstlisting. \documentclass[conference]{IEEEtran} \usepackage{xcolor} \usepackage{amsmath} \...
0
votes
0answers
48 views

listing with tcblisting of tcolorbox package and indexing with listings package conflict?

Accidentally I got what I wanted in terms of rendering but the code produced an error. On the other hand, removing the error in the code makes the expected color rendering of the keywords and C ...
1
vote
0answers
18 views

Matlab's script losing identation when pdf is generated. How can i solve it?

i am new in all this Latex stuff, but i am trying to learn. Currently i am stuck in a problem: display a Matlab code. This is my code in TexStudio: \documentclass[12pt]{article} \usepackage[margin =...
0
votes
0answers
25 views

lstinputlisting unable to find file if path includes dots but does not have an extension in some Linux distributions but not others

I am preparing a document using, rotating between Arch, Manjaro, openSUSE Tumbleweed, and Kubuntu. In Manjaro and Ubuntu, I am getting a listings package error in that the file specified is not able ...
1
vote
1answer
31 views

Change color of numbers in listing environment

How to change the color of the numbers in the python code block to blue, but at the same time leave the numbers in the comment block green? Also, for the keyword network3. How to just change that ...
0
votes
0answers
25 views

Cannot get minted and beamer to work together in MikTex [duplicate]

Edit: This was solved by changing \begin{frame} to \begin{frame}[fragile] as suggested by @ulrike-fischer. Here is a detailed answer: https://pbelmans.ncag.info/blog/2011/02/20/why-latex-beamer-needs-...
2
votes
1answer
38 views

lstlisting space symbol problem in R code

I am using the package listings. I was writing some code of R in LaTeX. I followed the suggestions from @Alan Munn by using showstringspaces=false \documentclass{article} \usepackage[svgnames]{...
0
votes
2answers
137 views

Make `llap` respect bottom margin

I'm using \llap in a custom environment to write some text in the document left margin, aligned with a code listing (code listing is done using lstlisting). Whenever the code listing is at the bottom ...
0
votes
0answers
14 views

listings changes the order of characters in a line of code [duplicate]

This is my minimum example \documentclass[a4paper, 10pt]{article} \usepackage{listings} \begin{document} \begin{lstlisting} loads = {'-g·M·e·(Σsines),'; 'wind-like·half-sine,'}; \end{lstlisting} \end{...
0
votes
0answers
15 views

lstlisting put '~' at the top of the line [duplicate]

I use the package listings to add code snippet in my document. my problem is for the character ~. It's placed at the top of the line, like if it was above a letter, while I want it at the middle of ...
0
votes
1answer
87 views

Russian language in lstlisting

I am using LaTeX on overleaf.com and trying to use russian language in code, but the compiler gives an error "Invalid UTF-8 byte sequence". I can use russian text freely out of code scopes. My LaTeX ...
0
votes
1answer
22 views

Conflict of between powerdot and listings packages

Please see my previous question: Conflict of \item indexes and \onslide in powerdot Playing with powerdot presentations, I realized one more awkward behavior. When listings package is in effect, \...
1
vote
0answers
22 views

How can I set line stretch inside lstlistings for displaying code?

I have a long document and I set a different spacing like this: \usepackage{setspace} \renewcommand{\baselinestretch}{1.5} This stretching also applies inside my lstlisting, but I would like to ...
0
votes
0answers
45 views

Why is the color in the PDF different from the one defined in LaTex file?

I've found this template to insert Python code in which the background color is very ease to my eyes: \documentclass[12pt]{article} \usepackage[left = 1in, right = 1in, top = 1in, bottom = 1in]{...
0
votes
0answers
20 views

lstlisting diables autocorrect after usage

I noticed this bug in TexStudio (Been meaning to move to Vim, maybe one day...) where using a lstlisting environment for my code disables any future autocorrect. It also disables all TexStudio ...
0
votes
0answers
33 views

Listings: Package keyval Error: consecutivenumbers

The following MWE, taken straight from the listings documentation, produces the error Package keyval Error: consecutivenumbers undefined. \documentclass{article} \usepackage{listings} \lstset{ ...
0
votes
0answers
20 views

How to specify listing position to start in the top of the page or new paragraph?

I use listings package to add some code snippet. I input the code from files using \lstinputlisting. Some codes are long so the listing starts at one page, then continue to the next page. I am fine ...
0
votes
0answers
77 views

Including 'pythonhighlight' package creates error

I would like to include the 'pythonhighlight' package in an book I'm writing. This is the code that creates the included error: \documentclass{article} \usepackage{pythonhighlight} \begin{document} \...
1
vote
0answers
864 views

undefined control sequence <argument> \textminus in listing

I tried to insert python code in my LaTeX document for a project of mine. For this, I used the listings package. For some reason unknown to me, a minus sign in my python code throws an !undefined ...
2
votes
1answer
30 views

Change the text style of references to line numbers in listings

Consider the following document: % Document \documentclass[10pt]{article} % Packages \usepackage{lipsum} \usepackage{xcolor} \usepackage{listings} \usepackage[ colorlinks, citecolor = blue, ...
0
votes
0answers
55 views

LyX error when using lstlisting

I am trying to insert a listing in LyX in an enumeration ("\item ..."). My document is in French, with UTF8-encoding for the accents. However, when I click on the button "Program listing" in the ...
2
votes
1answer
41 views

Working with \lstlistoflistings in the apa6 documentclass

I would like to insert a List of Listings including the section number in my Table of Contents. The listings documentation is not sufficient to solve this problem. I am using the apa6 documentclass, ...
0
votes
0answers
63 views

How to break line with colorbox inside a new command

I created a lstdefinelanguage for diff language. For each type of sentence, I want to color background in a different colour. To do this, I created a new command: \newcommand{\lstbg}[3][0pt]{{\...
0
votes
1answer
310 views

How to colour columns of an SQL query in Latex Listings package?

I am trying to find out how to define a style (or at least just a colour) on columns of an SQL query in the same way of the keywords style in the listings package. An example of the code can be found ...
0
votes
0answers
22 views

Up Arrow not showing in listingsutf8

% arara: lualatex: { synctex: yes, shell: yes } % arara: biber % arara: lualatex: { synctex: yes, shell: yes } if changed('bbl') % arara: lualatex: { synctex: yes, shell: yes } if changed('toc') \...
0
votes
0answers
141 views

How can I write ASM and C listings and look like as MPLAB shows?

I'm writing a report on latex and I find difficult to set a language style for ASM e C language. I would like to set like as shows on MPLAB (see the photo). The actual code doesn't work so well. So I'...
0
votes
1answer
67 views

LaTeX listings - how to apply a style to delimiters different from the content

How do I modify the key-value option \lstdefinelanguage{mybnf}{ morestring = [b]'' } To obtain the following result: that is, to be able to have the delimiters defined in a different style (in ...
0
votes
1answer
43 views

LstListing caption number setting

I am using \package{lstlisting} to display some matlab code in the latex. My codes are placed in the appendix with labels. Given below is excerpt of my code: % block of codes \clearpage \appendix ...
0
votes
1answer
62 views

How to get the image and code in showexpl package separate and break the code to new page when ended page?

In listings and showexpl package, my problem is the code is go over the page and one another problem is that how can the image and the code be seperate that the image in previous page and the code in ...
0
votes
1answer
26 views

File not found using lstinputlisting with variable as argument

Trying to create a new environment using lstnewenvironment to list code in a document. Sometimes the contents of this environment are typed directly in the tex file, sometimes they come from external ...
0
votes
0answers
57 views

Environment listings undefined

I am new to Latex and trying to use Listings in Overleaf for a conference paper. I have to use LNCS format, so I have imported its template to overleaf. The reason I am using Listings and not ...
1
vote
1answer
31 views

Unicode characters misplaced within lstlistings environment

I am compiling with XeLaTex. Within the lstlistings environment (provided by the listings package), special unicode characters appear to be misplaced. This is a minimal demonstration. Code: \...

1 2 3
4
5
64