如何在回忆录中获得具有非零 parskip 的“严格”列表

如何在回忆录中获得具有非零 parskip 的“严格”列表

这:

\documentclass{memoir}

\nonzeroparskip

\tightlists

% \usepackage{enumitem}
% \setlist{nosep}

\begin{document}
Lorem ipsum dolor sit amet, consectetuer
adipiscing elit. Ut purus elit, vestibulum ut, placerat ac,
adipiscing vitae, felis.

Nulla malesuada porttitor diam. Donec felis
erat, congue non, volutpat at, tincidunt tristique, libero. Vivamus
viverra fermentum felis.
\begin{itemize}
\item Proin fermentum massa ac quam.
\item Sed diam turpis, molestie vitae, placerat a, molestie nec, leo.
\item Maecenas lacinia.
\end{itemize}
Nam ipsum ligula, eleifend at, accumsan nec, suscipit a, ipsum. Morbi
blandit ligula feugiat magna.
\end{document}

在列表中产生额外的垂直空间(包括列表前后以及项目之间)。取消注释enumitem会消除项目之间的空间,但不会消除列表前后的空间。

我希望列表中没有多余的垂直空间,最好有enumitem(我使用它来方便地定义新列表)。怎么做?

答案1

回忆录用户指南的段落和列表章节讨论了 \tightlist 的使用。我成功地在文档中应用了 \tightlist 声明。

\documentclass{memoir}
\begin{document}

  \tightlist
  \begin{enumerate}
    \item Read this a little...
    \item ...bit easier
  \end{enumerate}

\end{document}

根据帮助,您还可以在特定的列表环境中应用它——我还没有尝试过。

答案2

@HarishKumar 建议了解决问题的最简单方法。它近似于\nonzeroparskip解决问题的方法(稍微灵活一些)。但是,如果您想避免使用enumitem,那么您可以这样做:

\documentclass{memoir}

\makeatletter
% memoir.cls has these two commands:
% \newcommand*{\abnormalparskip}[1]{%
%   \setlength{\parskip}{#1}\m@mabparskip=#1\relax
%   \m@mnzpskiptrue}

% \newcommand*{\nonzeroparskip}{\abnormalparskip{%
%   0.5\baselineskip
%   \@plus .1\baselineskip \@minus .1\baselineskip% NTG
% %%  0.5/baselineskip \@plus 2pt% RF
% }}

% Create a length that negates/removes the value of \abnormalparskip
\newlength{\rmnonzeroparskip}
\setlength{\rmnonzeroparskip}{%
  \dimexpr-0.5\baselineskip \@plus .1\baselineskip \@minus .1\baselineskip\relax}
% Create a macro that uses the above length
\newcommand*{\removenzps}{\vspace*{\rmnonzeroparskip}}
\makeatother
\tightlists
\nonzeroparskip

% etoolbox allows us to hook into environments
\usepackage{etoolbox}
\AtBeginEnvironment{itemize}{\traditionalparskip}
\AfterEndEnvironment{itemize}{\removenzps}
%\AfterEndEnvironment{itemize}{\vspace*{-0.5\baselineskip}} % <-- this is similar to Harish Kumar's suggestion


\begin{document}
Lorem ipsum dolor sit amet, consectetuer
adipiscing elit. Ut purus elit, vestibulum ut, placerat ac,
adipiscing vitae, felis.


Nulla malesuada porttitor diam. Donec felis
erat, congue non, volutpat at, tincidunt tristique, libero. Vivamus
viverra fermentum felis.
\begin{itemize}
\item Proin fermentum massa ac quam.
\item Sed diam turpis, molestie vitae, placerat a, molestie nec, leo.
\item Maecenas lacinia.
\end{itemize}
Nam ipsum ligula, eleifend at, accumsan nec, suscipit a, ipsum. Morbi
blandit ligula feugiat magna.

Nam ipsum ligula, eleifend at, accumsan nec, suscipit a, ipsum. Morbi
blandit ligula feugiat magna.

\end{document}

或者,如果您想使用enumitem(我通常推荐),但宁愿坚持设置的(默认)值\nonzeroparskip,那么您可以这样做:

\documentclass{memoir}

\makeatletter

\newlength{\rmnonzeroparskip}
\setlength{\rmnonzeroparskip}{%
  \dimexpr-0.5\baselineskip \@plus .1\baselineskip \@minus .1\baselineskip\relax}
\makeatother

\tightlists
\nonzeroparskip

\usepackage{enumitem}
% \setlist{nosep,  before=\vspace{-0.5\baselineskip}, after=\vspace{-0.5\baselineskip}} % <-- similar to what Harish Kumar suggested
\setlist{nosep,
% here we just use the length, not the subsequent macro
 before={\vspace{\rmnonzeroparskip}}, after=\vspace{\rmnonzeroparskip}}


\begin{document}
Lorem ipsum dolor sit amet, consectetuer
adipiscing elit. Ut purus elit, vestibulum ut, placerat ac,
adipiscing vitae, felis.


Nulla malesuada porttitor diam. Donec felis
erat, congue non, volutpat at, tincidunt tristique, libero. Vivamus
viverra fermentum felis.
\begin{itemize}
\item Proin fermentum massa ac quam.
\item Sed diam turpis, molestie vitae, placerat a, molestie nec, leo.
\item Maecenas lacinia.
\end{itemize}
Nam ipsum ligula, eleifend at, accumsan nec, suscipit a, ipsum. Morbi
blandit ligula feugiat magna.

Nam ipsum ligula, eleifend at, accumsan nec, suscipit a, ipsum. Morbi
blandit ligula feugiat magna.

\end{document}

还要注意,最好在之前memoir声明。\tightlists\nonzeroparskip

相关内容