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
2 votes
1 answer
38 views

How can I extend properties of \lstdefinestyle?

I am importing multiple python scripts into my tex file. I previously had one huge \lstdefinestyle definition which included options for all the specific functions, variables, etc across all my ...
0 votes
1 answer
16 views

How to get rid of the unwanted control information in Solidity listing displayed as figure

I am using dissertation template. Following is the link: https://www.overleaf.com/read/yyjwyqtvzfwt#ef4aff Can anybody get access to all my documents using the above link? I am trying to represent the ...
0 votes
1 answer
40 views

The listings package compilation

Hello Stack Exchangers I have been facing a problem in the successful compilation of the listings package's LaTeX Macros (.dtx) file into the local directory. The intention is not only to use the sty ...
0 votes
1 answer
51 views

listing with background color broken with maths equation

This is a similar question to listings with background color and mathescape broken. Here is my code: \documentclass{article} \usepackage{graphicx} % Required for inserting images \usepackage{listings} ...
0 votes
0 answers
47 views

Problem with lstlisting and LaTeX3 for exercises repository

First of all, sorry by the size of my MWE, I didnt know how to do it smaller. I was developing some kind of repository of questions for my classes. My purpose is to show one exercise in a pdf document ...
0 votes
1 answer
257 views

How can I use \lstdefinestyle in a subfile?

Assume that main.tex is my main compiled latex file. The rest of them (as sub.tex) includes the list of def ones in order to arrange each chapter, subchapter etc. How can I use defined style in main....
0 votes
0 answers
15 views

How do I allow automatic page breaks within a listing?

I have some code inside tcolorbox environments defined by lstlistings, and I want to be able to have a listing automatically page break to avoid so much vertical space at the bottom after a listing. I'...
1 vote
1 answer
23 views

Strange extra space in lstlisting when breakindent has been set to 0pt

In the following example of lstlisting, there is a strange extra space in the beginning of the third line. As you can see, it has already been set as breaklines=true and breakindent=0pt. The issue ...
1 vote
1 answer
72 views

Text outside tbox

\begin{tcolorbox} \begin{lstlisting} [caption = {C Code}, captionpos=b, label = {Listing3}, abovecaptionskip=12pt] int a ,b; int value = 20; \end{lstlisting} \end{tcolorbox} I am using the above code ...
3 votes
3 answers
1k views

How to insert equation numbers with lstlisting?

I am trying to use the lstlisting environment to insert R code into my LaTeX document. What I cannot figure out is how to get LaTeX to number these equations so that I can refer back to them later in ...
0 votes
0 answers
34 views

Insert code source with listings and problem with special french characters [duplicate]

I'm having a problem using listings. Everything works fine until I want to insert special French characters such as é or è. From that moment on, I get an error message. However, I had specified in my ...
0 votes
1 answer
278 views

Priority of page breaks between paragraphs in beamer slides with allowframebreaks

I have breamer slides with allowframebreaks which have some basic structure, e.g.: \begin{frame}[fragile,allowframebreaks]{Title} some text... \begin{itemize}...\end{itemize} other text \begin{...
1 vote
0 answers
48 views

Convertig latex to docx using pandoc

as a latex newbie I converted latex file via pandoc to docx. Itemized list with items a), b), etc. appears correctly in pdf but in docx it appears as bullet list. I tried different workarounds but ...
39 votes
8 answers
35k views

How to insert code with accents with listings?

I'm trying to insert source code in LaTeX with using listings, but my code has accents and pdflatex gives me this error: Unicode char \u8:�\expandafter not set up for use with LaTeX. This is a code ...
1 vote
1 answer
62 views

How to put an input listing to fill both columns in a two column format without the end of it getting cut off from the page?

I need to add a bunch of code to show the entire CPP file for the problem that I gave participants to solve but the code keeps cutting off the page no matter what style I define it as. I am using ...
3 votes
1 answer
53 views

Trying to apply two different caption styles using \caption, but the styles won't get applied

Below is my full LaTeX document. My goal is to create two different caption styles. One style for the caption for the programming blocks (created with listings), where above the programming block, a ...
1 vote
1 answer
217 views

Removing extra vertical padding from minted/listings code snippet

I have some extra vertical space in my listings/minted code snippet that I can't figure out how to get rid of (especially the bottom). The code originally came from this answer. I have read the ...
5 votes
1 answer
85 views

Create File Path for Listing with Macro based on Arguments

I am trying to make a macro that creates the path to a file from which a listing should be loaded based on its parameters. This fails very early. Here is a schematic of what I am trying to do: \...
0 votes
0 answers
45 views

Greek letter inside a listings environment [duplicate]

I have some Greek letters in my Python script that I'd like to typeset with a listings environment. I use the FiraCode font that seems to support Greek letters. But the Greek letters sometimes do not ...
4 votes
1 answer
49 views

Add linux tree command output in listing

I copy tree command output into listing but compile failure. \documentclass[12pt,a4paper]{article} \usepackage{listings} \begin{document} \begin{lstlisting} . ├── ./a.tex ├── ./b.aux ├── ./b.log ├── ./...
0 votes
1 answer
430 views

Indentation problem with wrapfigure and listings

I am having a problem with some indentation of paragraphs when displaying an image next to a block of lstlisting. I am using Overleaf online (and have found several weird quirks previously). Below is ...
1 vote
1 answer
27 views

How can I change the caption of a Listing which is outside of minted code?

I am working on a LaTeX document using the scrarticle class and the minted package for syntax highlighting. My objective is to have a properly aligned caption with the code listing, similar to the ...
17 votes
4 answers
10k views

Adding background color to \verb or \lstinline command without \Colorbox

Update: In addition to my previous post, here's a screenshot to give you a better visual example. This was created with HTML and CSS for demo only. In CSS, the code part is made using font-family: ...
0 votes
0 answers
29 views

Fixed width listings columns without extra spaces after copy from pdf

I would like the code listings from my Beamer slides to have the same spacing after having been copied from the pdf, and pasted into a text editor. I have been working with the columns option of the ...
0 votes
0 answers
18 views

How does classoffset work in listings?

Can someone please explain, how I can modify the following example, so that each dialect or language, can be colored differently? I have difficulty to understand what is the classoffset concept in ...
1 vote
1 answer
100 views

problsoln and listings package compatibility issues

I'm trying to use the probsoln and listings packages for computer science exercises, but it seems that these packages are incompatible when the problems are put in a separate file. Any help would be ...
0 votes
1 answer
318 views

Custom new environment positioning and margins

How can I place the following custom new environment at the top of every page like figures (options [ht])? \usepackage[newfloat]{minted} \newenvironment{code}{\captionsetup{type=listing}}{} \...
2 votes
3 answers
337 views

Listings: Replace the left out code

Is it possible to leave out some code and mark this, instead of including only parts of the code (which is almost the same)? I would like to have an output almost like the second and third listing in ...
0 votes
1 answer
124 views

Error while compiling list of symbols when using Greek letters [duplicate]

I am writing a list of symbols and acronyms for my thesis using \usepackage[printonlyused]{acronym} and \usepackage{multicol} I have no issues for Latin letters, but when I want to use, for example, ...
0 votes
1 answer
76 views

Justify text lstlisting

I would like to justify text in lstlisting. If the line gets too long, there doesn't seem to be any way to automatically add a new line. Is there a way to justify text?
0 votes
1 answer
61 views

Substitute text between delimiters (listings) [closed]

I want to format code within the lstlistings package via \lstdefinestyle. The goal is to substitute the text after the regex 'C:\ up to the regex .eps' with PATH. How can I realize this? The solution ...
1 vote
1 answer
69 views

Hack 'minted' definition with NewTCBListing und RenewDocumentEnvironment

A colleague and myself are trying to hack the minted environment by assigning the original meaning to oldminted using \NewEnvironmentCopy and then use this saved version in a redefinition of minted ...
0 votes
1 answer
134 views

Controlling listings `lstlisting` vertical spacing with paragraph breaks ( `aboveskip`, `belowskip`?)

When we have a blank line between text in the LaTeX source, we have a paragraph break. The fact of the paragraph breaking itself seems to be respected with a lstlisting environment. Specifically, if ...
1 vote
1 answer
470 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 ...
0 votes
1 answer
44 views

How to get lstdefinestyle to accept a custom command with an argument?

I want to customize the style of Matlab-editor in matlab-prettifier package. What I want is to produce background for MATLAB styled commands, but it does not seem that basicstyle key accepts commands ...
3 votes
1 answer
1k views

Latex highlighting error for lstinline

it has been quite a while that I have this problem and I have searched everywhere online and couldn't find a solution. The problem is latex syntax highlighting doesn't work after this line: \...
0 votes
1 answer
158 views

"Allow page break before the next line" inside lstlisting

I am trying to use the code from this answer to have precise control over where page breaks can occur inside listings. My problem is twofold: it seems I can't put the commands on their own line, and ...
0 votes
1 answer
24 views

Adjusting line break indentation with listings package

I'm using listings package for listing various text tables. I prefer to use this package as the look and feel of text and line numbering is similar to my other code listings. Below is a sample table: \...
0 votes
1 answer
61 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-...
1 vote
1 answer
298 views

Use listing for Matlab code from another file directory

I used the listingcode example from here What can I use to typeset MATLAB code in my document? to load a matlab code file directly into LaTeX, but I use different file directories as followed: \...
1 vote
1 answer
21 views

How to Fix spacing that produce weird symbol inside Code Environment?

I want to know why there are weird symbols of spacing like this (at the left side for the GLSL code) : This is the code that you can check and reproduce: \documentclass[twoside]{book} \usepackage{...
0 votes
1 answer
250 views

How to add a font code with \lstinline?

Under LaTeX, I'm wanting to add the following R code between text. I'm searching for an appropriate font . I already tried: \documentclass[notitlepage]{article} \usepackage{amsmath, amssymb} \...
0 votes
0 answers
23 views

Is it possible to use environments from existing packages when defining my own custom environment? [duplicate]

I'm trying to define a new environment for my own needs, and I'm trying to use the lstlisting environment from the listings package in the definition of my new environment, but whenever I try to ...
1 vote
1 answer
55 views

How to use two styles for the same listings language?

At the moment I have two global options defined for my listings language: color and monochrome (I have bundled the language as a package and so these are package options). However, now I find that I ...
0 votes
1 answer
24 views

How to reference labels within lstlisting?

My code is as follows, and I want to reference a Tikz image within the lstlisting environment instead of it being displayed as is. This kind of situation often arises in code comments. \documentclass{...
1 vote
1 answer
143 views

Title-cased small caps in Listings

I'm trying to transform an uppercase KEYWORD into \textsc{Keyword} in Listings. I'd like something of the form \lstdefinestyle{mystyle} { language = ML, basicstyle = {\ttfamily}, ...
1 vote
1 answer
59 views

Correct Elixir Syntax Highlighting

I am currently writing a thesis in which I frequently need to add Elixir code snippets. I am not very experienced with LaTeX, but after a bit of searching I found this solution. The problem is that ...
2 votes
1 answer
207 views

Classifying Matlab Code and Pseudocodes Under List of Codes and Matlab and R Output under List of Output

I am kindly requesting for assistance on how to put the headings Matlab Code and Pseudocodes under List of Codes and headings Matlab Output and R Output under List of Output using the below MWE. In ...
0 votes
1 answer
90 views

Conflict of between powerdot and listings packages

Playing with powerdot presentations, I realized one more awkward behavior. When listings package is in effect, \onslide command of powerdot package does not seem robust. The minimum example is shown ...

1
2 3 4 5
72