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

lstinline with special characters breaks some environments (runaway argument)

I am trying to enclose an inline listing with some environment like \fbox or \centerline. My MWE below illustrates how \lstinline normally escapes the % and { characters but inside the above-mentioned ...
0
votes
0answers
44 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
20 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 ...
0
votes
1answer
62 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
25 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
1answer
54 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
0answers
46 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
24 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
46 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
24 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
75 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
43 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 ...
1
vote
1answer
128 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
88 views

How can I automatically do \shorthandoff in all inline listings with pandoc?

To get proper French punctuation in pandoc with babel, I followed the advice in https://tex.stackexchange.com/a/505068/17868 which requires enabling shorthands in babel. However, as I found out, when ...
0
votes
1answer
62 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
vote
1answer
55 views

Box chars characters (Missing character: There is no ┬ in font)

I am using Sphinx to build a project that use listings and some box characters. I have these errors: Missing character: There is no ─ in font [lmmono9-regular]:! Missing character: There is no ┬ in ...
1
vote
1answer
27 views

Add new keyword including an operator to existing language listings

I am trying to type set some OPL (Optimization Programming Language) code using the listingspackage. It turns out, that it looks a lot like Java, so I use Java like a "base". However, some ...
0
votes
0answers
44 views

Undefined control sequence error in lstlisting

I trying to add SQL code in my document. I used the following piece of code. \documentclass[12pt]{article} \usepackage{amsmath, amssymb,amsthm,verbatim} \usepackage{color} \usepackage{xcolor} \...
0
votes
0answers
17 views

Class memoir Error: listing is not a counter

I am trying to use \counterwithout{listing}{chapter} Chngcntr: \counterwithout not working Number listings the same way as figures and tables But memoir keeps complaining Class memoir Error: listing ...
0
votes
0answers
23 views

lstlisting in two column article [duplicate]

I need to write an article in two columns, but I would like to span an lstlisting over both text colums. With figures and tables I use \begin{figure*}. But this does not work with \begin{lstlisting*}. ...
12
votes
1answer
1k views

produce copy-paste-able pdf output with correct indentation with listing

Here is a block of latex code to produce some Python code. I'd like to be able to copy and paste it into Python. \documentclass{standalone} \usepackage{listings} % Include the ...
1
vote
0answers
63 views

How do I use the MagicPython syntax highlighting with latex?

I would like to use the syntax highlighting from MagicPython with LaTeX - preferably with the listings package. According to the documentation for the listings package it should be possible to supply ...
2
votes
2answers
198 views

Do not apply literate option in comments

I defined my own programming language using listings and, to do so, I had to use the literate option a lot in my definition. For example, to make parentheses bold and green, I did this: \definecolor{...
84
votes
4answers
78k views

How to format an inline source code

I have a document where I quiet often refer to source code element, such as class names, I wanted to format these strings differently, but at the beginning I didn't want to fiddle with various options ...
4
votes
1answer
14k views

Simple coloring of json attributes

Could someone please explain me how I can color the json attributes for a json string in listing? An example would be great. Thanks. Example String: {"name1":"attribute1","name2":"attribute2"}. How ...
0
votes
0answers
84 views

Highlight numbers in code with listings

I'm currently trying to define my own code style with the Listings package for LaTeX. Among other things this style should display numbers in a separate color. However, if the numbers are within a ...
1
vote
1answer
49 views

Using listings linerange in tcolorbox breaks formatting

When using listings's linerange or firstline/lastline, the tcolorbox shows extra top and bottom padding, and the font is different. Is there a way to fix this, or is this a bug with tcolorbox that ...
0
votes
0answers
35 views

How to print spaces and tabs as spaces and tabs in 'lstlisting's?

Consider the following: \begin{lstlisting} int main(void) { printf("hello world"); return 0; } \end{lstlisting} [Note: the text is not actually rendered blue, I just tried to select it ...
2
votes
1answer
37 views

adjustwidth and newenvironment

Edit: thank you for commenting. I've edited the question to use lstnewenvironment but it keeps giving the same error. I will keep the question here while I go read the lstlistings manual. The ...
0
votes
0answers
94 views

pandoc listings not mono space font

I am using pandoc 1.19.2.4 on Ubuntu 18.04 to generate a PDF with markdown. I am wondering why my code listing are not rendered in a mono space font. I defined monofont: "Ubuntu Mono" in the ...
0
votes
1answer
18 views

How to create an empty lstlisting?

I am using lstlisting for code snippets. Currently, I am working on an exercise sheet, for which I need to create an empty lstlisting, which can later be filled out. Right now I create empty lines ...
0
votes
1answer
65 views

How to get the image and code in showexpl package separate and break the code to new page when ended page?

In listings and showexpl package, my problem is the code is go over the page and one another problem is that how can the image and the code be seperate that the image in previous page and the code in ...
7
votes
1answer
4k views

How to change frame color in listings package?

I am using listings package for code highlighting and I want to have a different color frame around my code examples. Any ideas how to do it? There is backgroundcolor but there isn't framecolor so I ...
0
votes
0answers
8 views

Keywords with $- sign - Listings

I am trying to create a snippet of code and want to use $output=0 as a keyword in one specific colour, however, it is not accepted by morekeywords as a new keyword.
6
votes
1answer
12k views

Float for lstlisting

I'm trying to set float to my lstlisting (It means lstlisting without pagebreak). I found 2 ways, but it not works for me: Float attribute in lstlisting. It is OK only for lstlisting then count of ...
0
votes
0answers
28 views

How to get rid of extra text (i.e listings, xcolor) while using “solidity-highlighting.text”

I am getting unnessary text in my document (i.e. listings, xcolor ) while I am using solidity-highlighting.tex file. I found that they are related to the command: \usepackage{listings, xcolor} I ...
0
votes
0answers
32 views

Listings moves and inserts double prime marks (U+2033)

I have the following LaTeX code: % !TeX TS-program = xelatex \documentclass{article} \usepackage[EU1]{fontenc} \usepackage{fontspec} \setmainfont{Times New Roman} \setsansfont{Arial} \setmonofont{...
0
votes
0answers
109 views

How to use Solidity.tex file for highlighting Solidity code in overleaf editor

I want to write Solidity code in overleaf editor. I found a file for highlighting Solidity code at : High lighting Solidity code When I am referencing this file in overleaf editor by: \input{solidity-...
0
votes
0answers
22 views

Why is listings not coloring the comments properly in the middle of the bash script?

I have created a minimal example to illustrate the behavior. I have a bash code using sed. I want to use multiple substitutions using sed, placing each in a different line, so that I may add a comment ...
0
votes
0answers
24 views

How to display double quotations in lstlisting, currently getting error and large space between lines

I am using following listing: \begin{lstlisting} 1pragma solidity 0.4.16; 2contract TestContract{ 3 string private mystring =”foo”; 4 uint private lastupdated = now; 5 function getString() ...
0
votes
0answers
30 views

package xkeyval Error

I wrote the following code in Latex overleaf editor. \begin{lstlisting}[language=Python, basicstyle=\small, caption=Table 9: Program of 'selfdestruct', obtained from [333].] The image is given below: ...
0
votes
0answers
17 views

Wrap/break long code lines using noweb

How can I enable line breaks within code chunks in noweb's Latex output? If I have long code lines, I want them to wrap on the final documentation PDF page, but this does not work out of the box, ...
1
vote
1answer
97 views

Colored Hexdump [duplicate]

I want to print a hexdump in my document, where i color some specific bytes. I tried working with escapeinside then doing textcolor in my lstlisting but this changes the format of the text. The bytes ...
0
votes
0answers
30 views

wlanguage code source and color in a report with listing

how to put wlanguage code source in a report i use this code : \documentclass[12pt,a4paper]{report} % Pour la gestion du français et des accents % \usepackage[english,french]{babel} \usepackage[utf8]{...
0
votes
0answers
28 views

Listings: Prevent keyword highlighting in Javascript comments

I use the listings package to display code snippets in my documents. To add syntax highlighting to my javascript listings, I have defined javascript as language for the listings package. The keywords ...
0
votes
0answers
46 views

Format mongodb code using the listings package

Has anyone perhaps used the listings package to format console output in a Latex document. I am specifically looking to format mongodb queries in my report to look something like the below:
1
vote
1answer
33 views

\usepackage{listings} with sffamily but proportional

I'm using \usepackage{listings} to display code in a text. With basicstyle=\sffamily, the text is displayed sans serif, but I want to have it proportianal too. Is any one know if it possible to have ...
1
vote
1answer
49 views

Elegant margin in listing environment?

If you look at how this example below is rendered in StackExchange, you see a nice margins around the hello world code: int main(int argc, char * argv[]) { printf("hello, world!\n"); } ...
2
votes
0answers
39 views

Beamer and listings incompatible? [duplicate]

I suspect that listings and beamer are incompatible and I am looking for a fix. My minimal example is as follows: \documentclass{beamer} \usepackage{listings} \begin{document} \section{...
0
votes
0answers
20 views

Truncating long files with Listings' \lstinputlistings

I know that the Latex Listings package offers \lstinputlisting to include listings from external files. I also know that I can include only a fragment of an external file by using options firstline, ...

1 2 3
4
5
64