Too many spaces after verbatim command

If I put the following LaTeX code:

\begin{singlespace} \begin{verbatim} 

There are too many spaces before the text inside these tags. It looks like there are two line breaks. Is there any way to reduce this gaps?

+4
source share
2 answers

In many environments, a default environment is placed around their contents. The correct way, most likely, will determine how the variable defining this space is called, and modify it (temporarily or for the whole file). However, for a quick and dirty fix, you can simply use some negative vspace:

 Lorem ipsum... \vspace{-1ex} \begin{strangedays} % ... 
+2
source

latex.ltx look at the core LaTeX ( latex.ltx ) shows the definition

 \def\@verbatim{\trivlist \item\relax \ if@minipage \else\vskip\parskip\fi [...] 

In other words, it adds \parskip at the beginning, unless verbatim is executed in minipage mode.

So try using

 \begin{quote} \begin{verbatim} ... \end{verbatim} \end{quote} 

Thus, verbatim runs in minipage mode and will not add \parskip at the beginning.

Usually you want to add some indentation when quoting source code or the like with verbatim , so using quote is what you want to do anyway.

+1
source

Source: https://habr.com/ru/post/1285659/


All Articles