![消除列表环境末尾的空格](https://linux22.com/image/284157/%E6%B6%88%E9%99%A4%E5%88%97%E8%A1%A8%E7%8E%AF%E5%A2%83%E6%9C%AB%E5%B0%BE%E7%9A%84%E7%A9%BA%E6%A0%BC.png)
我试图消除列表环境末尾的垂直空间(enumerate
、itemize
和),但仅当列表环境位于包中环境的describe
末尾时才这样做。这种特殊情况会导致左侧栏出现尴尬的悬垂(下面的工作示例)。到目前为止,我考虑了三个选项:leftbar
framed
- 我知道我可以调整
\topsep
、\itemsep
和\partopsep
,但这不会以环境的结束为条件leftbar
,也不会影响整个文档。 - 我可以重新定义列表环境以在末尾包含一些负空间。但是,这并不取决于位于环境末尾
leftbar
。 - 最后,我可以根据具体情况手动实施上述两种解决方案。这似乎不太优雅,而且在较长的文档中需要做大量工作。
如果有人有解决方案,我们将不胜感激!
\documentclass{article}
\usepackage{framed}
\begin{document}
\begin{leftbar}
\begin{enumerate}
\item Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old.
\item Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old.
\end{enumerate}
\end{leftbar}
\end{document}
答案1
您可以将leftbar
环境重新定义为-like 环境\unskip
插入的最后一个跳过itemize
。
在你的序言中添加以下几行:
\let\oldendleftbar\endleftbar
\renewcommand{\endleftbar}{\unskip\oldendleftbar}
梅威瑟:
\documentclass{article}
\usepackage{framed,lipsum}
\let\oldendleftbar\endleftbar
\renewcommand{\endleftbar}{\unskip\oldendleftbar}
\begin{document}
\begin{leftbar}
\begin{itemize}
\item Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old.
\item Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old.
\end{itemize}
\begin{enumerate}
\item Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old.
\item Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old.
\end{enumerate}
\end{leftbar}
\begin{leftbar}
\lipsum[1]
\end{leftbar}
\end{document}
输出: