2022 Developer Survey is open! Take survey.

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
0 answers
32 views

Replicate eclipse screen for java code

Hi there is a method to replicate the eclipse screen with keyword colors for a java code like this I tried this but it doesn't work \documentclass[a4paper, 11pt]{article} \usepackage{geometry} ...
user avatar
1 vote
2 answers
32 views

listings does not ignore comment character inside a string

I'm trying to insert a matlab code file in my tex document using listings but the output is messy because I'm using % inside a string with fprintf which is also a comment character. In the line ...
user avatar
  • 21
0 votes
1 answer
33 views

Error with `listings` and `tabularray` used together

I'm in the process of replacing tabular and array environments with tblr in some of my documents. It's already done for dozens of them, with no problem. But I hit a bump with the following MWE: \...
user avatar
  • 802
1 vote
1 answer
19 views

tex4ht does not see listings style using \lstinputlisting[style=style_name]{file}

I am using the code from how to make tex4ht work with listings styles for only basic decoration? (frame and background coloring)? thanks to Michal.h2 which works great except that the style defined ...
user avatar
  • 18k
1 vote
1 answer
32 views

lstlisting stops file from compiling

I'm writing a Latex file. But when I try to add the following code to the file, it just can't compile anymore: \begin{lstlisting}[language=bash,caption={bash version}] btcd --txindex --simnet --...
user avatar
1 vote
1 answer
25 views

Only highlight keyword if surrounded by whitespace

I defined a language as follows: \lstdefinelanguage{Z80}{ sensitive = true, keywords={a, hl, h, l, b, c, e, ix, sp, bc, af, d}, keywords = [2]{push, ld, and, pop, ret, sra, call, sla, cp, jp, ...
user avatar
0 votes
0 answers
29 views

\lstMakeShortInline fails with some characters when luatex-ja and microtype are involved

The following MCE example: \documentclass{article} \usepackage{listings} \usepackage{luatexja-fontspec} \usepackage{microtype} \lstMakeShortInline! \begin{document} Foo !\foo! \fontspec{Latin Modern ...
user avatar
1 vote
0 answers
46 views

Space before the "?", normally unbreakable with babel-french, breakable with listings' breaklines option

With babel-french, the space before the question mark is normally unbreakable. But, as shown by the MWE below (compiled with pdflatex, xelatex or lualatex), the breaklines option of the listings ...
user avatar
0 votes
1 answer
22 views

How to use two styles for the same listings language?

At the moment I have two global options defined for my listings language: color and monochrome (I have bundled the language as a package and so these are package options). However, now I find that I ...
user avatar
  • 269
0 votes
0 answers
19 views

autoref figure labels in tufte-book

This seems to be an issue with tufte-book figure labeling but I'm not sure whether it's something I can work around. \documentclass{tufte-book} \usepackage{listings}\lstloadlanguages{C} \usepackage{...
user avatar
0 votes
1 answer
25 views

How can I remove extra white space of a caption when listing wrap inside a figure?

I want to wrap listing inside a figure. But when I do that there is plent white space in between its caption. How can I remove extra white space of Figure's caption when listing wrap inside a figure? ...
user avatar
  • 402
0 votes
0 answers
22 views

nested use of listing options

The following code which is built by the lstlisting environment from the package listings, in my view, should typeset the text "aaa" with color red, but the real typeset remains black. I ...
user avatar
  • 2,213
0 votes
1 answer
42 views

Syntax highlighting of numeric literals with the listings package

I'm working on a document that contains a lot of python code snippets, many of which have numeric literals in them. For example, something like: var_a = 3 var_b = 20000 var_c = 1.75e12 var_d = 0.1415 ...
user avatar
0 votes
1 answer
36 views

Blank space after equal-sign in Python-Code-Section of LaTeX-Dokument-PDF by using packages "listings" and "pythonhighlight"

Does anybody know how to set the packages "listings" and "pythonhighlight" for displaying one blank space before (this already works) and after an "=" (and maybe other ...
user avatar
  • 3
1 vote
0 answers
48 views

<replace> of “literate” option still on in tcblisting environment of tcolorbox

I set @ and | as <replace> of the literate option(from the package listings), and use it in tcblisting(from tocolorbox). They work all right except that in the text part of tcblisting, @ and | ...
user avatar
  • 2,213
1 vote
0 answers
28 views

Changing the color of numbers and special words in listings for a Python snippet

I'm using the listings package to write a report where I report some code in Python that I used. I am not very familiar with listings and am having several problems. Specifically: I would like to ...
user avatar
1 vote
1 answer
29 views

listings lstdefinestyle not work with custom defined command

I defined a new command named '\showLineNo', and used in '\lstdefinestyle', got an error: Package Listings Error: Numbers none unknown. \lstset{style=customstyleone} sample code: \documentclass{...
user avatar
0 votes
0 answers
28 views

emphstyle in listings

The following code comes from the manuel of package listings in which I add a "backslash" before "square" and "\color{red}" before "\underbar" in the first ...
user avatar
  • 2,213
0 votes
1 answer
43 views

How to render a long code listing in multiple pages with the package minted?

I'm using the package minted for formatting code in my paper. The package minted provides a "listing" environment, which treats the code inside it as a float. It works very well under most ...
user avatar
1 vote
1 answer
23 views

Strange Autoref Countering of lstlisting

I made a new listtype called mycodes and want to autoref to them. The problem is, when using autoref to a lstlisting-block the number of the listing is wrong! The code \documentclass[]{article} \...
user avatar
  • 55
0 votes
0 answers
60 views
+50

How to write Octave code on LaTeX?

Here is an exemple of code I would like to write: clear all; close all; clc; X = Y = 0:0.1:1; for i=1:length(X) for j=1:length(Y) Z(i, j) = X(i) + Y(j); endfor endfor mesh(Y, X, Z) The ...
user avatar
0 votes
0 answers
22 views

Page break in LaTeX only if a code block is split between pages

I'm writing a report in LaTeX that contains several code blocks of varying sizes. For example, a code block might be: \begin{lstlisting}[language=Python] dic = { "qwe": 0.2, ...
user avatar
0 votes
0 answers
22 views

Increasing `minted` spacing

I've been switching my code environments from lstlistings to minted. However, in the process of switching, I noticed that all minted environments used smaller spacing between characters (the font ...
user avatar
  • 1
3 votes
2 answers
86 views

Listings Inside Macro

I am trying to figure out a way to have a macro where I demonstrate the output of a command then show the command via a lstinline command. I have read that I need to escape out the special char's (...
user avatar
  • 79
1 vote
1 answer
33 views

KOMA-script list of listings and LOF have unequal space below heading

I observed some unexpected behaviour with scrbook class (xelatex) and the list of listings from the listings package. The spacing between the chapter headings of the LOF and list of listings and the ...
user avatar
0 votes
0 answers
19 views

Listings Misses Coloring Words

I am trying to use \lstinputlisting to include a .tex file. When I use the \lstinputlisting to do it, the \includegraphics is not colored, however, when I use \lstinline with \includegraphics, it is ...
user avatar
  • 79
0 votes
0 answers
50 views

Markdown -> Latex -> PDF: md inline code snippets going out of page bounds

Problem I have a bunch of changelog.md files for our software that use backticks for inline code. I pull them as part of the documentation build process and compile a PDF with latex. Latex seems ...
user avatar
  • 75
0 votes
1 answer
16 views

Figure and Listings Produce Extra Page Break

I am trying to include a tex file directly after a figure environment. When I do, the listings ends up being on the next page even though a large amount of space exist on the previous page. How do I ...
user avatar
  • 79
0 votes
0 answers
20 views

Listings custom comments: End comment at new line

I'm trying to create a custom style in listings for Silvaco decks. In Silvaco any variable that starts with $ is highlighted. I have implemented it so far with a start delimiter of $ and an ending ...
user avatar
0 votes
0 answers
19 views

How to configure listings to escape curly brackets and variables in an interpolated string?

I want to make curly brackets white and variables (for example age) cyan in interpolated strings (for example $"I am {age} years old."). The following is not what I want because {age} in the ...
user avatar
0 votes
0 answers
27 views

Two vertical aligned minipages are horizontally shifted

I want to align two listings next to each other using minipages. Unfortuanately the right minipage is shifted a little bit to the bottom. What's the problem here? \documentclass[11pt,fleqn,a4paper,...
user avatar
1 vote
1 answer
52 views

how to make tex4ht work with listings styles for only basic decoration? (frame and background coloring)?

This is tex4ht only issue. There is a good answer in How to add frame and background color with listing when used with text4ht That shows how to make tex4ht put frame and background color when using ...
user avatar
  • 18k
0 votes
1 answer
46 views

Greek characters in Julia embedded code

I have a problem regarding jlcode package. The package documentation can be found here: https://github.com/m3g/jlcode_example/blob/master/jlcode.sty I have modified the default color theme to match my ...
user avatar
0 votes
0 answers
24 views

How can use verbatim-like command as \section Argument defining with tcolorbox package

In below code, I cann't use \mybox command in \section, how can I fixed that? \documentclass{book} \usepackage{amsmath,amsfonts,amssymb,amsthm} \usepackage{tcolorbox} \tcbuselibrary{listings,skins,...
user avatar
  • 343
3 votes
1 answer
51 views

listings: highlight LaTeX2e and expl3 code with separate colors

I'm planning to write new documentations for my packages, and in particular, this time I wish to improvement the code displaying. Below is the code I'm currently using for code highlighting. To ...
user avatar
  • 4,829
0 votes
3 answers
63 views

How can I use command in upper part of \tcolorbox environment, like \underline

How can I use \underline command for upper part of \tcolorbox, and underline all text in upper part? I test before upper=\uline{, after upper=}, or before upper=\underline{, after upper=}, but not ...
user avatar
  • 343
0 votes
1 answer
32 views

Why does the option fontupper not work in tcblisting of tcolorbox?

Please see the following MWE for my queries. Thank you. MWE: \documentclass[a4paper]{article} \usepackage{tcolorbox} \usepackage{geometry,tcolorbox} \geometry{showframe} \geometry{left=1cm,right=1cm,...
user avatar
  • 2,213
3 votes
1 answer
79 views

How to add frame and background color with listing when used with text4ht

This issue is only for tex4ht. I want to move all my code formatting away from using a Javascript package I am now using, and to use listings instead. As is known, listings package works as is with ...
user avatar
  • 18k
0 votes
1 answer
32 views

The tcblisting enviroment dosen't work when using it to build a macro

I want to build a macro with the tcblisting enviroment from tcolorbox, as shown below, but fail. What's the reason and how to deal with this? Code: \documentclass[a4paper]{article} \usepackage{...
user avatar
  • 2,213
0 votes
0 answers
35 views

how sensitive comment part of \newtcblisting to \lstdefinelanguage?

How can sensitive comment part (lower part) of code environment to \lstdefinelanguage Maple as upper part? \documentclass{book} \usepackage{tcolorbox} \tcbuselibrary{listings,skins,theorems} \...
user avatar
  • 343
0 votes
1 answer
76 views

Want to style LaTex code, in my lstlistings

in the manual of the command of the listing package, "LaTex" is one of the predefined languages. I know it may sounds confusing but I want to write my Latex code with the \ and everything (...
user avatar
  • 3
0 votes
1 answer
35 views

How to allow pagebreak with minipage or a code block?

I want to a code block (with two columns) can continue to bottom the empty of the frist page, and last to the top of next page, how to ? The code block with two columns, I rendered with minipage, but ...
user avatar
  • 407
0 votes
1 answer
27 views

Typeset python setter decorators with the listing package

I'm using the listing package to include my source files (Python) in my documentation but I'm having an issue with highlighting the setter decorators. Decorators such as @property or @dataclass are ...
user avatar
  • 329
1 vote
1 answer
17 views

How to remove the word Listing from the caption of the code and write it below the code?

How to remove the word "Listing" from my TeX file? Consider the following code: \documentclass[12pt,a4paper]{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{amsmath}...
user avatar
  • 933
2 votes
2 answers
51 views

How to get the desired output with proper alignment?

How to write a c++ code in LaTeX with proper alignment? I am providing more details about my question below: I need to write this: if(a==b): a=2 b=2 I need to write this above code in ...
user avatar
  • 933
0 votes
1 answer
17 views

Listing background color is overflowing margins on broken lines

I'm using the code on Listing, zebra effect and broken lines as a base. However, when lines are indented by either spaces or tabs the margins of the listing are not respected and the background color ...
user avatar
  • 51
0 votes
1 answer
41 views

Disable LaTeX interpreting my Source File

In my Latex file: \lstinputlisting[caption={Pascal Quellcode HashFunctionsTest.pas}]{../source/HashFunctions.pas} Error: [{ "owner": "LaTeX", "severity": 8, &...
user avatar
1 vote
1 answer
33 views

Referencing a listing and getting two question marks

I'm using TexShop 4.69 and I'm using lstlistings. But now after inserting my 3rd lstlisting, I can't get an adequate reference number. I'm receiving now two “??" in my text. Can somebody please ...
user avatar
  • 81
0 votes
1 answer
42 views

Removing extra vertical padding from minted/listings code snippet

I have some extra vertical space in my listings/minted code snippet that I can't figure out how to get rid of (especially the bottom). The code originally came from this answer. I have read the ...
user avatar
2 votes
1 answer
38 views

Uneven margins above and below lstlisting

The output from the code below looks wrong to me. I am trying to add padding around my listings, but I want the margins to be as thin as possible, preferably matching the space between consecutive ...
user avatar

1
2 3 4 5
69