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.
3,688
questions
0
votes
2
answers
30
views
How to include Latex listing in a command using minipage?
I created a \fooCmd to typeset some text in a large file.
This typesetting is using a minipage environment.
And sometimes within the minipage environment, I would like to include some LaTeX listing.
...
0
votes
0
answers
9
views
Issue with * notation for macaulay2 code
When I type this code (from A. Oneto)
\begin{lstlisting}[language=Macaulay2]
perpId := method();
perpId (RingElement) := F-> (
P := ring(F);
D := first degree F;
L := for j from 0 to D ...
0
votes
0
answers
18
views
listings - beauty table from emacs with iteral command
I would like to beauty a table output from emacs, the + looks weird. any suggestion to improve it?
\documentclass[border=2pt]{standalone}
\usepackage{listings}
\usepackage{xcolor}
\begin{document}
\...
1
vote
1
answer
2k
views
How to display colors of Octave code in latex with listings?
In my paper I include Octave code with
\usepackage{listings}
No I want that the text and numbers be written in the same colors as the are represented with in Octave. Everything is fine, except that ...
13
votes
1
answer
11k
views
How to increase the padding in the code snippet box when using `listings`?
So I am writing a book on Awk programming language, and I have enabled a single frame via \lstset{frame=single}. However, I would like the code within the snippet box to be further away from the frame ...
1
vote
1
answer
17
views
listings not cover the whole minipage area
I try to put a listing into minipage, when I set listings color to white and minipage color to grey, I found some grey color still show.
How can I make the listings cover the whole minipage area?
\...
0
votes
0
answers
34
views
redefine color pattern of listings language [duplicate]
I would like to redefine language color patter like below:
Below code works for some elements, but the numberstyle color not work
\documentclass[border=2pt]{standalone}
\usepackage{listings}
\...
2
votes
2
answers
60
views
below part not show up with standalone and listings
I try to draw on a listing with tikz overlay. but the image only show the listing, then the part out side of that region has been cut out.
\documentclass[border=2pt]{standalone}
\usepackage{tikz}
\...
1
vote
0
answers
14
views
Multiple or different indices
I am trying to write a report with different indexes, within the same document, I need to put an index, change the page and put a new index, that is, the new index begins with a new count of sections ...
2
votes
1
answer
55
views
You can't use `macro parameter character #' in horizontal mode. I can't print a code .py with special characters
I have this two simple lines of python code (test.py):
#################################################
# col.set_
and this is my latex code:
\documentclass[letterpaper,12pt]{report}
\usepackage[...
0
votes
1
answer
23
views
two symbols in escapechar in lstset (listings package) doesn't work
I am using listings package. When I include only one symbol in escapechar, Latex works fine.
\documentclass{article}
\usepackage{listings}
\lstset{escapechar=\%}
\begin{document}
\begin{lstlisting}
...
0
votes
0
answers
20
views
How can I color dot notation methods in the listings package?
I can't figure out a way to incorporate colored dot notation methods into my custom Python theme with the listings package of LaTeX.
For example, consider the following code:
1 import matplotlib....
0
votes
2
answers
174
views
How to fix spacing after multicols with lstlisting?
When combining lstlisting with multicols inside a minipage or tcolorbox, the vertical spacing of lstlisting changes. The spacing on top can be fixed by using \topskip = 0pt (see this answer with a ...
0
votes
1
answer
73
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 ...
0
votes
0
answers
24
views
Listings rendering horizontal lines randomly?
I want to display SQL queries but I keep having problems with the listings package. At one point I reduced my defined parameters just to styling and still got some horizontal lines but at random ...
1
vote
1
answer
20
views
Error when using mcode.sty package - Inserts "2D at first page
When using the mcode.sty package to include code from Matlab,
and compile it with pdflatex I am experiencing the error as follow,
(same error with TeXstudio and Overleaf):
! Missing number, treated as ...
0
votes
0
answers
27
views
What changes in Latex query can be made so that Our result is same as Image
%-----------EDUCATION & COURSES-----------
\section{Education}
\resumeSubHeadingListStart
\resumeSubheading
{State University}{Sep. 2017 -- May 2021}
{Bachelor of Science in Chemical ...
-2
votes
0
answers
24
views
Using listings with multiple styles [duplicate]
Have started using listings. The following changes the style.
Does the package allows using just one style. How can I add more
that one style ?
Although I have made two different styles, \lstset ...
17
votes
1
answer
5k
views
Recent issues with lstlinebgrd package with listings after the latter's update[September 02,2018]
I could run the program without any problem while highlighting few lines of code using listings and lstlinebgrd packages. But the recent update of listings package v1.7 is giving me error even on the ...
2
votes
1
answer
87
views
How to get zebra effect in ‘listings’? (‘listlinebgrd’ seems broken with recent ‘listings’ update)
I have just install TeXlive 2020 listings have been changed and so lstlinebgrd seem not work. How can we get back the beautiful zebra effect?
\documentclass[12pt,a4paper]{article}
\usepackage{...
2
votes
1
answer
209
views
Multicol listings and ntheorem rendering wrong
Given the quite long MWE:
\documentclass{memoir}
\usepackage[dvipsnames,table]{xcolor}
%\usepackage[showframe]{geometry}
\usepackage{mathtools}
\usepackage{needspace}
\usepackage{multido}
\usepackage{...
0
votes
0
answers
18
views
Linkbordercolor
Why does the text "Linkbordercolor" appear on my summary? I don't know what to do to remove it.
1
vote
1
answer
194
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
2
answers
163
views
How to mix markup for straight apostrophes and accented letters in a lstlisting environment?
I have a document, formatted with luatex, beginning
\documentclass[b4paper]{article}
\usepackage{expl3}
\usepackage{hyperref}
\usepackage{listings} %Requires luatex engine to handle UTF-8
...
42
votes
8
answers
37k
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
0
answers
28
views
Not sure how to get more delimeters in tcblistings environment
I am trying to define a style for metavariables in code. My WE is below...
\documentclass{article}
\usepackage{xcolor,listings}
\usepackage[most]{tcolorbox}
% define colors for code blocks
\...
2
votes
1
answer
130
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
338
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....
1
vote
1
answer
33
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
35
views
How to copy line number of lstlistings into a counter?
The last line of an lstlisting is stored in \lst@lineno --- while it can be accessed using:
\newcounter{gcpyn}
\makeatletter
\setcounter{gcpyn}{\lst@lineno}
\makeatother
trying to wrap that up in a ...
2
votes
1
answer
23
views
Capture beginning of a line in a listing delimiter in order to style diff files
I am trying to display diff files in a listing. Each added line should be green and each removed line red.
\documentclass{article}
\usepackage{graphicx}
\usepackage{listings}
\usepackage{xcolor}
\...
2
votes
1
answer
38
views
Lstlisting: check if style exists
I need to find a way to define a lstlisting style only if it was not previously defined, but I can't find how to check if a style has been previously defined or not. How could I do that?
MWE
\...
2
votes
0
answers
459
views
Tcolorbox, minted and listing without caption
I'm trying to have a non-captionned listing using tcolorbox and minted.
I've made a macro that automates the task, with the title of the snippet as optional argument.
My goal is, when the optional ...
1
vote
1
answer
48
views
Using overlays and listings
My beamer presentation has a slide with some code on it which is presented with the lstlisting environment. A specific line should only appear on a second version of the slide (overlay). Basically, I ...
0
votes
0
answers
42
views
Listings hook to detect whether the current line contains a colon?
TL;DR: I want to use the listings package for typesetting YAML snippets. For example:
\begin{lstlisting}[language=yaml]
key: value
list:
- value1
- value2
env:
key1: value1
key2: value2
\end{...
0
votes
1
answer
371
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{...
0
votes
1
answer
71
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 ...
1
vote
1
answer
301
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 ...
1
vote
1
answer
33
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 ...
1
vote
2
answers
44
views
Lstlisting border gaps
Im trying to highlight a line of code in a a lstlisting with a frame. However, when i render it, there is a tiny gap in the frame
\documentclass{report}
\usepackage{graphicx} % Required for ...
0
votes
0
answers
33
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 (...
1
vote
1
answer
578
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
122
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 ...
3
votes
1
answer
93
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}
\...
2
votes
4
answers
1k
views
Failed to compile Wiley NJD v5 latex template zip downloaded from Wiley official
Following the author guideline, I downloaded Wiley NJD v5 template zip file from the official site.
Then, as I following the author-guideline.pdf inside the zip file to compile the tex file, it failed....
0
votes
0
answers
29
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 ...
0
votes
1
answer
233
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?
1
vote
1
answer
46
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,
%...
0
votes
1
answer
47
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 ...
0
votes
1
answer
212
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 ...