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

\lstinline highlighting error in Texmaker

I am able to compile perfectly, and the PDF output is nice. But editing-wise, it gets annoying that Texmaker colours everything after \lstinline as if it is a listing. Any quick fix for this? Here is ...
0
votes
1answer
21 views

Listing not fully filling background with escape inside

I made this minimal example to showcase the problem I am having: \documentclass{article} \usepackage{xcolor} \usepackage{listings} \definecolor{background}{HTML}{EEEEEE} \definecolor{xmlOrange}{HTML}{...
0
votes
0answers
15 views

Listings and Float package ordering cause \parskip to be ignored in list of listings \lstlistoflistings

Ordering matters with listings and float packages else \parskip is ignored I was trying to figure out why in my list of listings (\lstlistoflistings) the \parskip was being ignored, when eventually I ...
0
votes
0answers
13 views

Overwrite listing style

I want to add some code in a listing with syntax highlighting. But for this language I like to change the style so the keywords are not blue like they normally are but bold and black. In addition when ...
0
votes
2answers
35 views

How to put a list of code in appendix?

I want to put a code in my thesis appendix. print('This sentence is output to the screen') # Output: This sentence is output to the screen a = 5 print('The value of a is', a) # Output: The value of ...
0
votes
0answers
11 views

Listing: custom syntax highlighting for JSON?

I created the following custom language definition for JSON, based upon the syntax highlighting offered by IntelliJ IDEA for JSON. % Custom colours \definecolor{numbers}{HTML}{0000FF} \colorlet{...
2
votes
1answer
23 views

Different colours for R input and output using listings

I need to quote some R commands and a few scripts, and sometimes to show the output. I would like that the output had a different colour than the input, but I have no idea how to. A minimal example ...
0
votes
0answers
11 views

Using subfiles package with listings package

I'm doing some notes for programming contests and I had managed to make both packages work nicely with each other (and the graphicx package) via the following: % Fix for relative path file insertion (...
4
votes
1answer
75 views

Get the language currently set for listings

How can I get the language currently set for the listings (aka lstlistings) package, e.g. via \lstset{language=Python,basicstyle=\color{blue},backgroundcolor=\color{lightgray}}? Details: I want to ...
1
vote
2answers
29 views

give a document input to lstnewenvironment

I recently asked this question: Independent caption and numbers on different lstlisting language script And the answer for my need was to use \lstnewenvironment. Problem is that I'm still working on ...
0
votes
1answer
24 views

Independent caption and numbers on different lstlisting language script

I'm trying to write a document where I use AMPL, Python and I would also like to be able to show some of the outputs. Problem is that the first python code is Script 1, the first AMPL is script 2, ...
0
votes
0answers
28 views

Syntax Highlighting for XML in lstlisting environments

I'm looking for a good syntax highlighting for XML (the existing syntax highlighting for XML does not meet all requirements.). I've already created something there (below), unfortunately I'm still ...
1
vote
0answers
18 views

Vertical cell padding in tabular with equations and listings

Vertical cell padding in the bottom of each cell in tabular with equations and listings is too large in cells containing one or more equations or listings. How do I get rid of this extra space? ...
0
votes
0answers
21 views

How to list Apache Webserver configuration snippets?

Is there a way to list with lstlistings apache configuration files? An example snippet is: <Directory /> Options FollowSymLinks AllowOverride None Require all denied </Directory&...
0
votes
0answers
16 views

Put some code with minted in an a0poster

I am using Overleaf to create my poster with the class a0poster. I have a question about introducing a code (SPARQL) in a minted block for a poster. When I used a minted block, with beamer or article ...
3
votes
2answers
90 views

tcolorbox inserting indent after code box

(the commented lines will be used later but as we can see in MWE, they aren't related with the problem) Why is there a par indent after the code box? MWE \documentclass{report} \usepackage{lipsum} ...
0
votes
0answers
33 views

Code formatting frustrations with listings

I have been trying to create some custom formatting for C++ code. But I am having the following problems: The right parentheses ) is immune to formatting. Formatting type breaks typedef, typeid, and ...
1
vote
1answer
49 views

Font for good looking `--` and `@` in an lstlinsting

I am using \lstset in order to create boxes with writing in in my document. In these boxes I am using a lot of double dash (--) and a lot of at symbol (@). I am trying to change basicstyle to ensure ...
0
votes
1answer
15 views

lstlisting label with wrong counting across sections [duplicate]

All my listings labels appear with prefix 1. in all sections, such as the following example, where the second listing of my paper in section 2 appears with the prefix 1. rather than 2. I have already ...
1
vote
1answer
23 views

Highlighting macros and keynames containing asterisk

My goal is to highlight latex macros and keynames in the MWE below. The problems come in when * is a part of a keyname and also as an argument to a macro. I tried using the MWE, but it does not ...
0
votes
0answers
22 views

How can i properly define multiple syntax for strings in a listing

I want to define my own syntax highlighting for listings. I want Keywords to be in red, comments in green, plain text in yellow and strings in blue. Problem is that i want to have multiple string ...
0
votes
0answers
29 views

JVMIS in lstlistings

I am using the listings package in order to typeset JVMIS code in LaTeX. Is there a chance to highlight the labels in such code? At the moment I have with the default definition JVMIS Lab: iconst_2 ...
0
votes
0answers
24 views

Minted: won't break page

This is example of my problem. This picture shows the end of the page This is my code begin{listing}[ht!] \begin{minted} [style=colorful, breaklines=true] {java} //code... public class Document { ...
1
vote
0answers
16 views

Listing theorems or definitions

I followed this Marking the end of a definition to create an specific environment definition for my theorems. Is there any easy way of listing all declared definitions/theorems? I want a list similar ...
1
vote
1answer
40 views

How to make the list of listings to work properly in tex4ebook?

How to make the list of listings to work properly in tex4ebook? Commands \tableofcontents and \listoffigureswork correctly. The pdf result The epub result I didn't found any suggestion to ...
0
votes
0answers
29 views

highlight text within lstlisting

I would like to highlight some text in a lstlisting section. The text contains some characters like % and {, }. To highlight some code I use different method but I always have the same issue: \...
1
vote
0answers
18 views

Apply specific color to !important in CSS using listings

Problem: I wish to apply a gray color to !important in CSS when using listings. I have managed to modify so that the color is different after : but how can I modify the code below so only !important ...
0
votes
0answers
17 views

lstlisting not show chinese words in iPad & iPhone

I am compile a tex document in my mac book pro and it shows chinese words perfectly,but when I import the pdf file into my iPad & iPhone,and it does not show chinese words of lstlisting.How to ...
0
votes
0answers
20 views

lstlisting with % in optv causes error

I use the options-package to show parts of my document only if necessary. Some of these excluded parts are in an lstlisting-environment and it works well. However if this environment contains a % an ...
1
vote
0answers
35 views

How to number listings included by the \lstinputlisting command?

I am trying to write a document displaying python codes, using the listing package with the \lstinputlisting command. It turns out that the counter "lstlisting" is not used or displayed, so that my ...
0
votes
1answer
22 views

Remove spaces inside quote in Listings [duplicate]

I'm using TexMaker with PDFLatex. My problem is that the code lines in the listing ress := 'articles'; test := 'something'; test := 'somethingarticles'; test := 'arrtticclleess'; are ...
1
vote
1answer
56 views

tikz - draw line over listings

I wish to draw over listings with lines. but below sample output into 2 different page. \documentclass{article} \usepackage[left=10mm,right=2mm,top=2mm,bottom=2mm,paperwidth=12cm,paperheight=4cm,...
0
votes
0answers
39 views

Writing code in LaTeX [duplicate]

Supeeer new to Latex so I'm sorry if my question is stupid. I have a programming assignment using pseudo-code for one of my courses. Our professor suggested we do the assignment using LaTeX. Can ...
0
votes
1answer
43 views

Formatting Matlab file with lstlisting

I included a Matlab file, and it worked fine. The colors changed and it looked nice. Suddenly Latex doesn't change the colors of the code, except of the background color. Is something wrong with my ...
0
votes
1answer
54 views

print obfuscated command

I want to print these two obfuscated commands in latex. I tried verbatim and listings. But, could not print the following as is. cmd.exe /C"set 4i=net us&&set OyVP=er&&call set kUt=%...
0
votes
0answers
30 views

numbering parenthesis in lstlisting mode

I am typesetting LISP/Scheme code in latex using the lstlisting package. I would like each opening and closing parentehsis to be be numbered, starting with 1 (and for a balanced sexpr, also ending in ...
0
votes
0answers
29 views

Copy and paste from the pdf to a txt so that newlines are kept

Is there a way to make the pdf so that when i copy the code and paste it in a text file it's reproduced in the same format, i.e. every new line is kept \documentclass[% corpo=12pt, oneside, stile=...
5
votes
1answer
112 views

How to highlight numbers only outside a string in lstlisting?

I have some source code in Python and I would like to highlight numbers, but only if the number is part of an operation or in a declaration, that is, if I name a variable variable1 for example, I don'...
0
votes
0answers
26 views

Why lstlisting does not highlight numbers?

I would like to include some python code in my document, and here is what I have written so far: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{graphicx} \usepackage{amsmath} \...
10
votes
1answer
764 views

Color coding in Python f-strings

Since Python 3.6, released Dec 2016, there is new f-string formatting, where, inside your string you can put python code to be evaluated in {}s. It's fantastic but TeX packages for code listings with ...
2
votes
0answers
29 views

underfull hbox when using caption+listings in enumeration

I'm getting a weird underfull hbox linked to the caption when having a listing inside an enumeration : \documentclass[a4paper,11pt]{article} \usepackage{caption} \usepackage{listings} \lstset{...
0
votes
1answer
62 views

Why is listings ignoring my whitespace?

\documentclass{article} \usepackage{listings} \usepackage{jslistings} \begin{document} Test: \lstinline[language=JavaScript]!import {function} from "@icm/service-name";! \end{document} results in ...
0
votes
2answers
47 views

How to color lines in code using listling?

I have a file with a code and I would like to insert it directly from the file in listings that is defined in some way. I need to color lines starting with #. How to do that please? in.txt # Code ...
0
votes
0answers
23 views

How to use bold/colors in listling?

I would like to emphasize words from code. Let us say code. How to do that? And is it possible even in case I load the code from a file? And is it possible to use diacritic? \documentclass[12pt,...
3
votes
2answers
57 views

tikz - listings marker postion weird behavior

I just add a marker dot on each line's start/first/end with build in marker coordinate but sounds like weird: \documentclass[border=10pt,varwidth=3cm]{standalone} \usepackage{tikz} \usepackage{...
3
votes
1answer
64 views

Single and multiple lines for a verbatim argument from a NewDocumentCommand

I want to create a command that display a given LaTeX code and its formatted output. So far I've noticed that the showexpl packages does a good job, since you can use those styles that have been ...
1
vote
1answer
41 views

Change font size for individual code listings

I would like to reduce the font size within a (beamer) document for some code listings; to allow an occasional larger program to fit on a slide. I have in the past used \begin{lstlisting}[basicstyle=\...
0
votes
0answers
28 views

Use argument from lstinline twice in a user defined command [duplicate]

I'm writing a document (that uses the listings package) which aims to show the output of some LaTeX commands. I want to create a command that would allow me to typeset the command inline and its ...
1
vote
0answers
30 views

Create a command whose delimiters are not curly braces

Whenever I want to write an inline piece of code of LaTeX by using the listings package, I have to use the following command: \lstinline[language={[latex]tex}, keywordstyle={\color[HTML]{101094}}]|\...
1
vote
1answer
41 views

Duplicate text in multiple places in different environments (lstlisting?)?

folks--- I got a question I'm not sure how to solve. I'm putting together a compendium of my exam questions in a single pdf that I'd like to share with other teachers who also use LaTeX. The pickle ...

1 2 3 4 5 59