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
2
votes
0answers
33 views

Have accented letter in keywords with listings

How can I have an word with accented latter that is also a keyword using listings? I found a solution to have accented letters here, but if the keyword contains an accent, it is not recognized as a ...
0
votes
1answer
63 views

Listings custom counter

I've wanted to create custom listings style with its own counter. The problem I have right now is that the counter is not increased by 1 but by 2. Here is an example: Output: First listings counter is ...
0
votes
2answers
74 views

Can I make an entire listing a hyperlink rather than just the code?

Using the method explained in https://tex.stackexchange.com/a/213413/218142 I can click on the code in a listings environment defined with lstnewenvironment. Students cut and paste their code from ...
1
vote
0answers
27 views

Beamer: code fragment with listings [duplicate]

I am having difficulty adding code fragment to my slides in beamer with listings package. My code: \documentclass{beamer} %\usepackage[utf8]{inputenc} \usetheme{Warsaw} \usepackage{listings} \title{...
0
votes
1answer
36 views

Two column listing separated by a vertical line, LaTeX

I'd like to create something like this: and I achieved similar results in LaTeX, but nothing is alligned and there is too much white space over and under the text. Any solutions? Here's the code ...
0
votes
1answer
22 views

Customizing list of listing

I need to customize my list of listings page by adding a period after each caption (e.g. Listing 1.1.). I couldn't find the correct place to insert the period in the code. Here is my MWE: \...
2
votes
1answer
50 views

List of listings linked to incorrect page number in TOC

I want to customize list of listings format in my document and did the following changes in my project: % before \begin{document} \makeatletter \AtBeginDocument{% \renewcommand\lstlistoflistings{\...
0
votes
0answers
38 views

How do I remove these white bars in the listing environment?

Basically I am trying to add some code to my document, and no matter what I try to do, these white lines won't go.. I don't seem to be the only one struggling with this as I found this question, ...
0
votes
0answers
44 views

Setting a common counter to different environments (figures, tables, theorems, etc)

I am trying to set a common counter to the environments figure, table, algorithm, thm, lstlisting. After searching over the internet I found a partial solution: to add the following code at the ...
1
vote
1answer
43 views

How to make at operator while listing program?

When I am inserting mathematica codes with the package listing, I find that it recognize at as a letter rather than an operator. This comes into a result that, for example when typing N@Table[10,5], ...
0
votes
0answers
36 views

How to use Consolas from fontspec and times simultaneously

I want to use times in headings but I want to use Consolas inside listings, however times and fontspec overrides one with another. I have tried the following: %-----------------------------------------...
1
vote
0answers
38 views

How to put equation within listing caption?

I'm trying to do something like this: \begin{lstlisting}[language=Python, caption=Here is an equation $y=2x$.] def y(x): return 2*x \end{lstlisting} But I get an error due to the equation in the ...
0
votes
0answers
42 views

Create a macro to generate arguments for lstlisting

I have the following elm file with some source code, that I would like to include in listings: -- >Color type Color = Red | Green | Blue -- <Color -- >colorToString colorToStirng : Color -&...
2
votes
0answers
289 views

How make a LaTeX document that generates a PDF from which copy-paste works correctly for empty lines and leading space indentation?

We are writing a PDF document in LaTeX that contains various installation instructions and other technology text. Our idea is that the user reads various instructions in Serif font and then there's ...
2
votes
1answer
490 views

x86 Assembly Language Listing

I am trying to make the following x86 Assembly Language Listing style: But I couldn't make it. My listing code is as: \documentclass{article} \usepackage{listings} \usepackage{color} \usepackage{tikz}...
1
vote
2answers
67 views

Color problem in listings with breaklines=true

I'm trying to highlight a specific comment type with lstsliting, and the option breaklines messes things over. Here is the faulty output : The color purple (produced by the keyword name) takes over, ...
0
votes
0answers
15 views

Line numbering within pages with listings package

When I use listings package as is, line numbers appear in the margin and the listing lines start at the margin. I know a workaround of putting each listing into a minipage with \noindent, but it is ...
1
vote
2answers
55 views

Using minted .Things are alright except List of Listing is small with * and in TOC the text is replaced by * instead of “List of Listings”

I am using listing and minted package already and code as follows: \documentclass[11pt,a4paper,openright,final,twoside,onecolumn]{memoir} \listfiles \fixpdflayout \usepackage[utf8]{inputenc} % ...
1
vote
2answers
30 views

Continuous border with math markup within code/algorithm markup

I'm currently facing an aesthetic issue. The borders of my code/algorithm section are being divided by in-code math markup: Table has been generated with the following code: \documentclass{article} \...
1
vote
2answers
156 views

How do I add border at top and bottom in lstset for code

I want to have border at top and bottom of my code. I tried setting it in lstset as follows: \lstset{frame=topline|bottomline} However it simply removed right side border and kept all borders intact. ...
0
votes
1answer
48 views

Having asterisk above and not inline in code listings

I want to writing code listings with asterisk in-line not above line. That is something like this: But when I tried this: \documentclass{article} \usepackage{listings} \begin{document} \begin{...
1
vote
2answers
37 views

How to correctly color code listing without getting weird character spacing?

I want to prepare code listing which looks like this: I tried this: \lstset{escapeinside={<@}{@>}} \begin{lstlisting} <@\textcolor{blue}{void}@> fun(var<<@\textcolor{blue}{long int}@...
1
vote
1answer
55 views

Is there a way to use the listings package together with mathpartir's mathpar

I'm trying to typeset a small-step semantics for a programming language. My plan was to use the mathpartir package for writing the inference rules and the listing package to typeset the language ...
0
votes
1answer
44 views

Adding Horizontal lines before and after listings frame

I have a listing, and I would like to add a hline before and after the listing. Using the frames style parameter do not work as intended for two reasons: 1. I want to keep a left bar as a separator ...
0
votes
0answers
12 views

Color for the text when using “lstlistings” with R text

I am using the environnement "lstlistings" to insert chunks of R in a LaTeX paper. I would like to have the text of R commands in blue color and the output of R in red color. How can I do ...
0
votes
0answers
31 views

How can I get a “Listing” in multicolumn format with frame and caption

I am hoping to put a multicolumn listing in a single column book with a frame and caption. The frame is to surround the entire listing and the caption centred on the page. This MWE example clearly is ...
0
votes
0answers
88 views

LaTeX listing package Pseudocode with Syntax Highlighting

I am trying to use listings package for writing algorithm. I have used algorithm2e but its hard and i cannot customize it specially the fonts. I am following this stackexchange answer: \documentclass{...
0
votes
0answers
314 views

LaTeX listings package JSON formatting

I am using package listings for JSON data. I am following this example How to improve listings display of JSON files from this stackexchange answer. It generates the following output: I added caption ...
0
votes
0answers
20 views

Other environments within 'lstenvironment' breaks?

Trying to add a color frame to an lstlisting with the mdframed package environment. It works great when I do something like: \begin{mdframed} \begin{lstlisting} code \end{lstlisting} \end{...
0
votes
1answer
13 views

How to cross reference lstnewenvironments?

I have made a lstnewenvironment in my document. I am unable to cross reference it. Here's the code \lstnewenvironment{customlistings}[3]{ \lstset{ numbers=left, language=#3, breaklines=true , ...
0
votes
0answers
75 views

How to put caption in package solidity-highlighting.tex

I am using following Latex code for displaying Solidity listing but it does not show any caption. I downloaded the file from here Somebody please guide me how to put caption. Link for project files is:...
0
votes
1answer
36 views

Strange “incomplete iffalse” error depending on length of text before : how to track down?

Recompiling the text of a lab session document for this year, I get an error when processing a lstlisting that I did not get last year. Here is an excerpt of the log : [1 {/opt/yann/texlive/2020/...
0
votes
0answers
27 views

knitr: change the tidyverse italic font in Soutput environment comments?

In printing a tibble, for example, the output begins \begin{Soutput} # A tibble: 30 x 2 cond rating ... # … with 20 more rows \end{Output} The output formatting is defined by \usepackage{listings}...
0
votes
1answer
19 views

Maintaining exact formatting in a listing with hyperlink escape sequences

I have some code in which I wish to place hyperlinks. I am using the 'listings package.' I would like the code to look identical, with and without the hyperlinks. Failing that I would like to be able ...
1
vote
0answers
30 views

problsoln and listings package compatibility issues

I'm trying to use the probsoln and listings packages for computer science exercises, but it seems that these packages are incompatible when the problems are put in a separate file. Any help would be ...
1
vote
1answer
56 views

Line break in lstlisting inside of escaped text

I' trying to fix the display of a line break inside an lstlisting environment, but more specifically in a part of the listing that is inside an escaped area: \documentclass{article} \usepackage[utf8]{...
0
votes
0answers
60 views

git highlighting style for listings

Is there a predefined highlighting style that I could use with package listings so that output from git commands like git diff, git log can be highlighted as they show up on the terminal (added lines, ...
1
vote
1answer
26 views

Literate in listings does not work for every item

I am reproducing C code style with listings. I have defined "" to be a string, so when I add libraries as "ff.h" it is treated as a string and is printed blue. To avoid that, I use ...
1
vote
2answers
83 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
59 views

TikZ arrows change direction when used with beamer, listings and itemize

I asked this question on https://topanswers.xyz/tex?q=1244 but the question seems to have exposed a bug. \documentclass{beamer} \beamertemplatenavigationsymbolsempty \setbeamertemplate{frametitle}[...
0
votes
1answer
26 views

First number and captions in listings environment

I am using listings to display code and I added firstnumber and caption but it doesn't appears to work. There's an example: \documentclass[11pt,fleqn]{book} % Default font size and left-justified ...
0
votes
0answers
48 views

I updated MiKteX some days ago (11/08); Since I dit that, “lstlisting” doesn't work

I want to include R code in a tex source by using the environment lstlisting from the package listings. It is a paper I began to work on some weeks ago. The inclusion was working correctly during some ...
0
votes
0answers
28 views

How to use captions in the style of headings in the appendix of floating environments?

TL;DR: If I have to word it differently, I could also ask: How can I use headings instead of captions for these entries (listings or figures)? I do have these elements: pictures in figure floats ...
0
votes
1answer
118 views

\lstlisting in \enumerate environment

I simply would like to have an enumerated list that contains code, but the result is glitchy: I would ideally have the code-block indented and starting at the same horizontal level as the item label. ...
0
votes
1answer
64 views

sagetex linebreak

When using the environment sagecommandline of sagetex with long number output, how can I get automatic line breaks? I already tried to change sagetex.sty (putting breaklines=true at several places), ...
0
votes
1answer
30 views

lstlisting indent doubled

I'm trying to use the listings packege. When I incert the following content which copied from the https://www.overleaf.com/learn/latex/code_listing \documentclass{article} \usepackage{listings} \begin{...
0
votes
1answer
97 views

Macro for lstinline with mathescape results in undefined control sequence

I have the following issue: \documentclass{article} \usepackage{listings} % also sets some other options but this bug is indepent of them \newcommand*{\code}[1]{PREFIX \lstinline[mathescape=true]{#1} ...
0
votes
1answer
64 views

Remove leading space with \lstinputlisting

When including listings with \lstinputlisting, spaces (or tabs) used for indentation of the code are kept, which is of course a good thing. But I want to document code line-by-line, so sometimes the ...
2
votes
1answer
353 views

Listings package language Assembler could not be loaded

hi i'm trying to do a very basic paper on asm x86 intel syntax, I tried few languages like Python , C , perl and makefile and with that i got no errors. this is my LaTEX code \documentclass{article} ...
0
votes
1answer
99 views

Listings : avoid white line glitches in background color?

With the following code I get some glitches in the background color of my listing environment: How can I avoid these glitches? Aside from this issue, the margin top and bottom is different. The code ...

1 2 3
4
5
65