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
1
vote
2answers
89 views

How to display $ in listings Latex

I need to write three different programming languages: C#, R and TensorFlow. TensorFlow has the keyword tf$ and i would like to have it as keyword in my latex file, but i have got an error. \...
0
votes
1answer
37 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, \...
0
votes
1answer
22 views

Add dot after number of listing in list of listings

Hello does some of you know how to add leading dot after listing number in list of listings? Im using listings package and \lstlistoflistings command. Im using tocloft package to do it in list of ...
0
votes
1answer
8 views

Text alignment in a \sortedlist environment

I'm using the following command : \documentclass[10pt]{report} \usepackage{datatool} \usepackage{enumerate} \newcommand{\sortitem}[2]{% \DTLnewrow{list}% \DTLnewdbentry{list}{label}{#1}% \...
2
votes
1answer
52 views

listings and danish special chars does not work together

In the small document listed below, I try to include some danish special chars in a lstlisting environment, but that does not work. However it works fine in the verbatim environment. I use the ...
8
votes
1answer
169 views

Highlight numbers using listings package

The problem: Is it possible to highlight all the numbers inside a lstenvironment except the numbers in comments, strings or variable names? Example of expected output (Python in Google Colaboratory): ...
48
votes
5answers
2k views

Has the time come for a LaTeX3 successor to 'listings'?

I'm currently looking for a nice and challenging open-source project to work/collaborate on after my thesis. I don't have a Comp. Sci. background, but I'd like to learn more about compiler ...
0
votes
0answers
13 views

Unexpected linebreak in lstlisting environment

The Situation: I'm importing a piece of Code into the document via \lstinputlisting[language=custom]. The Code is formatted in a way, that there are 80 characters in a single line at maximum, so I ...
2
votes
0answers
86 views

Code highlight in ltxdoc documentation

I wish to add LaTeX code highlight in a package documentation. Usually I use the following code to highlight LaTeX code (copied from classicthesis documentation): \usepackage{listings} \definecolor{...
3
votes
1answer
44 views

How to import text from a text file “AS IS” and justify it?

I would like to import text from a .txt file as is, and have it be automatically wrapped and justified. What I have done so far: \documentclass{article}% \usepackage{listings} \begin{document} \lstset{...
0
votes
1answer
30 views

How to add # in emph in lstlisting package?

my current lstlisting package format is provided below. I am not sure why but the # is not displayed as blue but rather as golden. I wish to make it displayed as the colour that is specified in ...
1
vote
1answer
69 views

How can I manually add italics or underlines to code listings using minted?

I'm a new user of minted, and I have a LaTeX fragment that looks like this: \begin{minted}{python} `s` = input(`prompt`) \end{minted} I was previously using the listings package: \begin{lstlisting} `...
113
votes
2answers
200k views

How to change font size for specific lstlisting

I have a java lstlisting and it is too big and does not mach a single page. Is there any way to specify font for specific listing, not all listings in document?
2
votes
1answer
26 views

Problem with listing numbering in caption

When I want to put a simple caption to my listing, tex puts the number of the subheading to the listing and not the actual listing number. \begin{lstlisting}[language=Python, caption=Listing 1: ...
2
votes
1answer
167 views

Multicol listings and ntheorem rendering wrong

Given the quite long MWE: \documentclass{memoir} \usepackage[dvipsnames,table]{xcolor} %\usepackage[showframe]{geometry} \usepackage{mathtools} \usepackage{needspace} \usepackage{multido} \usepackage{...
1
vote
0answers
25 views

How can color of a default parameter in call, be changed like PyCharm?

I am working on a document that contains some Python codes. I use the following template in Overleaf. \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{listings} \usepackage{xcolor} %...
1
vote
2answers
52 views

listings comment style not applied on language operators

I'm using the listings package to typeset some Haskell and Scala code in my document, and I've defined a simple style named ttt. I set comments to be displayed in red for contrast, but the problem ...
3
votes
1answer
190 views

How to scale horizontally every character in listings code?

I want to scale horizuntally every character in listings code, making it narrower. The basewidth option is not what I want, since it doesn't scale characters. Any way to achieve this? \documentclass{...
0
votes
1answer
191 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
17 views

lstlisting url broken by line wrapping

I have a URL which get's broken by the line break. Ideally I'd like it to be possible to copy the whole wget command and paste it into a terminal. Unfortunately I am ending with an overflowing box and ...
0
votes
0answers
20 views

Is it possible to use \lstdefinestyle (listings package) whith language=latex inside?

Using this setup: \usepackage[utf8]{inputenc} \usepackage{amsmath} \usepackage{xcolor} \pagecolor[rgb]{0,0,0} %black, you can reset to white setting all values to 1 \color[rgb]{0.8,0.8, 0.8} % set ...
0
votes
0answers
31 views

Listings doesn't highlight everything

I'm having an issue with a custom \listings enviroment: \begin{document} \lstdefinestyle{mystyle}{ backgroundcolor=\color{backcolour}, commentstyle=\color{codegreen}, numberstyle=\tiny\...
0
votes
1answer
50 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 ...
1
vote
1answer
22 views

Allow page breaks inside figures

I am currently writing a paper that has lots of code snippets in it, which I would like to treat as figures. Because the examples can be very long it would be convenient to allow page breaks inside of ...
0
votes
0answers
24 views

How to make two different environments next to each other?

I wrote a piece of code in the listing form. Then I want to put its running result graph below this code. But in Latex, although I write them next to each other, sometimes they are distributed on ...
39
votes
5answers
24k views

\autoref does not capitalize initial character in sentence when referencing label in listings environment

I have defined the following \providecommand*{\lstnumberautorefname}{line} and within my text \begin{lstlisting} |\label{sdd_1}|<sqlCallStatistics>YES</sqlCallStatistics> \...
1
vote
1answer
17 views

Use the nomencl and listing packages to include a command summary

I am writing a document related to computer science and I want to include a short summary of the commands that appear through the text at the end. I am using the listing package to handle the code and ...
91
votes
4answers
151k views

How to highlight Python syntax in LaTeX Listings \lstinputlistings command

I am using package listings to import my Python source code into my LaTeX document. I use the command \lstinputlistings. I have a Python source like class MyClass(Yourclass): def __init__(self, ...
1
vote
1answer
157 views

How do I customize Circuit_macros in listings?

MWE: \documentclass{article} \usepackage{xcolor} \usepackage{listings} \definecolor{Others}{RGB}{0,110,40} % Green \definecolor{Character}{RGB}{146,76,157} % Purple \definecolor{Number}{RGB}{176,...
0
votes
0answers
15 views

Broken dash output in listings (noto font)

I'm trying to use the "noto-sans" font found in the LaTeX Font Catalog, unfortunately each dash (-) produces a tombstone (▯) as output. Here is an MWE: %!TEX program = xelatex \documentclass{...
0
votes
1answer
93 views

How can I add code highlighting for listings with different colour lines?

How can I create a listing design in LaTeX, with numbers on the left, and each line separated with colours like in the picture? I could not find such listing style for LaTeX.
5
votes
2answers
108 views

Annotate listing with overlays

I'd like to visually divide a listing containing a hex dump into regions and provide a label for them. Here's what I got so far: The code for this uses tcolorbox for the overlays and textpos to make ...
1
vote
1answer
25 views

Class memoir Error: listing is not a counter

I am trying to use \counterwithout{listing}{chapter} Chngcntr: \counterwithout not working Number listings the same way as figures and tables But memoir keeps complaining Class memoir Error: listing ...
0
votes
1answer
35 views

Listings define language in a separate file

I'm currently working on a paper where I want to showcase some JavaScript code snippets. I am using the listing package and defined JavaScript with \lstdefinelanguage. Since the command with its ...
0
votes
1answer
46 views

MATLAB script with accented characters does not work correctly with UTF-8 listing

I am truly desperate. I need accented characters in the MATLAB script. I wouldn't mind with comments, but accents are also in Figures, which does actually matter. Both .tex file and .m file are saved ...
1
vote
2answers
39 views

Why error is coming when using listings in polyglossia package?

The complete file is here. MWE: \documentclass[11pt,fancy,authoryear,twoside]{elegantbook} %-------------------------------------------------- %Bengali Font in Document %--------------------------...
1
vote
1answer
19 views

Styling lstinline separately from listings in preamble?

I use pandoc, so I'm a bit limited in the tex hacks I can apply. However, here is an example: I have this document, test.md, in pandoc Markdown: --- listings: true # see also https://stackoverflow....
0
votes
1answer
24 views

Package `listings`: add counter to custom-defined language

I am using the listings package to include some Julia code, however the Julia language is not yet supported by the listings package. As a result I had to make my own (basic) set of rules, inspired by ...
0
votes
1answer
48 views

Break longer word into lines to fit the box (inputminted?)

I would like to fit the long string (as it is labelled url in the json file) inside the box without overflowing. As far as I understand, breaklines option only helps when strings consist of separated ...
3
votes
1answer
49 views

How to put lstlisting in a minipage

I had a problem creating a new environment that would let me put a lstlisting inside a minipage. I could create a new environment that sets up the minipage, then in the document put a lstlisting ...
0
votes
0answers
20 views

Problem with listings and overset

I don't understand why listings doesn't render the overset well. \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{graphicx} \usepackage{listings} \usepackage{xcolor} \usepackage{amsmath,...
0
votes
1answer
87 views

Priority of page breaks between paragraphs in beamer slides with allowframebreaks

I have breamer slides with allowframebreaks which have some basic structure, e.g.: \begin{frame}[fragile,allowframebreaks]{Title} some text... \begin{itemize}...\end{itemize} other text \begin{...
2
votes
1answer
27 views

Flatfile comma and semicolon hightlight in lstlisting?

How do I create a lstlisting language handling Comman and Semicolon separated list. Would like to highlight the keywords "STOP, START, ATTEMPT" as well as ", , :" (actual comma and ...
2
votes
1answer
71 views

Strange result with package listings when a string literal presents

I'm using package listings to add code in a document. Almost everything works pretty well, until I write a string literal like this: \documentclass{article} \usepackage{listings} \begin{document} { \...
6
votes
1answer
187 views

How can I use the lstsample environment (lstdoc package) in article?

I would like to try the lstsample environment from the lstdoc package, distributed with the listings package. For that I have written the following document: \documentclass{article} \usepackage{...
0
votes
0answers
33 views

lstlisting error: Package inputenc Error: Invalid UTF-8 byte sequence

I am writing code with: \begin{lstlisting} \end{lstlisting} and \lstset{language=Matlab,% %basicstyle=\color{red}, breaklines=true,% morekeywords={matlab2tikz}, keywordstyle=\color{...
7
votes
1answer
338 views

How can I test the first character on each line of a listing?

The listings package defines a hook called EveryLine to allow users to execute TeX code at the beginning of each line of a listing; the following is taken directly from the listings source code (...
2
votes
1answer
709 views

listings: How to Annotate a Matlab Listing (Matlab Code) (curly brackets, arrows, text)

I have a matlab code and I want explain part of them like picture. or any other idea can do better. \documentclass{article} \usepackage{listings} \usepackage{color} %red, green, blue, yellow, cyan, ...
1
vote
1answer
27 views

Reduce space between multiple minted inputs in a single listing

I've created a listing with multiple code blocks using the \inputminted command And want to reduce the space between the blocks. A minimal working example is given here: \documentclass[11pt,oneside]{...
1
vote
0answers
18 views

Invalid numbers and output on listing when using linerange on lstinputlisting

I'm trying to use linerange inside a lstinputlisting. The command is able to read the file but omitts the content of the first line. I would expect if I use the following code to see the last line of ...

1
2 3 4 5
65