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.

0
votes
0answers
2 views

Strange listing alignment behaviour with and without a frame

Consider the following code which does an alignment experiment with listings. We are interested in the behaviour aboveskip and belowskip with and without a frame. % -----------------------------------...
0
votes
1answer
7 views

Listing in a command error: Text dropped after begin of listing on input line

While I wanted to test some alignment options to ask another question regarding to listings, I have encountered a problem that I was not expecting. Consider the following code: % Preamble \...
2
votes
1answer
45 views

Escaping $ in listings environment

I'm trying to escape the dollar sign within listings for TeX language but it is not working. I have tried this post without any success. This is the MWE: \documentclass[border={10pt 10pt 10pt 10pt}]{...
0
votes
1answer
24 views

How to enable contextual substitutions in lstlisting?

Fira Code (available via its GitHub Release page) not only provides fancy programming ligatures (see Use Fira Code font with ligatures in code listings), but also contains contextual substitutions. ...
3
votes
0answers
25 views

How to change \lstinline{} font size? [duplicate]

I have the following example. I use \lstinline{} command to provide code within latex text. However the font size seems to be small. Please if you know how to to trigger this please let me know. ...
1
vote
1answer
19 views

Highlight new C++ keywords introduced in C++11, C++17, and C++20 in the listings package

C++11 added a bunch of new keywords: alignas, alignof, constexpr, etc. But they don't seem to be supported by the listings package. \documentclass{article} \usepackage{listings} \usepackage{xcolor} ...
0
votes
1answer
34 views

How do I use special characters from the danish alphabet as a part of keywords when using listings?

Im writing a report in overleaf about a programming language im making, I want to be able to use listings to have the syntax of the language highlighted in the report, however since the programming ...
0
votes
1answer
32 views

Why I get opposite brackets at listing code?

I'm writing Hebrew document and the brackets at the code are opposite. They are ok at the regular mode but when I change the font style the brackets became opposite: And here is MWE: \...
0
votes
1answer
22 views

Define an environment that by default load some options

Is there a way to define a new listings environment with some listings options by default? For example, I am hoping to define a new environment, say myenv, such that \begin{myenv} \end{myenv} and \...
0
votes
1answer
28 views

Listings environment with mathmode on every line [closed]

I wanted to create an environment that replicates the listing environment, but formats all text as inline math. Basically, I want something like this: \begin{myenvironment} \alpha \beta &...
0
votes
1answer
12 views

Treatment of space in quotation marks in listings

Consider this example: \documentclass{report} \usepackage{listings} \begin{document} \begin{lstlisting}[language=sh] command "A B" \end{lstlisting} \end{document} the output is: The replacement of ...
2
votes
2answers
43 views

Multiple listing styles with caption package

This question is mainly related to Multiple listings styles. If I have \usepackage{caption} definition in the head of file, list of custom listings disappear. How to make it work? \documentclass{...
0
votes
1answer
18 views

Define a new caption in a new listing environment by overriding caption setup for lstlisting

This issue is mainly realated to Define a new caption in a listing environment. I want to define caption setup for default lstlisting but also want to define caption setups for new listing ...
9
votes
1answer
134 views

How to use lstlisting with tcolorbox?

I want to insert lstlisting inside a tcolorbox which must has a title and title can be hidden whenever I need, also it's top right and bottom left corner will be rounded something like this: I know ...
2
votes
2answers
61 views

Listings for OCaml and quotes

The listings syntax highlighting for OCaml breaks whenever the OCaml literal character '"' appears in the source. It's not possible to let the language definition treat single quotes as a delimiter ...
0
votes
0answers
14 views

How to highlight word in listings that starts/ends with specified character?

I want to highlight function name in code, which is a word that ends with left parenthesis, like sqrt(), but don't want to highlight the parenthesis. Here is what I got so far, I learnt this from ...
0
votes
0answers
11 views

How to highlight C/C++ header file names with the listings package? [duplicate]

C/C++ header files can be given in two forms: <foo> or "foo". For example: #include <iostream> #include "myheader.hpp" By default, listings does not recognize the first form, and regards ...
5
votes
1answer
64 views

Listings color context sensitive keywords (Matlab)

In Matlab there's two ways to use end: to end ifs, whiles etc. to refer to the last item in an array/vector (example: v(end) or v(end-1)). I want to use listings to include some matlab code in my ...
0
votes
2answers
36 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 ...
1
vote
1answer
38 views

Error with listings and baposter

I want to include listings in my baposter poster but I get the following error if I do: ! Paragraph ended before \lst@next was complete. <to be read again> \par l.288 } ...
2
votes
1answer
27 views

Using a language dialect in listings

I don't understand why the following document does not compile: \documentclass[letterpaper, 11pt, onecolumn]{article} \usepackage{lipsum} \usepackage{listings} \lstloadlanguages{[11]C++,[ISO]C++} \...
0
votes
0answers
28 views

Title space of List of listings is too small

I am encountering the problem that the space between the title and the actual list is too small no matter what I do. But this issue only exists regarding the list of listings. All other lists (e. g. ...
1
vote
0answers
22 views

listing - Tabs are shown as ^^I [duplicate]

I used the code from here to write some java code in beamer that uses the Luebeck theme. \documentclass[11pt]{beamer} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{lmodern} \...
0
votes
0answers
49 views

Change caption setup in listing/minted environment [duplicate]

I would like to change the appearance of the caption of a code snippet that I have created with minted and listing. However, using \captionsetup[listing]{<options>} does not change anything. ...
0
votes
0answers
18 views

Cut off content in listings that is too long

I am converting an md to a PDF. My listings contain both code and the repl output. The output is sometimes too long, so I just want to cut it off. However, I cannot find a switch that allows me to cut ...
3
votes
1answer
23 views

Listing within tabular — alignment

I have the following code where $q_1$ aligns in the middle. I would like to align it with the top line (SELECT). Is there a way to do that? \documentclass{article} \usepackage{listings} \lstset{...
1
vote
1answer
40 views

How can I use the listings package with more than one language?

I am writing a book that will include code in two languages (R and SAS). I know I could use \verbatim or \alltt to set the code sections, but the listings package has some nice features. Is there a ...
0
votes
0answers
36 views

To typeset LaTeX code using listings package: [AlLaTeX] dialect instead of [LaTeX] dialect for additional identifiers?

To typeset LaTeX code using the listings package, the typical advice is to specify the LaTeX dialect via the language = [LaTeX]{TeX} key-value pair in a \lstset command. (E.g., Joseph Wright's answer ...
0
votes
1answer
39 views

Caption fontsize in a listing using minted

With listing and minted and a pycon lexer to emulate an IPython console, I'd like to change the caption font size to be footnotesize. Unfortunately, my code below does not change the fontsize of the ...
3
votes
2answers
39 views

Listings applies keywording where it shouldn't

I want to implement Python code inside a LaTeX file. A minimalistic example follows \documentclass[12pt]{report} \usepackage{listings} \usepackage[dvipsnames]{xcolor} \begin{document} \newcommand\...
0
votes
1answer
34 views

Listings breaklines at predefined places

The code lines I write within a lstlisting sometimes are too long. So at the end a line break occurs. But sometimes these breaks are not well chosen and can make the code much more unreadable. Is ...
0
votes
0answers
72 views

LaTeX error message

I have a hard-to-understand LaTeX error on the R Win-builder test website. My R package stationery has examples of LaTeX (Sweave or knit) and R markdown documents. The documents all build fine on my ...
0
votes
1answer
42 views

Recent issues with lstlinebgrd package with listings after the latter's update [extension]

This question is in continuation of the earlier question in which it has been modified to include background color along with linebackground color in few lines of code. MWE is given below: \...
6
votes
1answer
77 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=...
3
votes
1answer
28 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{...
3
votes
2answers
69 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). I am currently using commands to stop / ...
2
votes
1answer
119 views

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
23 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]...
2
votes
1answer
39 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
39 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, &...
5
votes
3answers
144 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
44 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. \...
2
votes
1answer
61 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
35 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 ...
2
votes
1answer
31 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: ...
5
votes
1answer
53 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
31 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 /> ...
2
votes
1answer
152 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
155 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 ...
2
votes
0answers
18 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 = {...