I'm writing a custom command that uses minipages to display its contents:
\newcommand{\example}[1]{\noindent\begin{minipage}{\linewidth}#1\end{minipage}}
The spacing around this command should be similar to that of the align environment: \abovedisplayskip above, and \belowdisplayskip after, so I add \par\vspace{…} before and after:
\newcommand{\example}[1]{%
\par\vspace{\abovedisplayskip}
\noindent\begin{minipage}{\linewidth}#1\end{minipage}
\par\addvspace{\belowdisplayskip}}
This isn't perfect, though: it adds an extra \parskip before and after the contents, even if there are no blank lines around the command:
AAA % too much space (extra \parskip) after this
\example{\lipsum[1]}
BBB % too much space (extra \parskip) before that
I can remove the first one by changing the definition to this:
\newcommand{\example}[1]{%
\ifvmode\else\par\vspace{-\parskip}\fi\vspace{\abovedisplayskip}
\noindent\begin{minipage}{\linewidth}#1\end{minipage}
\par\addvspace{\belowdisplayskip}}
But what's the equivalent fix for the bottom of the command? If I use a negative space the \parskip will always be suppressed. Ideally, I'd like text immediately following the command to not be indented, just like with \[\].
Here's a minimal example:
\documentclass{minimal}
\usepackage{lipsum}
\setlength{\parskip}{50pt}
\newcommand{\example}[1]{%
\ifvmode\else\par\vspace{-\parskip}\fi\vspace{\abovedisplayskip}
\noindent\begin{minipage}{\linewidth}#1\end{minipage}
\par\addvspace{\belowdisplayskip}}
\begin{document}
% There should be small spaces after AAA and before BBB
AAA
\example{\lipsum[1]}
BBB
% There should be a large space after AAA and a small one before BBB
% And BBB shouldn't be indented
AAA
\example{\lipsum[1]}
BBB
% There should be a small space after AAA and a large one before BBB
AAA
\example{\lipsum[1]}
BBB
\end{document}

word\begin{center}centred words\end{center}word, then\parskipis still inserted twice. – Circumscribe Nov 05 '18 at 12:04\partopsepas\parskipin the\parcase and\topsepas\parskipin the no-\parcase, so by setting up those list parameters you can achieve (some) control over that – David Carlisle Nov 05 '18 at 12:15\parskipwhich set things up for non zero parskip would automatically do the right thing here. – David Carlisle Nov 05 '18 at 12:47\partopsep=\parskipand\topsep=-\parskipworks. I think both\parskipand\topsepare always inserted (so this way they cancel out) and\partopsepis only inserted when there is a preceding paragraph break. – Circumscribe Nov 05 '18 at 12:57\trivlistalways puts the same amount of space after the list too, regardless of whether the list is followed by a new paragraph. Do you have suggestions for that? – Clément Nov 05 '18 at 19:11