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

Customizing the location of a caption on a lstlisting?

I'm working on some code listings and would like to have my caption be top-left aligned with the file name (optionally) in brackets. The default settings appear to center the caption, and I can't find ...
TheProgrammer's user avatar
1 vote
1 answer
34 views

cref on lslisting elements only translates to two questionmarks and the index of the element

I am rather new to working with LaTeX and so far I have not found the solution to following problem: Using \cref or \Cref gives me the desired output whenever I use it with tables or figures. When I ...
K Hil's user avatar
  • 13
0 votes
1 answer
45 views

LyX, listings, cannot get return to the line in the last part of a code [closed]

Reformulation: I am starting from the Julia code as follows (in VS-Code): fout = open("harmoniques-spheriques_l3_m1.dat","w") for θ in 0.00:0.02:6.50 for φ in 0.00:0.02:6.50 ...
Aquarelle332's user avatar
0 votes
0 answers
51 views

Spacing for typewriter font looks off without fulflexing option in lstlisting [duplicate]

I'm trying to get the spacing and font to look clean in my lstlisting output window. Right now, if I enable the columns=fullflexible option, it makes the font truly monospaced and it perfectly aligns ...
TheProgrammer's user avatar
0 votes
1 answer
84 views

Using .\ inside lstlisting causes issues crashes

I want to produce MATLAB prettified code with MATLAB code. Using .\ causes error. alsoletter={.\\} in \lstdefinestyle does not seem to work \documentclass[aspectratio=169, xcolor={x11names}, t, ...
Al-Motasem Aldaoudeyeh's user avatar
0 votes
0 answers
39 views

Using .\ inside tikzpicture causes issues crashes

I want to produce MATLAB prettified code with MATLAB code highlighted with tikz background. The environment itself works. Using .\ causes error. alsoletter={.\\} in \lstdefinestyle does not seem to ...
Al-Motasem Aldaoudeyeh's user avatar
1 vote
1 answer
34 views

How to get listings to identify \ as letter?

With listings, it is possible to identify \\ as letter using the following literate entry {\\\\}{{\textcolor{IndianRed1}{\textbackslash{}\textbackslash{}}}}{1} However, I want to do the same thing ...
Al-Motasem Aldaoudeyeh's user avatar
1 vote
1 answer
52 views

Amsbook + Paracol pagebreak broken with mdframed

I am trying to typeset some code and some commentary side-by-side using paracol and listings with the amsbook document class. It mostly works but I encounter a bug, when there is a pagebreak the ...
Alex Nelson's user avatar
  • 1,060
0 votes
1 answer
64 views

How to add referrable numbered circle symbols to code listings?

I'm using \lstinputlisting to include sections of source code. Instead of adding line numbers to be able to refer to some specific parts, I'd like to include unique symbols that are visibly not part ...
UnbescholtenerBuerger's user avatar
0 votes
0 answers
101 views

How to configure cwl to provide verbatim highlighting for custom code?

I am trying to customize cwl file to provide verbatim highlighting. I am trying to get assistance from TeXstudio : User manual, and my cwl file contains the following \basoom{verbatimSymbol} This is ...
Al-Motasem Aldaoudeyeh's user avatar
4 votes
2 answers
133 views

Error with % and & despite using verb option

I am new to tabularray and I have a problem typesetting tables with code in it. I see the option verb must be given to environment tblr to allow verbatim text, but even then, characters % and & ...
ysalmon's user avatar
  • 1,160
0 votes
1 answer
48 views

Invalid character error: Listings with unicode chars with pdflatex and xelatex

The following code works fine with xelatex. It gives an invalid character error ^^00 with pdflatex. If I comment the line out it works fine. Probably an input encoding problem but can not find the ...
Danie Els's user avatar
  • 19.8k
0 votes
1 answer
60 views

How to get lstdefinestyle to accept a custom command with an argument?

I want to customize the style of Matlab-editor in matlab-prettifier package. What I want is to produce background for MATLAB styled commands, but it does not seem that basicstyle key accepts commands ...
Al-Motasem Aldaoudeyeh's user avatar
1 vote
0 answers
40 views

lstinputlisting ignores showlines=true

I am trying to display some code in my document using lstinputlisting. I want to display code written in Stan. I have a separate Stan file which I then call in my Latex document. Below is a working ...
J. Doe's user avatar
  • 176
0 votes
1 answer
83 views

how to add such a footnote to the code listing

Recently I saw a manual for working with glossaries, source code on page 14 there is a footnote with: opening the source code downloading it from the server by downloading the finished pdf file I ...
avebass's user avatar
  • 13
0 votes
0 answers
65 views

Math mode in wrapped lstinline

I am writing text that should be displayed as a code block with some fancy math mode characters. \documentclass{article} \usepackage{listings} \begin{document} \lstinline[mathescape=true]{Integer $\...
Fendor Baradiel's user avatar
0 votes
1 answer
213 views

Can't display Δ in a lstinputlisting: LaTeX Error: Invalid UTF-8 byte sequence (�\lst@FillFixed@)

I have an external JSON-File that contains the character Δ. A document can be built but I get the error: LaTeX Error: Invalid UTF-8 byte sequence (�\lst@FillFixed@). As it's external I am using: \...
Qohelet's user avatar
  • 113
0 votes
0 answers
54 views

How to make wider lstlistings

This is my LaTeX document containing some Java code: \documentclass[12pt, oneside,titlepage]{book} % add a4paper \usepackage[italian]{babel} \usepackage{geometry} \usepackage{color} \definecolor{...
tail's user avatar
  • 103
3 votes
1 answer
132 views

All caps text is crammed in lstlisting

I'm using lstlisting for command line documentation. The problem is that anything written in all CAPS is poorly spaced inside lstlisting but normal outside of it. I observed the same issue with ...
td211's user avatar
  • 153
2 votes
1 answer
299 views

How can I remove semicolon after Figure caption and make its number bold, when listing caption changed into Figure

I have applied in combination of following two solutions. How to make figure and listing share their counter and How to change listing caption?. I was able to combine them and make it work but I just ...
alper's user avatar
  • 1,389
2 votes
1 answer
124 views

\sys_get_shell:nnN seems to strip newlines from shell output

Goal: run a shell command and \input its output as LaTeX code. See related: How to protect \input shell command args with backslashes When using expl3's \sys_get_shell:nnN, newlines from the shell ...
David Fink's user avatar
1 vote
1 answer
57 views

How to create a new environment with mdframed and lstlisting? [duplicate]

I want to create a new environment that wraps mdframed and lstlisting together as shown below, however that does not work for me as it does not compile. Any ideas what the issue is and how to define a ...
pixel's user avatar
  • 1,357
0 votes
1 answer
70 views

How to define custom code listing?

I have the following custom listing but it throws error for lstset part that the keys are undefined. Any ideas how to fix this? \documentclass{llncs} \pagestyle{plain} \usepackage[utf8]{inputenc} \...
pixel's user avatar
  • 1,357
2 votes
1 answer
41 views

\lstinputlisting always parses entire source file

I'm using a lot of \lstinputlisting commands to display snippets from a large source file. For example: \lstinputlisting[firstline=8244,lastline=8250]{source.c} \lstinputlisting[firstline=9244,...
Robert's user avatar
  • 23
0 votes
0 answers
89 views

Creating a List of Symbols

I am writing a longer mathematical text, and I want to create a list of symbols. What is the recommanded way of doing this? I have tried to search older questions on this topic. Some seem to be ...
Cornman's user avatar
  • 103
1 vote
1 answer
87 views

listings package issues in LuaLaTeX, with coloring cyrillic comment in UTF

Coloring cyrillic comment does not work in LuaLaTeX. How might I be able to resolve this issue? MWE: \documentclass{article} \usepackage{polyglossia} \setdefaultlanguage[spelling=modern]{russian} \...
Youra_P's user avatar
  • 1,054
0 votes
1 answer
60 views

How do I designate part of a code listing transparent and another part not?

Let's say I have a code segment as follows: function foo() { ... // Lots of code not shown here } Then, let's assume I add some changes that I'd like to highlight over the old code. function foo() ...
TheSinisterStone's user avatar
0 votes
0 answers
96 views

Suddenly, the xsim package refuses to wrap my listing-enviroment

I wrote a script with a set of coding problems, and made use of the xsim package to produce an optional sample solution. Until September, this worked fine, especially wrapping a lstlisting-enviroment ...
Peter Sanctus's user avatar
1 vote
1 answer
73 views

Colorize string between to characters with lstdefinelanguage in latex

I want to change the color of all method names to blue. Method are defined by a dot in front and an opening parenthesis after. Example: .setLanguage("de"); Here i just want the setLanguage ...
Henning 's user avatar
1 vote
0 answers
18 views

beamer + noto + listings + \ttfamily: Curly Brackets Not Displayed Correctly [duplicate]

I am using beamer together with the noto fonts. I am finally done with my slide deck and wanted to ass a listings with some biblatex information. The problem is that some characters, e.g. { are not ...
Dr. Manuel Kuehner's user avatar
0 votes
2 answers
619 views

Treat command provided as argument as plain text

I find myself struggling with a supposedly simple task but after several hours of searching and trial&error I finally give up. I probably still lack the deeper understanding of LaTeX and its ...
Johnson's user avatar
  • 227
0 votes
1 answer
324 views

List of listings on same page with list of tables and list of figures

I need to put \listoffigures, \listoftables and \lstlistoflistings on the same page. The first two are ok, but the list of listings ends on a different page. This is what I tried: \begingroup \let\...
Deffo's user avatar
  • 53
1 vote
0 answers
216 views

\usepackage{listings} prevents file from compiling

I am trying to use the listings package to show code in my document, but for some reason, if I include this package, the whole document doesn't compile. I don't get any error messages, just: Process ...
user279043's user avatar
2 votes
1 answer
101 views

newenvironment with tcblisting

I want to defne a macro environment that uses the listings and tcolorbox packages, something akin to this: \documentclass{article} \usepackage{tcolorbox} \tcbuselibrary{listings} \newenvironment{...
erifor's user avatar
  • 23
0 votes
1 answer
442 views

Setting a minimum width in listings

I'm trying to create a few listings of some code files with varying max line-length. Is there a way to ensure that all listings have a 63-character width, regardless of how long its longest line is? I ...
Imp54's user avatar
  • 83
1 vote
1 answer
138 views

How to create table of code listing [closed]

How to create table like this one?
poker shark's user avatar
0 votes
1 answer
73 views

Can you standarize the whitespaces of the source code?

I want to know if there is a option to set all the whitespaces in my source code. The whitespaces in my CPP code do not look uniform. Sometimes I leave a space before and after the = sign, sometimes I ...
Maroon Racoon's user avatar
1 vote
1 answer
271 views

How to include listing language in top right corner of the listing?

I'm using the listings package, both using \begin{lstlistings} and using \lstinputlisting commands. Now, I would like to display the language of the listing for some languages. Say I have the ...
msrd0's user avatar
  • 127
1 vote
1 answer
166 views

Listings not showing line number in standalone class

I'm trying to compile a listing in a standalone so it can be \includegraphics'd on a separate document. The line numbers disappear when compiling as standalone, however, even though they do appear if ...
Imp54's user avatar
  • 83
1 vote
1 answer
65 views

How to put an input listing to fill both columns in a two column format without the end of it getting cut off from the page?

I need to add a bunch of code to show the entire CPP file for the problem that I gave participants to solve but the code keeps cutting off the page no matter what style I define it as. I am using ...
DeveloperInTraining's user avatar
0 votes
1 answer
40 views

Inconsistent result from basic lstlisting

Is it possible to understand why, and fix the faulty highlighting (inconsistent bold of only a few) in the listlistings for bash? The default rendering is worse than random. There is no reason why cd ...
Niklas Rosencrantz's user avatar
0 votes
2 answers
112 views

Make hyperlink in code listing

I'm trying to achieve something I thought would be basic functionality. Just a hyperlink where it appears (in a code listing). It would be better if it was possible to follow the link for a reader. ...
Niklas Rosencrantz's user avatar
1 vote
1 answer
45 views

tex4ht does not handle listing correctly when using smaller font size

tex4ht mess up code alignment when using basicstyle=\small (with or without font family being given) compare to when not using basicstyle. This only happens in the HTML. The pdf is correct. Here is a ...
Nasser's user avatar
  • 20.2k
1 vote
1 answer
174 views

List of Listings (lstlistings) style in KOMA-Script

This post suggests that scrhack is required to format a list if listings consistently: How to have the list of code listings also in twocolumn? I would like to format my List of Listings consistently ...
likethevegetable's user avatar
0 votes
1 answer
110 views

How to show a LaTeX command in lstlisting? [duplicate]

I code this in a .tex file. \begin{lstlisting} % This is the syntax for inserting code. \begin{lstlisting} \end{lstlisting} \end{lstlisting} And this is what I expect: % This is the syntax ...
Michael Tan's user avatar
2 votes
1 answer
63 views

How to affix a file-name in a box to the corner of a listing environment?

I'm writing a series of lecture notes and, because I'm working with multiple source files, I'd like to affix the current file name in the top-right of my listing environments. Here's an example of ...
Joshua Crotts's user avatar
0 votes
2 answers
94 views

How to include a listing with `#` in the filename?

Given the following files: book.tex \documentclass{memoir} \usepackage{listings} \begin{document} \lstlistoflistings \chapter{Hello, world!} \lstinputlisting{C\#/hello.cs} \end{document} C#/hello.cs ...
Christian Hujer's user avatar
1 vote
2 answers
164 views

lstinline in mathmode with correct font size

I often typeset mathematical formulas about computer programs (loop invariants, etc.). I typeset them in typewriter font, saying in my preamble \lstset{basicstyle=\ttfamily}. I could say $\frac{\text{\...
ysalmon's user avatar
  • 1,160
1 vote
1 answer
104 views

Automatically label line numbers in minted enviornment

I've recently swapped from the listing package to the minted package for my code listings. When I used lstlistings, I was able to redefine \lst@Key to automatically place labels of the format \lst@...
candr's user avatar
  • 21
0 votes
1 answer
47 views

Automaticly listing definitions at the end of document

I'm writing latex notes for mathematics. I use \newtheorem{definition}{Definition}[section] as an environement for definitions. I would like to have a list of definitions at the end of the document, ...
PNM's user avatar
  • 103

1 2 3
4
5
73