我的代码如下:
\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}
输出
请指教如何实现这一点...
PS:不想给出回车标记,像一些标签\vspace{4pt}
等......
答案1
更新
一种方法是分割环境并在中间添加一些空间。
如果这只是罕见的现象……
或者在列表行之间添加一些空格
\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}