7 votes
Accepted

LaTeX is not letting me add spaces in strings in lstlistings

This is not a bug, it is a feature! With your current settings, spaces inside a string will be visualized using this "bucket", as you call it. This can be especially helpful if you have more ...
  • 2,625
3 votes
Accepted

How to typeset Japanese ascii art in latex?

I think this would be a safer way of doing what you want: \ProvidesPackage{jart}[2023/03/06 Japanese ASCII Art] \RequirePackage{fancyvrb} \usepackage{fontspec} \newfontfamily\verbatimfont[% ...
  • 2,621
2 votes
Accepted

Position lstlisting below text

Welcome to TeX.SX! When you use \DeclareCaptionType you seem to basically define a new float environment. Its content will, well, float! If you don't want it to float, you can use float's [H] ...
  • 2,625
2 votes
Accepted

How to display the value of a variable inside a listings environment

\documentclass{article} \usepackage{listings} \newcommand{\xVar}{42} \begin{document} \begin{lstlisting}[escapechar=!] the value of xVar is !\xVar! \end{lstlisting} \end{document} See ...
  • 4,188
1 vote

lstlisting and newcommand conflict

You can also use Ulrich Diez's DefineVerbatimToScantokens macro (can be found in a few answers, for example https://tex.stackexchange.com/a/626166/250119) as follows: \documentclass{article} \...
  • 5,211
1 vote
Accepted

lstlisting and newcommand conflict

I'd written some code in the past for myself (one of my documentations), that allowed me to decouple input and output as far as I needed myself. The code in this answer reuses much of that code, but ...
  • 53.2k
1 vote

Rewriting non float code listings Pandoc compatibility

You could use \captionsetup{type=...} to enable features like \caption (and \label), sub-figures (via subfig or subcaption package) etc.: \documentclass{article} \usepackage{fancyvrb} \usepackage{...
1 vote

How to apply captions to non-floating Listings

Since you seem to be unable to do what a comment suggests, here is an answer that does what my comment suggested: \documentclass{article} \usepackage{fancyvrb} \usepackage{fvextra} \usepackage{xcolor} ...
  • 53.2k
1 vote
Accepted

How to apply captions to non-floating Listings

\documentclass{article} \usepackage{fancyvrb} \usepackage{fvextra} \usepackage{xcolor} \usepackage{float} \usepackage{caption} \newfloat{codelisting}{h}{lop} \floatname{codelisting}{Listing} \...
  • 14.9k
1 vote
Accepted

How to include nested captions for listings

This uses the lstlisting custom caption. \documentclass{article} \usepackage{listings} \usepackage{newfloat} %\renewcommand{\lstlistingname}{Sublisting} \DeclareFloatingEnvironment[fileext=lol,...
  • 74.2k
1 vote

tabularray and listings combability

Here is a workaround using filecontents*: \documentclass{article} \usepackage{tabularray} \usepackage{xcolor} \usepackage{listings} \lstset{ language=sql, keywordstyle=\color{black!30!blue}\...
  • 69.6k
1 vote

How to quickly change spacing of lstlisting to use two spaces instead of four?

You can use the literate key to turn four consecutive spaces to two output spaces: \documentclass{article} \usepackage{listings} \lstset{literate={\ \ \ \ }{\space\space}{2}} \begin{document} \begin{...
  • 53.2k

Only top scored, non community-wiki answers of a minimum length are eligible