minted
minted copied to clipboard
Standard gap between normal text flow and minted code.
Hello!
There is some code.
Some text here.
\begin{minted}[linenos]{text}
40xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
\end{minted}
And some text here.
And a screenshot.
Can someone help to reduce space before and after minted code? To make coded looks like normal text.
The gap is the normal list gap added by fancyvrb
package. You can use fancyvrb
option listparameters
to eliminate it. Unfortunately, this option is undocumented in fancyvrb
's doc, and not inherited by fvextra
, nor minted
. In short, you can use \fvset{listparameters=...}
to alter the gap and you can only use this way.
To get to know what dimensions affect "list gap", the picture in https://latexref.xyz/list.html#list and Figure 1 in doc of enumitem
package both help.
Full example:
\documentclass{article}
\usepackage{minted}
\begin{document}
\subsection*{Before}
Some text here.
\begin{minted}[linenos]{text}
40xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
\end{minted}
And some text here.
\fvset{listparameters=\setlength{\topsep}{0pt}\setlength{\partopsep}{0pt}}
\subsection*{After}
Some text here.
\begin{minted}[linenos]{text}
40xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
\end{minted}
And some text here.
\end{document}
PS: What a coincidence that I have just found that option (from fanvyvrb
's source code) one hour ago and then encountered corresponding questions both on TeX.SX and at here.
@muzimuzhi Thanks for that! I will add minted
support for listparameters
in \setminted
. I will also look into adding listparameters
to the fvextra
documentation of undocumented fancyvrb
features. It might also be worth contacting the fancyvrb
maintainer to see about getting it added to the official documentation...there have been a few fancyvrb
updates recently, so it might get added.
@gpoore
I will add
minted
support forlistparameters
in\setminted
. I will also look into addinglistparameters
to thefvextra
documentation of undocumentedfancyvrb
features.
Maybe this is a chance to finish #208 altogether. Currently option fontencoding
is added to fvextra
but not minted
.
It might also be worth contacting the
fancyvrb
maintainer to see about getting it added to the official documentation...there have been a fewfancyvrb
updates recently, so it might get added.
There might be more undocumented fancyvrb
options, for example formatcom*
. It can be used to append code to formatcom=<code>
.
I will contact the fancyvrb
maintainer after a thorough source reading. Also, I have mailed to hvoss (his tug email address) about some problems including this one at July 2019 and have not received any response till now. I will try again.