Skip to main content

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
0 votes
0 answers
28 views

How to reconcile literate and \lst@BeginAlsoWriteFile?

I am currently trying to write the source code in the lstlistings environment to a file and read it using luaLatex. However, I found that the characters specified for literate in the language styling (...
博ノ助's user avatar
3 votes
1 answer
85 views

How can I replace the single quotation mark with another one in the listings package?

\documentclass[a4paper,12pt]{book} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{lmodern} \usepackage{listings} \usepackage{xcolor} \usepackage{graphicx} \usepackage{tcolorbox} \...
Özgür's user avatar
  • 3,344
0 votes
0 answers
23 views

lyx errors on export (with code listings) - Argument of <?> has an extra a} [closed]

I've been using Lyx for many years, but not in any advanced way. This time I'm using "listings" in included child documents - and this seems to be causing errors on export I don't understand....
Penelope's user avatar
  • 217
0 votes
0 answers
26 views

listings package required but not supported in template [duplicate]

I am getting an error when I am trying to compile a big template document. The document loads the package lstmisc.sty, but when loaded I get a error that says this package listings.sty version 1.10a ...
kpr62's user avatar
  • 111
1 vote
1 answer
39 views

German umlaut at listing settings

May I know how can the Umlaut ü (Tür) be shown in the listing settings? I couldn't find the online examples in the listing setting. Thanks for any help! \documentclass[ ngerman, 11pt, %...
user12595983's user avatar
0 votes
1 answer
30 views

Code Block - overflow border

I wanna (1) use the colour and (2) avoid code overflow the border any suggestions for debugging? I don't know why the code doesn't work and tried // as quick fix as deadline coming, but failed. The ...
user12595983's user avatar
1 vote
1 answer
45 views

listings keywordstyle does not work inside NiceTabular

As you see above, I customized some keywords to show up in gray. This works for tabular but not NiceTabular environment My MWE \documentclass{article} \usepackage{fancyhdr} \pagestyle{empty} \...
Al-Motasem Aldaoudeyeh's user avatar
0 votes
1 answer
36 views

The listings package and side-by-side code listings

I'm using the listings package liberally in an article. However, I want to show some code listings side-by-side and for those i use the subfigure package: \begin{figure*} \begin{subfigure}{0.49\...
Gaslight Deceive Subvert's user avatar
1 vote
0 answers
30 views

\begin{listing} environment taking full page width when used inside of \begin{itemize} environment

I am using \begin{listing} environment inside of \begin{itemize} environment. But the listing output is taking full page width instead of the itemize environment width. Here is the complete example: ...
AKASH YADAV's user avatar
0 votes
1 answer
56 views

Changing the commentstyle color for an existing language in listings?

Consider the following MWE: \documentclass{article} \usepackage{xcolor} \usepackage{listings} \begin{document} Hello World! \begin{lstlisting}[language=C] // this is a main function int main(int ...
sdbbs's user avatar
  • 247
3 votes
1 answer
147 views

How to format code in the style used in academic papers?

I came across a scientific article that features beautifully formatted code, as shown in the image below. I'm interested in using a similar style for my own article, but I'm not sure how to achieve ...
drobilc's user avatar
  • 161
1 vote
1 answer
23 views

Listings over multiple pages affects header style

I am currently using titlesec (which includes titleps) for my page formatting, and listings to format code. Things worked out well until I entered a long piece of code which spans through multiple ...
WishofStar's user avatar
1 vote
1 answer
60 views

Special characters in \lstinline cause an error when used in tcbox

I am trying to create a tcolorbox style for LaTeX listings. Although listings styles work as desired, using \tcbox command with \ Improper alphabetic constant Using { and } bracks causes the ...
Al-Motasem Aldaoudeyeh's user avatar
0 votes
0 answers
25 views

package pythonhighlight isnt rendering in LyX 2.3.7

when I use this package in LyX it doesn't render at all without raising any errors. the same code on overleaf works completely fine and as intended. here's a picture from lyx of the code itself and ...
Nate3384's user avatar
  • 197
2 votes
1 answer
32 views

How to get a listing and other content in a table to align to the top?

I wrote a table with code on the left side and an answer box on the right. Also tested with ordinary text on the right. With the answer box inserted, the listing appears to align to the bottom of the ...
Dov's user avatar
  • 1,543
0 votes
0 answers
22 views

ubuntu terminal emulator: how to remove horizontal translucent lines

I was using this from Alan Xiang's Blog to emulate an ubuntu terminal in latex. However, with multiple lines, some translucent horizontal lines appear, that make it less attractive to look at. I would ...
Pedro's user avatar
  • 1
3 votes
2 answers
125 views

Bug with colors when trying to paste C++ code into LaTeX [duplicate]

I have already dealt with a similar problem, that I can’t make the colors in the Text work properly! Now I've switched to the code and made other settings so that they don't conflict, but I'm getting ...
Dmitry's user avatar
  • 145
3 votes
2 answers
89 views

Missing vertical space at section end due to lstinputlisting

I have discovered that if a section contains an \lstinputlisting, the following section title will be typeset without the usual vertical skip (even if the listing is not the last vbox)... but only if ...
amonakov's user avatar
  • 1,012
0 votes
0 answers
16 views

How to use thicker backslash with listings verbatims? [duplicate]

As seen above, \textbackslash is thinner than what we get by default. I literate \ because I want to get flexibility to adjust all special characters of interest My MWE \documentclass[11pt, a4paper]{...
Al-Motasem Aldaoudeyeh's user avatar
1 vote
1 answer
69 views

Formatting C++ code in LaTeX with colors [duplicate]

I'm trying to integrate C++ code into LaTeX text so that I can visually write explanations of the code or write a specific type of problem. It is very important to understand that I am not trying to ...
Dmitry's user avatar
  • 145
1 vote
0 answers
42 views

Allowing line breaks in listings causes parenthesis to lose their color [duplicate]

I am trying to create a listings style to highlight LaTeX codes. Enabling breaklines seems to remove customized color in literate option The same issue is reported in Problem with literate and ...
Al-Motasem Aldaoudeyeh's user avatar
1 vote
1 answer
27 views

htlatex listings emergency stop

I am trying to generate some HTML (using htlatex) from a very simple .tex-file containing some listings. If I do not set my own style, it proceeds as expected and generates the HTML, but when I choose ...
Rewbert's user avatar
  • 111
1 vote
1 answer
23 views

`@` in minted SHACL/SPARQL listing introduces an unwanted hyperlink

I want to display a SHACL listing in my paper. It seems that there is no dedicated SHACL lexer but the SPARQL lexer is fine for my purposes. However, for some reason, the @ symbol at the start of my ...
John Doe's user avatar
  • 231
1 vote
1 answer
27 views

Redefining cleverefs multirangeformat for line numbers of listings

I would like to redefine cleverefs \crefrangeformat and probably also \crefmultirangeformat for the line numbers of a listings package. Consider e.g. the MWE below \documentclass{article} \usepackage{...
LaTeChiMan's user avatar
1 vote
1 answer
18 views

Unwanted indent in lstlisting [duplicate]

I am using listings to explain pieces of a code, but the PDF adds unwanted indentation. How to remove it? Here is a MWE: \documentclass[12pt, twoside, openrigt, a4paper]{memoir} \usepackage{xcolor} \...
Brasil's user avatar
  • 1,380
1 vote
0 answers
26 views

Lstlisting doesn't highlight keyword

I have the MWE below. However, the keyword \getit is not highlighted. How to turn it blue? \documentclass[12pt]{memoir} \usepackage{xcolor} \usepackage{listings} \lstset{ basicstyle=\...
Brasil's user avatar
  • 1,380
0 votes
1 answer
37 views

Does IfPackageLoadedTF neutralize xpatch?

This is an admittedly strange question. The background is the suggestion from StackExchange to use package xpatch to keep latexmk running a TEX file although included graphic files or in this case ...
user2609605's user avatar
3 votes
1 answer
37 views

Double caption on Listing (one on top and one below but I just want the one below)

I have tried to include SQL code in my text. Unfortunately I am not very familiar with it and have cobbled together the code from various forums. Now, as the title says, I have two captions for the ...
FloB's user avatar
  • 75
3 votes
1 answer
35 views

Code shows in Greek letters

I have been trying to insert an Octave function in my paper but when I build the pdf the letters are all turned into greek.(The rest of the paper is written in greek). What is even weirder is that ...
I Like Algebra's user avatar
0 votes
1 answer
36 views

Typesetting Zig Programming Language: Seeking Listing or Minted Environment

As I delve into the Zig programming language, I'm exploring options for effectively typesetting code snippets in my documents. While LaTeX offers powerful tools like the "listing" and "...
ignis_datta's user avatar
2 votes
2 answers
33 views

Caption of listing uses wrong font

I am using the KOMA script class scrreprt and would like to change the standard document font. But I noticed inconsistent font styles in the caption of listing-environments. The following is a minimum ...
flgei's user avatar
  • 53
0 votes
1 answer
34 views

Adding horizontal blank space in listing

\documentclass[12pt] {article} \usepackage{listings} \usepackage{titlesec} \usepackage[shortlabels]{enumitem} \def\baselinestretch{2.0} \setlength{\evensidemargin}{-0.15cm} \setlength{\oddsidemargin}{-...
Manjoy Das's user avatar
0 votes
0 answers
25 views

Listings produces 'misplaced \noalign' when including a LaTeX array

The following MWE demonstrates how valid LaTeX code produces a Misplaced \noalign error when the LaTeX code is to be displayed with listings. How can this be fixed? \documentclass{scrartcl} \...
Marius Hofert's user avatar
0 votes
0 answers
45 views

How can I update new command of Mathematica?

This is my code \documentclass[12pt]{article} \usepackage{listings,xcolor} \ProvidesPackage{latexalpha2Win} \lstset{language=Mathematica} \lstset{basicstyle={\sffamily\footnotesize}, numbers=...
John Paul Peter's user avatar
1 vote
0 answers
21 views

lstlistings: making backslash an ordinary character [duplicate]

I'm trying to use the listings package to format code in Isabelle/HOL. Fortunately, someone has already done most of the hard work for me by defining the language for the listings package. ...
John's user avatar
  • 457
0 votes
0 answers
17 views

\lstnewenvironment with broken page breaks

I have the following environment set up: \lstdefinelanguage{prompt}{} \lstnewenvironment{prompt}{% \lstset{language=prompt, frame=none, aboveskip=1.5mm, belowskip=1.5mm, ...
Duarte's user avatar
  • 1
0 votes
1 answer
27 views

Changing the name of lstlisting

Is it possible to change the name of the lstlisting environment from the listing package?
Louis Lascaud's user avatar
1 vote
1 answer
34 views

Avoid spaces before and after `std::cout` in listings

In this example: \documentclass{article} \usepackage{listings} \lstset{ language=c++, extendedchars=true, inputencoding=utf8, literate={::}{{::}}2 } \begin{document} \begin{...
nowox's user avatar
  • 1,417
0 votes
2 answers
48 views

Incorrect C++ code formatting of pointer near char using listings package and lstlistings

I try to do simple hello world of C++ in LaTeX with listings package. Better one time to see. Here the code: \begin{figure} \begin{lstlisting}[language={[11]C++}, %float, keepspaces=...
leanid.chaika's user avatar
0 votes
1 answer
37 views

How to add a line break in bold text in a code listing

I need to bolden some text within a code listing and for that I am using using the following code that uses mathescape=true and \textbf in a lstlisting: \begin{lstlisting}[language={}, basicstyle={\...
Priyshrm's user avatar
  • 187
2 votes
3 answers
74 views

How to change font size **only** for \lstinline{}?

At first sight, this may look as a duplicate of another question already closed as a duplicate of this one. But it isn't ;-) How do I set globally the font size of all \lstinline macros, independently ...
Pedro Sánchez Terraf's user avatar
0 votes
0 answers
27 views

framextopmargin not working listings.sty

Tried with \documentclass{article} \usepackage{xcolor,listings} \usepackage{showframe} \begin{document} \lstset{% frame=leftline,% framerule=3pt,% framextopmargin=20pt, rulecolor=\color{...
GowriSaro's user avatar
  • 572
0 votes
0 answers
20 views

Highlighting a Keyword with a Red Rectangle in listings Environment (XML Language)

How can I highlight the keyword myINSTRUMENT with a red rectangle inside a listings environment (using language=xml)? Please see below MY CODE, MY OUTPUT and MY DESIRED OUTPUT. MY CODE: \documentclass{...
Marco Moldenhauer's user avatar
1 vote
1 answer
18 views

how to make the caption showup without caption text in `lstlisting` environment?

I found that only the non-empty caption text make the caption appear in outputed file, even a sapce character \ . Here's an example: \documentclass{article} \usepackage{listings} \lstset{ language=...
On_My_Way's user avatar
0 votes
0 answers
59 views

lstlisting and tcolorbox - line numbers margin

I want to get my code look something like this: but I have problems with the line number position, it's on the box line. \documentclass{scrartcl} \usepackage[a4paper,top=2cm,bottom=3cm,left=3cm,...
sp8cky's user avatar
  • 53
0 votes
0 answers
54 views

Is there any way to use code in lstlisting with utf8 characters?

I have code embedded in LaTeX containing a UTF-8 character like a greek letter. In many modern languages this is perfectly legal, but LaTeX hates it. is there any way to include a source code file and ...
Dov's user avatar
  • 1,543
0 votes
2 answers
90 views

From listing 1. to 1. listing in \autoref of a lstlisting

I'm using listings to display code in my document, and all is okay, or I was able to find a solution, except for one problem. When I autoref a listing, it references as "listing 1." in the ...
meszolym's user avatar
0 votes
1 answer
54 views

Highlighting on lists of strings and lists of numbers in a listing

I am following the format used by this answer to color a json listing on my document, but I noticed that in a list of strings and a list of numbers, only the first element gets colored properly. Is ...
nottelling's user avatar
1 vote
1 answer
46 views

Code listing with Title above it?

I recently checked one of my Professor's tests and saw that his questions involved some code blocks that that have title for it, with a box surrounding it and horizontal lines that do not extend to ...
Juan De Castro's user avatar
0 votes
0 answers
16 views

multiple lstlisting for commands and outputs [duplicate]

I wanted to have some commands and outputs in my document. Is it possible to have two seperate lstlistings? The command would be: \begin{lstlisting}[language=cl, caption = Command Caption, label=...
MSH's user avatar
  • 101

1
2 3 4 5
72