# Paragraph delimiters that disappear at the tops and bottoms of pages (like \vspace)

Books of poetry, or collections of short prose expressions, are often delimited by ornaments. I would like a command that inserts an ornament between paragraphs, but that disappears at the top or bottom of a page. That way I don't have to insert the ornaments manually when I'm typesetting a large collection. (I'm thinking of how \vspace automatically goes away at the top of the page.) In the MWE below, the third delimiter would ideally just disappear, since it would be at the top of a page.

\documentclass[11pt]{article}
\usepackage[a4paper,bottom=4.8cm]{geometry}
\usepackage{lipsum,pgfornament}
\newcommand\MyDelimiter{\vspace{2em}\begin{center}\pgfornament[width=0.5*\textwidth]{86}\end{center}\vspace{2em}}
\begin{document}
\lipsum[1]

\MyDelimiter

\lipsum[1]

\MyDelimiter

\lipsum[1]

\MyDelimiter % this one should just disappear

\lipsum[1]

\MyDelimiter

\lipsum[1]
\end{document}


By the same token, the delimiter should disappear if it's the last thing on a page:

\documentclass[11pt]{article}
\usepackage[a4paper,bottom=10.5cm]{geometry}
\usepackage{lipsum,pgfornament}
\newcommand\MyDelimiter{\vspace{2em}\begin{center}\pgfornament[width=0.5*\textwidth]{86}\end{center}\vspace{2em}}
\begin{document}
\lipsum[1]

\MyDelimiter

\lipsum[1]

\MyDelimiter % this one should just disappear

\lipsum[1]
\end{document}

• If I understand correctly what you mean, there’s a famous trick, due to Marcin Woliński, based on the use of \leaders. I haven’t time to post an answer now, but if you can read Italian, I’ll refer to this possibly related answer appeared ont the Italian Tug.
– GuM
May 5 '16 at 10:36
• Here’s an English reference, too: How to make a box disappear at a line break.
– GuM
May 5 '16 at 10:40
• Great, thanks! I've used that macro in my answer. May 5 '16 at 11:45
• I'm not sure why you want no separator between items at the top and bottom of the pages. The memoir class has a set of macros related to this which might be worth looking at (in the user manual section "Fancy Anonymous Breaks" texdoc memoir). May 5 '16 at 18:38

Here's a MWE with the delimiter disappearing at the end of a page. The macro definition follows this link, which was suggested in the comments (thanks Gustavo Mezzetti!).

\documentclass[11pt]{article}
\usepackage[a4paper,bottom=14cm]{geometry}
\usepackage{lipsum,pgfornament}

\makeatletter
\newcommand*\MyDelimiter{\par
% Emulate LaTeX's \bigbreak (more or less):
\ifdim\lastskip<\bigskipamount
\removelastskip
\fi
\penalty -200
% Do not depend on e-TeX's \glueexpr:
\skip@ \medskipamount
\multiply \skip@ \tw@
\dimen@ \skip@
\vss
\centerline{%
\vrule \@height 10\p@ \@depth\tw@\p@ \@width \z@
\pgfornament[width=0.5*\textwidth]{86}
}%
\vss
}\vskip \skip@
}
\makeatother

\begin{document}
\lipsum[1]

\MyDelimiter

\lipsum[1]

\MyDelimiter % this one should just disappear

\lipsum[1]
\end{document}


I don't follow all of the code but I note that the vertical spacing can be adjusted by adding to \skip@, e.g., by replacing:

\advance \skip@ \baselineskip


With:

\advance \skip@ \baselineskip