消除列表环境末尾的空格

消除列表环境末尾的空格

我试图消除列表环境末尾的垂直空间(enumerateitemize和),但仅当列表环境位于包中环境的describe末尾时才这样做。这种特殊情况会导致左侧栏出现尴尬的悬垂(下面的工作示例)。到目前为止,我考虑了三个选项:leftbarframed

  1. 我知道我可以调整\topsep\itemsep\partopsep,但这不会以环境的结束为条件leftbar,也不会影响整个文档。
  2. 我可以重新定义列表环境以在末尾包含一些负空间。但是,这并不取决于位于环境末尾leftbar
  3. 最后,我可以根据具体情况手动实施上述两种解决方案。这似乎不太优雅,而且在较长的文档中需要做大量工作。

如果有人有解决方案,我们将不胜感激!

\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} 

输出:

在此处输入图片描述

相关内容