如何在段落之间获得空格(我想要在包含块段落的不规则文档中获得该空格),并避免在没有空格开头的列表之前出现多余的空格?
如果我设置 topsep=-\parskip,列表将不会与其上方的文本正确分离。但我也会丢失列表后到下一段之间的空格。
这是我的 MWE:
\documentclass{article}
\usepackage{enumitem}
\newlist{myshortlist}{itemize}{4}
% Attempt 1: lose space after list before next paragraph
%\setlist[myshortlist]{label=\textbullet,nolistsep,topsep=-\parskip}
% Attempt 2: get extra space between list and immediately preceeding text.
\setlist[myshortlist]{label=\textbullet,nolistsep}
\begin{document}
\raggedright\setlength\parskip{\baselineskip}
Want these paragraphs separated by whitespace.
Want these paragraphs separated by whitespace.
Want space before this line, but not between this line and list:
\begin{myshortlist}
\item one
\item two
\end{myshortlist}
Want space before this line, but not between this line and list:
\begin{myshortlist}
\item one
\item two
\end{myshortlist}
\end{document}
答案1
\documentclass{article}
\usepackage{enumitem}
\newlist{myshortlist}{itemize}{4}
\makeatletter
\setlist[myshortlist]{label=\textbullet,nolistsep,topsep=-\parskip, after*={\@topsepadd\parskip}}
\makeatother
\begin{document}
\raggedright\setlength\parskip{\baselineskip}
Want these paragraphs separated by whitespace.
Want these paragraphs separated by whitespace.
Want space before this line, but not between this line and list:
\begin{myshortlist}
\item one
\item two
\end{myshortlist}
Want space before this line, but not between this line and list:
\begin{myshortlist}
\item one
\item two
\end{myshortlist}
\end{document}