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

decrease monotype letter spacing in lstlisting

I'm using listings to display code in my document and tgheros font. How can I decrease the monotype letter spacing for code listings? % in my preamble \usepackage{listings} \usepackage{tgheros} % ...
0
votes
0answers
18 views

Command that would treat all arguments as string

I have this command that makes gray boxes around text. How do I make sure that eveything I put as an argument there is treated as a string and gets rendered like an inline gray box? \documentclass{...
1
vote
0answers
8 views

listing pre- and postbeak gives error in beamer slide

Following this answer, I've tried to embed a listing with long lines into a beamer frame. I'd like to have a nice red arrow at the line break (as show here). The parameters prebreak and postbreak give ...
0
votes
0answers
16 views

Solidity listing: IEEE Conference Template

I am trying to display solidity code in IEEE LAtex template for conference paper. The link for GitHub repository is: IEEE CPS TEST_ZIP and the file names is: IEEE CPS test.zip It is a two column ...
0
votes
0answers
22 views

How to maintain formatting when copying code from rendered PDF?

I am looking for a way to write code in a document so that the readers could easily copy the code from within and paste it in an editor without breaking the formatting (indentation, line breaks and ...
0
votes
0answers
38 views

What is the best way to add the results of the Master thesis in the Latex report

I am writing my Master thesis report. My thesis was research and development of a test data generator for a particular domain in an organization. The developed application will generate test data in ...
2
votes
0answers
29 views

gobble option of listing when used via tcolorbox

I use tcolorbox + listings to display code in a box. I pass a gobble option to listings, which seems to be plainly ignored: \documentclass{article} \usepackage[listings]{tcolorbox} \begin{document} ...
1
vote
1answer
48 views

Positioning listings in itemize

Minimal Example \documentclass{report} \usepackage{listings} \usepackage{xcolor} \usepackage{caption} \definecolor{captioncolor}{rgb}{0.7, 0.7, 0.7} \definecolor{backgroundcolor}{rgb}{0.95, 0.95, 0....
0
votes
0answers
8 views

How to remove formatting for some of the keywords in listings?

How do I remove (or change) the formatting for end on line 8 while not removing it for end that closes the for-loop? \documentclass{article} \usepackage{verbatim} % code \usepackage{listings} ...
1
vote
1answer
19 views

How can I add string formatting for listings code?

How do I make sure that string-like code like "file" below (on line 7) gets same formating (purple/muave) like strings below? \documentclass{article} \usepackage{verbatim} % code \...
2
votes
1answer
25 views

Nesting listings in an environment

I'm trying to define an outer environment around lstlisting (using quotation as an example). I tried: \newenvironment{quotelst}{% \begin{quotation} \begin{lstlisting}[] }{% \end{lstlisting} \end{...
1
vote
1answer
33 views

lstlisting: Box numbered variables in matching colors

Is it possible to match numbers, prepended by a %, e.g. variable %101 and surround every occurrence of that number in color-matched boxes? I am trying to make it easier for readers to follow the ...
0
votes
1answer
30 views

How can I draw in an existing tikzpicture from an lstnewenvironment?

The below example works fine if I move the tikzpicture environment into the after command of the lstnewenvironment. However, if I want to draw in an existing tikzpicture, the node content is not shown....
0
votes
2answers
31 views

listings package und set lstinline style?

I set 3 styles in my lecture notes for 3 different code style enviroments (\lstdefinestyle and \lstnewenvironment). How can I set the \lstinline style to one of these? Or is it not possible? Because ...
1
vote
1answer
22 views

remove the dashes that appear at the top

Using the listings package I tried to mimic the Matlab R2016a environment with the following code: \documentclass[12pt,letterpaper]{article} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \...
0
votes
0answers
17 views

How to fit long strings that goes out of page using lstlisting?

I am finishing my thesis in Overleaf and need to add an XML file in the appendix. I use lstlisting package. The problem is that the file contains strings with many characters and does not fit in the ...
0
votes
0answers
15 views

Listings unexpectedly descends the star(*) character

Using the Fontspec package in XeLaTeX, I declared a new mono font(Menlo) as the font for the listings package. But the package unexpectedly descends the star(*) character, which is weird. How to ...
1
vote
0answers
33 views

Tabular appearance when using listing in beamer

I am using the listing package to display some code. However, the result is not what I expected due to the annoying presence of symbols ^^| (see picture below). The settings that I am using are the ...
2
votes
1answer
45 views

How to highlight the XML code in latex overleaf

I followed few answers mentioned here to highlight the XML content in my latex and tried to combine best things together from different answers but for some reason nothing is being highlighted in my ...
1
vote
1answer
30 views

Listings: skip line number ONLY where command is defined

I have looked at the following: Suppress line numbering for empty lines in listings package Suppress line numbering for specific lines in listings package However, the solution given in the latter ...
0
votes
0answers
16 views

The Listings Package: how to format quotation marks, commas, periods, punctuation marks

I'm trying to give format to my code, which was written in a Raspberry Pi OS terminal. What I've currently achieved is the following: \documentclass{article} \usepackage{xcolor} \usepackage{listings} ...
0
votes
0answers
20 views

Alignment of caption in Listing

i need help with the alignment of my caption. The Problem is that the second line dont align correct. My code is: \DeclareCaptionFormat{listing} {\parbox{\textwidth}{\hspace{15pt}#1#2#3} } \...
0
votes
1answer
23 views

How to highlight the word “base” as code with the listings package, e. g. \lstinline{base}?

When I use the word base inside \lstinline{} to highlight it as inline code, I get an error, followed by warnings that are not there, if the error is not there: Package xcolor Error: Undefined color `...
0
votes
0answers
15 views

Colored code using mosel xpress programming language

I would like to edit the \lstset so that it supports the mosel language coloring scheme. \documentclass[a4paper]{article} \usepackage[english]{babel} \usepackage{microtype,etex,listings,color,parskip}...
3
votes
2answers
75 views

Using a listing inside a figure-like environment

I am writing a document dealing with formal grammars, containing numerous examples. I decided to use the lstlisting environment from the listings package over the mathematics align and give example ...
0
votes
1answer
24 views

Change listing colors and allow auto-indent

This is my listing whose code is: \lstset{ inputencoding=utf8/latin1, language=Java, % choose the language of the code numbers=left, % where to put the line-...
2
votes
0answers
24 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 ...
1
vote
1answer
33 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
1answer
55 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
19 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
26 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
18 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
43 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
33 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
33 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
0answers
22 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
24 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
33 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
32 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 -&...
1
vote
0answers
113 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
54 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
61 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
36 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
26 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} \...
0
votes
2answers
17 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
25 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
1answer
29 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}@...
0
votes
0answers
17 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
23 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 ...

1
2 3 4 5
63