Stack Exchange Network

Stack Exchange network consists of 175 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.

2
votes
1answer
20 views

Missing space after parenthesis in inline text

\documentclass{book} \usepackage[utf8]{inputenc} \usepackage[english]{babel} \usepackage{listings} \lstdefinestyle{General} { basicstyle=\small\ttfamily, breaklines=true } \lstset{style=...
2
votes
1answer
21 views

Listings: Inline text too small in headlines

\documentclass{book} \usepackage[utf8]{inputenc} \usepackage[english]{babel} \usepackage{listings} \lstdefinestyle{General} { basicstyle=\small\ttfamily } \lstset{style=General} \begin{...
0
votes
1answer
17 views

lstlisting - line number gaps

Is it possible to add non-number characters on the left of a code block? Specifically, I want to add ... to correspond with some source code (see image).
0
votes
0answers
16 views

How to remove the extra margin on top and bottom of a long listing [on hold]

Problem: A long listing in a two-column document occupies the entire column, and doesn't allow any text to appear above or below it. What I would like to achieve: a listing which is positioned at the ...
1
vote
0answers
38 views
+50

How do I customize Circuit_macros in listings?

MWE; \documentclass{article} \usepackage{xcolor} \usepackage{listings} \definecolor{Others}{RGB}{0,110,40} % Green \definecolor{Character}{RGB}{146,76,157} % Purple \definecolor{Number}{RGB}{176,...
0
votes
0answers
21 views

Listings escapeinside bold text

\documentclass{article} \usepackage{listings} \lstset{ framesep=5pt, frame=single, captionpos=b, aboveskip=3mm, belowskip=3mm, showstringspaces=false, columns=flexible, ...
0
votes
0answers
17 views

Increase lstlisting vertical space in toc

I have found this post but the solution is not working for me. Grouping the list of listings by chapter I am using the package listings \usepackage{listings} \lstdefinestyle{sharpc}{language=[Sharp]...
1
vote
1answer
28 views

How to redefine comment character using literate

I would like to render the comment character differently, specifically I would like to render Ada's double dash as a long dash. Using literate=*{--}{{---}}1 achieves the mapping, but unfortunately ...
0
votes
0answers
28 views

Formatting of C language using listings

Consider the following code segment in C: int llvm_test_diagnostic_handler(void) { LLVMContextRef C = LLVMGetGlobalContext(); LLVMContextSetDiagnosticHandler(C, &diagnosticHandler, &...
1
vote
0answers
37 views

Reduce distance between listings and their captions

I'm using the KOMA scrbook class to write my thesis. I have source code blocks that I wish to display with minted. An MWE can be seen here: % Intended LaTeX compiler: pdflatex \documentclass{scrbook} ...
0
votes
1answer
39 views

Coding formatting (C language)

I have a code in C language. I wish to set the margin numebers and the symbols (e.g., (, ), {, }, =, >, etc.) in white. I am working using the following format, but without any real result. \...
1
vote
1answer
54 views

Quotation marks and hyphen in listings generate un-copyable PDF

I'm writing a document for general purpose so that anyone can follow it and the idea is to copy and paste this command in a Linux terminal. But when I do that in a terminal give me error because ...
1
vote
1answer
25 views

Editor breaks line within lstlisting

I'm using an editor that breaks lines after a line length of 80 characters. Whenever I use a long lstinline at the end of a line and the editor continues in a new line I get the error message Package ...
1
vote
1answer
22 views

Color delimiters in listings differently from content

I am trying to implement syntax highlighting in listings for XML. As a follow-up to this answer, I have tried to grey-out the delimiters themselves, but have not had much luck despite a few attempts: ...
4
votes
1answer
43 views

Adding `otherkeywords` in listings - How do I avoid highlighting them inside strings?

I'm using the listings package for Python code, and I have set otherkeywords={self,__init__} An unintended side-effect of this seems to be that in a string such as "self_loathing" the self portion ...
1
vote
0answers
19 views

long listings with pandoc-crossref doesn't fit on page

Let's consider input file: ```{#lst:code .html caption="Listing caption"} <!DOCTYPE html> <html> <br /> <br /> <br /> <br /> <br /> <br /> ...
1
vote
1answer
68 views

pandoc --listings breaks styling of code block

Considering this input file: ~~~{.html caption="test caption"} <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Store</title> </head>...
1
vote
2answers
145 views

How to keep listing contiguous

I am writing a book with relatively long code listings. How can I keep the code contiguous and not have text and figures inserted, which break the flow of the listing. The only way I have found so far ...
0
votes
0answers
10 views

How do I keep morekeywords from being highlighted in a comment?

Say I have the following listing style: \lstdefinestyle{custCpp}{ language=c++, keywordstyle={\bfseries}, % keyword color keywordstyle = [2]{\color{blue}\bfseries}, otherkeywords = {...
3
votes
2answers
90 views

Hexadecimal line numbers in listings

Is it possible to introduce hexadecimal line numbers in steps of two using the listings package? In the MWE \documentclass{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{...
1
vote
0answers
30 views

How to get noweb and listings to cooperate?

The introduction of the Linux subsystem for Windows has made it possible again to use noweb under Windows. I'd like to pretty-print the resulting code, for which arguably the listings package is the ...
0
votes
1answer
101 views

How to import my R codes in TeXnicCenter

This package is basically writting R codes in LaTeX but I am typing codes in TeXnicCenter when I use this command it doesn't work to copy codes from R. Please tell me how I can write my R codes in ...
0
votes
0answers
19 views

Error when trying to install listings package in MikTex [duplicate]

I'm trying to install the 'listings' package through MiKTeX package manager and I get the following error: MiKTeX Problem Report Message: parse error - unexpected end of input; expected '}' MiKTeX: 2....
1
vote
0answers
27 views

Roman to Arabic Listing Caption Numbering [closed]

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
20 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
55 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
20 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
32 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
32 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
116 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
32 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
44 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
63 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
39 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
61 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
26 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
27 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
72 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
31 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
26 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
35 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
46 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
59 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
85 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
60 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
34 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
33 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
38 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
41 views

listings interfering with babel

Consider this script: \documentclass{article} ...
1
vote
0answers
46 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]{...