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
48 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 ...
0
votes
0answers
16 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*}. ...
1
vote
0answers
59 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 ...
1
vote
1answer
30 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
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
43 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
30 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
33 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
52 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
51 views

Cyrillic characters in lstlisting

I try to write some cyrillic text in a source code block: \begin{lstlisting}[caption={asdfa},label={lst:tokens},language=SQL] SELECT (SELECT COUNT(*) FROM cards WHERE description ILIKE '%#НОМЕР#%') ...
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.
0
votes
0answers
26 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
31 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
21 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
22 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
25 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
96 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
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
77 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
24 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
26 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
32 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
29 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
41 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
19 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, ...
0
votes
0answers
35 views

Code environment that supports copy-paste

Is there a LaTeX package that can generate code in PDF file and allow users to copy-paste the generated code? I have tried the lstlisting environment. This is my test code: \documentclass{article} \...
0
votes
1answer
104 views

LaTeX Error: Command \thelstlisting undefined

I'm using book class, and trying to change numbering on listing using \renewcommand\thelstlisting{\arabic{chapter}.\arabic{section}} but im getting this message LaTeX Error: Command \thelstlisting ...
0
votes
1answer
51 views

Is it possible to change the language from english to other in lstset?

Generally speaking. Is it possible to change the language from english to other for captions in lstset? If yes, how do I do it? Example of captioned text: \lstinputlisting[language=Matlab,caption={...
0
votes
0answers
25 views

How to include a caption to a Python code snippet

I am using a self-defined command to create an environment for my Python code that I want to show in my document. This command has been taken from redmode's answer to the following question: here. So, ...
0
votes
1answer
38 views

Using listings, copy bash command in 1 line

Im trying to insert in my PDF some long bash commands like this one: I like how it looks but, when trying to copy, it splits the command into 3 lines, which obviously is not how I would like it to ...
1
vote
2answers
30 views

Display three listings side-by-side (consider that the page size might change)

The context I want to display 3 listings side-by-side. I've managed to display 2 listings side-by-side with the following minimal working example \documentclass{article} \usepackage{listings, lipsum} ...
1
vote
1answer
51 views

How to write SPL in LaTex?

I have searched everywhere for SPl(Search Processing Language) that is used in splunk and I wanted to format my piece of code just like that: I have tried to play with the lstdefinelanguage and ...
0
votes
1answer
43 views

How can I use commands in a listlisting

I have the following latex code \begin{lstlisting}[escapechar=\%] begin begin \alpha; i = 5 ... \end{lstlisting} and I would like to have the \alpha be rendered as a ⍺ but it seems to ...
1
vote
1answer
60 views

Custom styles for minted in Overleaf

So I just moved from listings to minted, as listings had super annoying problems with lines showing up when the background color is set to dark. Minted, on the other hand, is annoying as there doesn't ...
0
votes
0answers
23 views

Ignoring doxygen comments in listings

I have a C project that I am documenting in latex. It features doxygen comments (like those /** bla */ /**< blab */ /// bla blub ///< blubber). I use the listings package to include parts of the ...
0
votes
0answers
15 views

Keeping font spacing in lstlisting and escaped latex

I'm using the following code to highlight in red some C code: \begin{lstlisting}[language=C,basicstyle=\ttfamily\tiny,keywordstyle=\tiny\ttfamily,escapechar=@] struct test { int field1; ...
0
votes
0answers
18 views

Setting text color in lstlisting without using the xcolor package

I want to be able to make custom colors for code contained in lstlisting blocks. The generally recommended solution is to use xcolor, but I tried using that package and it causes a bunch of errors ...
2
votes
2answers
39 views

Change font only used in listing and not in rest of document

I created a \lstdefinelanguage command for some JSON blocks I'd like to add into my document, I followed the answer to this question: How to improve listings display of JSON files? In the answer the ...
0
votes
0answers
21 views

Change width of \lstlisting resulting from user defined \lstdefinelanguage

I used the \lstdefinelanguage to create a formatting for some JSON blocks I'd like to add to my file, I used the one in the answer for this question: How to improve listings display of JSON files? ...
-1
votes
1answer
35 views

Error with listing and tabular

Here is the code \lstdefinestyle{mystyle}{ frame=single, } \begin{figure*}[tbp!] \begin{center} \begin{tabular}{c} \lstset{style=mystyle} \lstinputlisting[]{...
1
vote
0answers
25 views

Why does ~ from Python file look so weird when imported into Latex? [duplicate]

After inserting a Python file into my latex file via \lstinputlisting[language=Python]{Thesis.py}, I get Normally, it should be ~, but it is at higher than it should be. When I copy it from the ...
2
votes
1answer
35 views

how to put caption below 2 minipage?

I have 2 side-by-side minipages and I would like to put a caption below them. Is there a way to do it? \noindent\begin{minipage}{0.5\textwidth} \begin{lstlisting}[mathescape=true] P -> if (x,y) ...
5
votes
2answers
106 views

Escaped percent sign is syntax-highlighted as comment by listings package

My code: \documentclass{article} \usepackage{listings} \usepackage{xcolor} \lstset{ language=[latex]tex, basicstyle=\ttfamily, commentstyle=\color{violet}, columns=fullflexible, ...
1
vote
1answer
125 views

Use JetBrains Mono ligatures with fontspec and lstlisting environment

I would like to use JetBrains Mono font in my document, in order to write some code with lstlisting environment. I’m using lualatex and memoir class. I’m using TeX Live 2020 on Windows 10. Is it ...
1
vote
1answer
41 views

How to color matching parenthesis within listings?

What I would like to achieve are rainbow-colored parenthesis (just like Rainbow delimeters in Emacs) based on their depth in a newly defined style for a programming language (Racket). For example: (...
0
votes
0answers
18 views

How to add mathematical symbols to list of keywords and color them in listing using morekeywords?

I already read this question: Mathematical symbols as keywords in listing but I am interested in a solution which adds my mathematical symbols to morekeywords - is that possible?
0
votes
0answers
449 views

Command \textminus unavailable in encoding OT1

When I try to compile my document I get the error as in the title. I guess it is related to the Matlab code I submit, but I do not know how to correct this. \documentclass[3p,times]{elsarticle} \...
1
vote
0answers
29 views

Rendering unicode theta (θ) in lstlisting

I am including some MATLAB code into my main document, using the listings package, which contains a unicode theta (θ). How can I render an actual unicode theta instead of using \theta. Here is a MWE: ...

1 2
3
4 5
64