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
1answer
51 views

Is it possible to change the language from english to other in lstset?

Generally speaking. Is it possible to change the language from english to other for captions in lstset? If yes, how do I do it? Example of captioned text: \lstinputlisting[language=Matlab,caption={...
0
votes
0answers
36 views

Code environment that supports copy-paste

Is there a LaTeX package that can generate code in PDF file and allow users to copy-paste the generated code? I have tried the lstlisting environment. This is my test code: \documentclass{article} \...
0
votes
1answer
128 views

LaTeX Error: Command \thelstlisting undefined

I'm using book class, and trying to change numbering on listing using \renewcommand\thelstlisting{\arabic{chapter}.\arabic{section}} but im getting this message LaTeX Error: Command \thelstlisting ...
3
votes
1answer
50 views

Add keywords to listings in preamble or lstlang1.sty

Some keywords I want to add I would like to add a few keywords for C, but am having difficulty. The keywords I would like to include are bool, simd, omp, restrict, etc. I would like these to be just ...
0
votes
0answers
43 views

How to include a caption to a Python code snippet

I am using a self-defined command to create an environment for my Python code that I want to show in my document. This command has been taken from redmode's answer to the following question: here. So, ...
5
votes
1answer
3k 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: ...
1
vote
1answer
55 views

How to write SPL in LaTex?

I have searched everywhere for SPl(Search Processing Language) that is used in splunk and I wanted to format my piece of code just like that: I have tried to play with the lstdefinelanguage and ...
1
vote
2answers
30 views

Display three listings side-by-side (consider that the page size might change)

The context I want to display 3 listings side-by-side. I've managed to display 2 listings side-by-side with the following minimal working example \documentclass{article} \usepackage{listings, lipsum} ...
0
votes
1answer
86 views

nice tilde in listings with indent working

I am trying to have a nice tilde when using the listings package Inspired by an answer here: The correct way to type tilde? I tried the following solution: \documentclass{article} \usepackage[T1]{...
5
votes
2answers
126 views

Escaped percent sign is syntax-highlighted as comment by listings package

My code: \documentclass{article} \usepackage{listings} \usepackage{xcolor} \lstset{ language=[latex]tex, basicstyle=\ttfamily, commentstyle=\color{violet}, columns=fullflexible, ...
1
vote
1answer
89 views

Custom styles for minted in Overleaf

So I just moved from listings to minted, as listings had super annoying problems with lines showing up when the background color is set to dark. Minted, on the other hand, is annoying as there doesn't ...
0
votes
0answers
28 views

Ignoring doxygen comments in listings

I have a C project that I am documenting in latex. It features doxygen comments (like those /** bla */ /**< blab */ /// bla blub ///< blubber). I use the listings package to include parts of the ...
0
votes
0answers
15 views

Keeping font spacing in lstlisting and escaped latex

I'm using the following code to highlight in red some C code: \begin{lstlisting}[language=C,basicstyle=\ttfamily\tiny,keywordstyle=\tiny\ttfamily,escapechar=@] struct test { int field1; ...
0
votes
0answers
20 views

Setting text color in lstlisting without using the xcolor package

I want to be able to make custom colors for code contained in lstlisting blocks. The generally recommended solution is to use xcolor, but I tried using that package and it causes a bunch of errors ...
0
votes
0answers
24 views

Change width of \lstlisting resulting from user defined \lstdefinelanguage

I used the \lstdefinelanguage to create a formatting for some JSON blocks I'd like to add to my file, I used the one in the answer for this question: How to improve listings display of JSON files? ...
-1
votes
1answer
38 views

Error with listing and tabular

Here is the code \lstdefinestyle{mystyle}{ frame=single, } \begin{figure*}[tbp!] \begin{center} \begin{tabular}{c} \lstset{style=mystyle} \lstinputlisting[]{...
1
vote
1answer
146 views

Use JetBrains Mono ligatures with fontspec and lstlisting environment

I would like to use JetBrains Mono font in my document, in order to write some code with lstlisting environment. I’m using lualatex and memoir class. I’m using TeX Live 2020 on Windows 10. Is it ...
1
vote
0answers
26 views

Why does ~ from Python file look so weird when imported into Latex? [duplicate]

After inserting a Python file into my latex file via \lstinputlisting[language=Python]{Thesis.py}, I get Normally, it should be ~, but it is at higher than it should be. When I copy it from the ...
2
votes
1answer
35 views

how to put caption below 2 minipage?

I have 2 side-by-side minipages and I would like to put a caption below them. Is there a way to do it? \noindent\begin{minipage}{0.5\textwidth} \begin{lstlisting}[mathescape=true] P -> if (x,y) ...
1
vote
1answer
45 views

How to color matching parenthesis within listings?

What I would like to achieve are rainbow-colored parenthesis (just like Rainbow delimeters in Emacs) based on their depth in a newly defined style for a programming language (Racket). For example: (...
0
votes
0answers
557 views

Command \textminus unavailable in encoding OT1

When I try to compile my document I get the error as in the title. I guess it is related to the Matlab code I submit, but I do not know how to correct this. \documentclass[3p,times]{elsarticle} \...
0
votes
2answers
140 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 ...
1
vote
0answers
34 views

Rendering unicode theta (θ) in lstlisting [duplicate]

I am including some MATLAB code into my main document, using the listings package, which contains a unicode theta (θ). How can I render an actual unicode theta instead of using \theta. Here is a MWE: ...
0
votes
0answers
18 views

Fix code highlight issues with listings

I have a listing styling set up like this but this is just the global styling: \usepackage{listings} \lstset{ %UTF-8 fixes keepspaces=true, %frame frame=l, ...
1
vote
0answers
30 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): \...
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? \...
5
votes
1answer
183 views

How to omit the last n lines from an inline listing?

This is a followup to a question addressing the corresponding issue with listings from external files. The ideal solution would be extending the lastline key to accept negative values and count ...
0
votes
0answers
37 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 ...
11
votes
2answers
14k views

Add another color at other keywords in listings

How can I add another color at other keywords? For example: morekeywordsA={RequirePackage,ProvidesPackage}=\definecolor{keywordsA}{HTML}{8A4A0B} morekeywordsB={{,},=}=\definecolor{keywordsB}{HTML}{...
1
vote
1answer
44 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
30 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
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
34 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
56 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 ...
2
votes
1answer
34 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
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
77 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 ...
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
114 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 ...
9
votes
1answer
3k views

Recent issues with lstlinebgrd package with listings after the latter's update[September 02,2018]

I could run the program without any problem while highlighting few lines of code using listings and lstlinebgrd packages. But the recent update of listings package v1.7 is giving me error even on the ...
2
votes
0answers
36 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
95 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
22 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
29 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 ...
0
votes
0answers
66 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 =...
1
vote
1answer
32 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-...

1
3 4
5
6 7
64