Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

1
vote
0answers
20 views

Roman to Arabic Listing Caption Numbering [on hold]

I'm working on my thesis that uses many code listing in it. In each listing, I want to put caption with the chapter number followed by the position of that listing on that chapter. The problem is my ...
0
votes
1answer
17 views

Listings Package causes normal text to hyphenate at forward slashes

MWE: \documentclass{article} \usepackage{listings} \begin{document} IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII hardware/software \end{document} This results in this ...
3
votes
1answer
45 views

Space between caption and listing

Obviously, the caption is not beautifully placed; it needs more space between the caption text and the frame/listing itself. How can I do that? I am using the IEEEtran document class and the ...
0
votes
1answer
18 views

How can I style Listing captions the same as Figure captions?

Here is my listing caption format: Here is my figure caption format: How can I format the listing captions to be the same as figure captions? here is the relevant bit from the style file: % Revised ...
0
votes
0answers
28 views

How do I reset the setcounter for a custom lstlistingname in latex?

I am fairly new to the world of LaTeX and am currently working on a report. Throughout the report there are several tables, figures and commands. For the figures and tables I found the working code ...
1
vote
0answers
29 views

Positioning of listings [closed]

Exists something like positioning of listings. I mean for instance something like [h] that is used by figure or tables. I would like to add it to \mylisting[label=p]{p}{p.txt} I have a \...
2
votes
1answer
47 views

Font size in listing

How to set a font size in listing when I have these settings in the preamble? \documentclass[12pt,a4paper]{report} \usepackage[most]{tcolorbox} \newtcbinputlisting[auto counter,list inside=lol,list ...
3
votes
1answer
28 views

Listings package does not return the expected output

So I was trying to use the listings package for LyX in order to create something as following: After some research (link) I saw a suggestion to do the following steps: In settings->LaTeX Preamble ...
0
votes
1answer
39 views

Setting space and font in tcbinputlisting [duplicate]

How to set a space above the \mylisting and is the fontsize set fine? Thank you \documentclass[12pt,a4paper]{report} \usepackage[most]{tcolorbox} \newtcbinputlisting[auto counter,list inside=lol,...
3
votes
0answers
57 views

How to scale horizontally every character in listings code?

I want to scale horizuntally every character in listings code, making it narrower. The basewidth option is not what I want, since it doesn't scale characters. Any way to achieve this? \documentclass{...
1
vote
0answers
34 views

How to have code both word-wrapped and flush with an example number?

Using \verb| | in an example fails to give word-wrapping. Using: %! TEX = xelatex \documentclass[a4paper, titlepage]{book} \usepackage{listings} \lstset{ breaklines=true } \newcommand{\...
3
votes
2answers
54 views

List of listings - how to add

I have defined listings. How to create a list of listings? I mean something similar to \listoftables. Thank you \documentclass[12pt,a4paper]{report} \usepackage{xcolor} \usepackage{listings} \...
0
votes
0answers
25 views

List of listings: problem with the STYLE of table of contents

I have some problems with making of table of contents for listings. I would like to add to my document (memoir class) the List of Listings but I could only obtain it with totally a different style ...
2
votes
1answer
24 views

Customizing caption of listings within a beamer document

I want to change the font of the caption of the listings within my document. I found the solution of doing it with the package caption and the tag captionsetup: \documentclass{beamer} \usetheme{...
2
votes
1answer
55 views

Problems with fragile frames in Beamer

I found a nice solution of re-using titles of beamer frames here by defining: \newenvironment{slide}[0]{ \begin{frame}\ifx \insertsubsection \empty \frametitle{\insertsection} \else \...
1
vote
1answer
28 views

Highlighting second set of latex command in a listing

I'm trying to get a second set of (own defined) Latex commands to get highlighted with the listings package, but I don't succeed. See the MWE below. \documentclass[a4paper]{article} \usepackage{...
0
votes
0answers
24 views

Listings not breaking long lines with breaklines=true and breakatwhitespace=false

I have the following code in my Markdown: ```{latex-fontsize=scriptsize} $ ./my-new-application create app_example creating app_example Generating <path-to-app-src>/new-application/...
1
vote
0answers
32 views

Listing parenthesis highlighting [duplicate]

I'm using the listings package to insert code into the document. My research led me towards the literate option of listings to control operator highlighting. I have one issue - the right round bracket ...
2
votes
1answer
43 views

Listing inside a frame using beamer

I want to use listing inside a frame. I know that I have to specify: begin{frame}[fragile] ..... However my code has not the row elements i.e. on the left the numbers related to the rows are ...
7
votes
0answers
52 views

Defining a two part environment using minted and listings

I am writing some programming instructions for students, and I am trying to format the code so that it looks like the cell input/output structure of a Jupyter or Google Colab notebook. So I want it ...
6
votes
2answers
77 views

Weird Vertical Spacing of '*' with Fira Code in Listings

I am recently getting started with LuaLaTeX and I was trying to set up a custom listings style for C++. Consider the following MWE: \documentclass{scrartcl} \usepackage{fontspec} \usepackage{xcolor} ...
1
vote
2answers
45 views

How to automatically write bold commands in a bash script in Latex using listings [duplicate]

I wanna include a bash script in a black box in a pdf using latex. I achieved everything I want, except bold commands in the script using the following code: \documentclass[11pt,a4paper,DIV=15]{...
0
votes
1answer
32 views

Referencing caption of code listing

I would like to reference some piece of code which has a caption on it like this: \begin{lstlisting}[caption=componenet \label{Label} , backgroundcolor = \color{lightgray}] //Here is my code \end{...
3
votes
1answer
31 views

Listings does not break at pure hyphen lines

I have the issue, that I need listings package to break at a hyphen (-). I will give a MWE below. According to https://tex.stackexchange.com/a/140725/7166 the hyphen is a character of type "other", ...
2
votes
1answer
31 views

Listing: XML keywords, strings, identifiers not recognized

I'd like to implement some XML code in my document. However, the syntax of my listings doesn't seem to be acknowledged. So my output looks like this right now: Obviously, that doesn't make any sense. ...
2
votes
1answer
39 views

listings interfering with babel

Consider this script: \documentclass{article} ...
1
vote
0answers
42 views

tcolorbox listing in XeLaTex compiler

I want to write a document whose main language is Arabic with listings by using the package \usepackage{polyglossia} \documentclass[14pt]{extarticle} \usepackage[listings,minted,breakable,skins]{...
2
votes
0answers
35 views

Including a Java code snippet by method name, not line number

I am currently writing documents that contain large amounts of references to source code, in which I would typically include a complete method at a time. /* ... */ public class MyClass { public ...
0
votes
1answer
21 views

Listings in another language [duplicate]

I'm using the babel package along with the greek language and I want to insert a List of Listings in my document. I used \addcontentsline{toc}{section}{\numberline{}Κατάλογος Αλγορίθμων} \...
2
votes
1answer
31 views

Problem inserting C snippet

I am trying to insert an snippet like this But when I write \usepackage{listings} \lstset{language=C} \begin{document} \begin{lstlisting} typedef double real_t; // Esto casi seguro necesita ser tipo ...
3
votes
1answer
33 views

Use same reference count for lstlisting and figure/graphics

I have the following code on overleaf: \begin{lstlisting}[caption={Código inicial para o sistema de arquivos},label={lst:Figura1}] abstract sig FSObject { } sig File, Dir extends FSObject { } sig ...
0
votes
1answer
21 views

Listings problem: indentation and not automatic wrap

I am having some problems when formatting c++ code using listings. Here is my WME: \documentclass{standalone} \usepackage[left=1.00in, right=1.00in, top=1.00in, bottom=1.00in]{geometry} \usepackage{...
1
vote
0answers
43 views

Tabular (height spacing) for \lstinputlisting and picture

I have a lstlisting environment in one column and an included picture in the other. according to the MWE, the following is printed: MWE: \documentclass[10pt]{article} \usepackage[margin=0.75in, top=...
1
vote
1answer
53 views

The inserted code has extra blank lines

I'm using listings to format blocks of code in my xeLaTeX.When I insert this picture into Anki's card, the inserted code has extra blank lines. Following is my MWE: \documentclass[tikz]{standalone} \...
1
vote
1answer
36 views

In memoir and XeLaTeX, I attempted to control the environment of minted to break across pages, but the codes did not work

I use the class memoir and the packages minted and compile in XeLaTeX. Based on the questions How to let minted break across pages but keep the caption together with the end of listing? and Breaking ...
2
votes
1answer
27 views

Tilde in listings using lineskip and a command breaks “onehalfspace”

I'm trying to produce an inline code snippet that starts with a ~. Using onehalfspacing per university requirement and lineskip=-1pt for subjectively better legibility, packing the \lstinline inside ...
1
vote
1answer
22 views

Continuous line numbering in lstlisting, but separate lsttableoflistings entries?

i'd like to use the name=something,firstlinenumber=auto function for continuous line numbering throughout a couple of subsequent listings in my document. I'd also like to have each of the listings ...
-1
votes
0answers
26 views

Got problem in lstset type

Code \lstset{numbers=left,commentstyle=\color{mygreen},keywordstyle=\color{blue},stringstyle=\color{codegreen},,numberstyle=\color{blue},backgroundcolor=\color{backcolour}} In this picture the left ...
4
votes
3answers
52 views

Silencing overfull hbox warning for listing in adjustbox

I have the following in my document and it works as I expect, scaling the listing to fit the page, but it gives me a spurious Overfull \hbox warning that I would like to get rid of: \begin{adjustbox}{...
3
votes
1answer
52 views

How put source to algorithm?

I want to put SOURCE in the algorithm as I put them ?, I want to use this \usepackage{copyrightbox} \documentclass{book} \usepackage{lipsum} \usepackage{listings} \usepackage{tocloft} \renewcommand{\...
2
votes
1answer
20 views

Regression in spacing before lstlisting environment with version 2018/09/02 after paragraph break

Anyone else noticed a difference in the spacing before a lstlisting environment since upgrading to version 1.7 2018/09/02? Here's a MWE with output with version 1.7 and version 1.6 for comparison. I ...
0
votes
1answer
49 views

Listing linerange markers sometimes not being recognised

I am documenting several large XSLT scripts using the \lstinputlisting command. I have set Processing Instructions in the scripts to mark off suitably-sized blocks of code to document, mostly 10–20 ...
2
votes
1answer
28 views

How to create space between chapter in List of Listings

I want space in the List of Algorithm for every chapter that I insert, similar to how it occurs in the List of Figures and List of Tables. This is my code: \documentclass{book} \usepackage{lipsum} \...
0
votes
1answer
67 views

Problem with UTF-8 in Listings not beingsolved by standard answer

I'm using TeXstudio and pdfLaTeX. I'm trying to use the listings package to add some Matlab source code to my document. However, I'm having trouble with some portuguese letters used in the code (...
4
votes
3answers
74 views

Strange behaviour using center, tcolorbox, listings and enumerate

I have a problem compiling the following minimal example: \documentclass{article} \usepackage{listings} \usepackage{tcolorbox} \begin{document} \begin{center} \begin{tcolorbox} \begin{...
3
votes
1answer
57 views

Infinite loop error when inserting more than one\newtcbinputlisting setting

I was attempting to generate different programming languages code snippets to highlight the different syntax in different programming languages like: Python, Matlab and C++ (more to be added later). ...
1
vote
0answers
75 views

Can the command \minted and \mintinline have rounded corners without depending on the package listings? Are tcolorbox and tikz needed?

I use XeLaTeX, but I can not use both or similar or duplicate packages, because someone said it is bad idea in XeLaTeX. I would like to use only minted. Here are two answers which offer inline code ...
3
votes
0answers
45 views

Importing code files with unicode using listings

I've written a program in python, about 2500 lines in total, that I wish to include segments from into my report. Normally I use listings to do that but in this case, the .py files include many ...
0
votes
1answer
38 views

listing code has missing some word

\usepackage{listings} \definecolor{identifiercolor}{rgb}{.4,.6,.56} \definecolor{stringcolor}{rgb}{170,55,241} \definecolor{inactivecolor}{rgb}{28,172,0} \lstset{ basicstyle={\footnotesize\def\fvm@...
2
votes
1answer
53 views

Listings - Error could not load requested style

I am trying to create some styling for my javascript snippets. My configuration looks like: \documentclass[letterpaper, dvipsnames]{article} \usepackage[utf8]{inputenc} \usepackage{listings} % ...