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
79 views

How to create this beautiful Python highlighting in LaTeX with listings?

I found this beautiful Python code highlighting in a PDF today. I want it! But I don't know how to get it? Here is what I tried: \documentclass[10pt,a4paper]{article} \usepackage[utf8]{inputenc} \...
0
votes
0answers
23 views

How to make a reference to “lstlisting”?

I have this format to my codes, and i want to make a refference, i used \ref{} but dont work. How can I solve that? \begin{lstlisting}[caption = code, label=lst:E269] \end{lstlisting}
0
votes
0answers
8 views

listings option morekeywords not work with Chinese characters when breaklines is set

When morekeywords contains Chinese characters, this keyword seems just be ignored when breaklines=true is set. How to fix this? \documentclass{ctexart} \usepackage{listings} \usepackage{xcolor} \...
1
vote
1answer
16 views

Use colorbox inside a lstlisting without losing other formatting?

I have a lstlisting defined as follow \begin{lstlisting}[language=bash,frame=single] Offset(P) Local Address Remote Address Pid ---------- ------------------------- ------------...
0
votes
0answers
25 views

UseRawInputEncoding and Norwegian letters

I'm currently writing a document in overleaf that has a lot of code implemented in the lstlisting environment. The problem with this is that it floods my log with "invalid utf-8 byte sequence ...
2
votes
1answer
21 views

Is it possible to indent the line numbers in algorithmicx the same as in Listings?

By default, the line numbers in algorithmicx are inside the float rules. \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{algorithm, algpseudocode} \begin{document} \begin{algorithm} ...
0
votes
0answers
15 views

Long commentaries lst (R)

I am making a Latex docuemnt where I have to input some code in R with the command \lstinputlisting. I have my own style defined with the following configuration: \lstdefinestyle{mystyle}{ ...
1
vote
0answers
44 views

Pretty displaying code in beamer

I am currently making my first beamer presentation, so forgive if this is a very trivial question. I have tried to research how to display code on a beamer presentation. I have managed to do this ...
0
votes
0answers
14 views

Listings define language in a separate file

I'm currently working on a paper where i want to showcase some JavaScript Code Snippets. I am using the listing package and defined JavaScript with \lstdefinelanguage. Since the command with its ...
0
votes
0answers
13 views

lstlistings in a two column setup

How can I use lstlisting in a two column setup, meaning that the code block is spreading over both columns? (lstlisting* is not valid.) - I dont want two listings side by side!
0
votes
0answers
12 views

Top/bottom margins in Listings

As seen in the screenshot below, the text is way too close to the background borders, the problem is solved on the left side using framesep but as I don't want to change the appearance of my framing, ...
1
vote
1answer
32 views

Why using @ inside \newcommand gives “Undefined control sequence” error?

I'm trying to create a command that temporarily changes the size of a lstinline, so that I can properly use it in a footnote. The following commands seem to work fine: \makeatletter \lst@AddToHook{...
0
votes
1answer
12 views

Postbreak token for listings not working in beamer

I have the following latex code: \documentclass{beamer} \usetheme{Frankfurt} \usepackage{listings} \lstset{ basicstyle = \linespread{1}\ttfamily, breaklines=true, postbreak=\raisebox{0ex}[0ex]...
0
votes
1answer
13 views

Break longer word into lines to fit the box (inputminted?)

I would like to fit the long string (as it is labelled url in the json file) inside the box without overflowing. As far as I understand, breaklines option only helps when strings consist of separated ...
1
vote
1answer
41 views

Automatic line break with backslash in listings

I would like to use listings to format bash commands in such a way that overly long lines are automatically broken with a backslash. I know about the prebreak option, but it appears as though it is ...
3
votes
1answer
65 views

How to use bicaption and how to define bilingual names for lstlisting?

I need to write bilingual captions for codes in a paper, but I do not know how to use \bicaption for lstlisting. Also, I want to change the name of lstlisting to Code in the bicaption. I know I can ...
1
vote
0answers
15 views

Listings morekeywors is no adding special caracters like ::, + etc [duplicate]

when i use morekeys in the lstdefinestyle it succesfully adds any word but it doesn't work with some characters like +,<, etc. this is the style: \lstdefinestyle{ligth}{ morekeywords = [1]{}, ...
0
votes
3answers
140 views

Listings: consistently colouring numbers

I have been using this solution found here at LaTeX Stack Exchange for colouring numbers in my code excerpts: \documentclass{article} \usepackage{listings} \usepackage{xcolor} \makeatletter %%% ...
0
votes
0answers
30 views

Color in lstlisting is black to different language

I am new to XeLaTeX and I want to display python code using listings package. The problem is that greek characters in comments or strings are colored black. This is a MWE: \documentclass[a4paper,11pt]{...
0
votes
1answer
25 views

Use custom delimiter for inline minted environment

Using the listings package, we can do the following to create a | (pipe)-delimited inline code environment: \lstMakeShortInline| I am interested in using the minted package instead, however it doesn'...
0
votes
0answers
18 views

Rule above caption of lstlisting too long inside itemize

I want to use the caption package to insert a horizontal bar above the caption/title of a lstlisting environment (+ some other stylings which are not relevant here). The minimal example below shows a (...
1
vote
2answers
24 views

lstinline puts space before dot

I am trying to use \lstinline to style filenames in my document, but it puts some random whitespace befor the dot. I presume it has to do with autosettings for punctuation? Can I deactivate this with ...
1
vote
1answer
35 views

Degree symbol and \lstinputlisting

How can I print a degree symbol (°) in a listing with \lstinputlisting? I have noticed the questions based on the lstlisting environment but it does not work with \lstinputlisting. This illustrate the ...
1
vote
1answer
32 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
24 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
13 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
18 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
24 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
40 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
34 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
55 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
22 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
27 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
39 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
32 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
33 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
24 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
19 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
18 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
37 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
49 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
31 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
18 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
25 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
16 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
84 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
26 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
2 3 4 5
64