Increase space between lines (not globally) by using fancyvrb

fancyvrbspacing

My codes are follows:

\documentclass{book}
\usepackage{xcolor}
\usepackage{fancyvrb}%
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{fontsize=\small,commandchars=\\\{\}}
\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}}
\newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\begin{document}

\begin{Highlighting}[]
\DecValTok{5} \SpecialCharTok{+} \DecValTok{32}
## [1] 8
\DocumentationTok{\#\# this is the start of an R script}
\DocumentationTok{\#\# the heading provides some information about the file}
\DecValTok{5} \SpecialCharTok{+} \DecValTok{32}
## [1] 8
\end{Highlighting}

\end{document}

Output

enter image description here

Please advise how to achieve this…

PS: Don't want to give an enter mark, like some tag \vspace{4pt}, etc…

Best Answer

UPDATE

One way would be to split the environment and add some space in the middle.

If it's just a rare occurrence ...

Or add some space between the lines of the listing

e

\documentclass{book}
\usepackage{xcolor}
\usepackage{fancyvrb}%
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{%  
%       frame=single,framesep=0mm,framerule=0.1pt,
%       rulecolor=\color{green},
    fontsize=\small,commandchars=\\\{\}}
\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}}
\newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\SpaceTok}[1]{\vspace*{-10pt}}

\begin{document}
    
\begin{Highlighting}[]
    \DecValTok{5} \SpecialCharTok{+} \DecValTok{32}
    ## [1] 8
    \DocumentationTok{\#\# this is the start of an R script}
    \DocumentationTok{\#\# the heading provides some information about the file}
    \DecValTok{5} \SpecialCharTok{+} \DecValTok{32}
    ## [1] 8
\end{Highlighting}

\centering aprox. 4pt added   to baselineskip = \the\baselineskip

\begin{Highlighting}[]
    \DecValTok{5} \SpecialCharTok{+} \DecValTok{32}
    ## [1] 8
\end{Highlighting}
\vspace*{\dimexpr -2\baselineskip+8pt} % add ~ 4pt <<<<<<<<<<<<<<<<<<
\begin{Highlighting}
    \DocumentationTok{\#\# this is the start of an R script}
    \DocumentationTok{\#\# the heading provides some information about the file}
    \DecValTok{5} \SpecialCharTok{+} \DecValTok{32}
    ## [1] 8
\end{Highlighting}

\begin{Highlighting}[]
    \DecValTok{5} \SpecialCharTok{+} \DecValTok{32}
    ## [1] 8 \raisebox{0pt}[0pt][8pt]{}  % add ~ 4pt <<<<<<<<<<<<<<<<<<
    \DocumentationTok{\#\# this is the start of an R script}
    \DocumentationTok{\#\# the heading provides some information about the file}
    \DecValTok{5} \SpecialCharTok{+} \DecValTok{32}
    ## [1] 8
\end{Highlighting}
    
\end{document}
Related Question