![减少诗句环境前后的空间](https://linux22.com/image/325033/%E5%87%8F%E5%B0%91%E8%AF%97%E5%8F%A5%E7%8E%AF%E5%A2%83%E5%89%8D%E5%90%8E%E7%9A%84%E7%A9%BA%E9%97%B4.png)
我想在文档中全局减少诗句环境前后的垂直空间。 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}