减少诗句环境前后的空间

减少诗句环境前后的空间

我想在文档中全局减少诗句环境前后的垂直空间。 MWE 显示了问题,输出如下: 图片

我不想使用其他软件包,因为我想学习一些低级命令。我知道这verse取决于list环境。相关答案 (如何消除诗句环境前后的垂直空间?) 似乎过于复杂,并且使用verse包(而不是内置版本)。当然有办法

\setlength{\versesep}{0pt}

或者类似的东西?

或者(因为我正在使用xpatch包),我可以做类似的事情

\xpatchcmd\verse{\...

但我不知道如何找到该verse环境的原始代码,所以我不知道要修改哪一行。

\documentclass[12pt,oneside]{article}

\setlength{\parindent}{0pt}
\setlength{\parskip}{1em}

\begin{document}

This is a paragraph.

This is another paragraph.  Separated nicely.

\begin{verse}
This is some\\
lovely verse,\\
that has too much space\\
on top and below.
\end{verse}

I would really like not as much space above and below.  Just one parskip would be sufficient.

But other paragraphs should be spaced with parskip.

\end{document}

答案1

\parskip通过减少来删除添加的\topsep

\documentclass[12pt,oneside]{article}
\usepackage{xpatch}

\setlength{\parindent}{0pt}
\setlength{\parskip}{1em}
\xpatchcmd{\verse}{\itemsep}{\advance\topsep-\parskip\itemsep}{}{}

\begin{document}

This is a paragraph.

\begin{verse}
This is some\\
lovely verse,\\
that has too much space\\
on top and below.
\end{verse}

I would really like not as much space above and below.  Just one parskip would be sufficient

I would really like not as much space above and below.  Just one parskip would be sufficient

\end{document}

在此处输入图片描述

答案2

如果没有其他软件包,可能是这样的:

\documentclass[12pt,oneside]{article}

\setlength{\parindent}{0pt}
\setlength{\parskip}{1em}

\let\oldverse\verse
\renewenvironment{verse}{%
    \vspace{-\parskip}
    \oldverse
}

\begin{document}

This is a paragraph.

This is another paragraph.  Separated nicely.

\begin{verse}
This is some\\
lovely verse,\\
that has too much space\\
on top and below.
\end{verse}

I would really like not as much space above and below.  Just one parskip would be sufficient.

But other paragraphs should be spaced with parskip.

\end{document}

在此处输入图片描述

相关内容