wspr / herries-press

A collection of LaTeX packages by Peter Wilson
http://wspr.github.com/herries-press/
30 stars 5 forks source link

\needspace and \Needspace need to hide their actions better! #32

Open FrankMittelbach opened 5 years ago

FrankMittelbach commented 5 years ago

The suggestion in #10 is not sufficient. \needspace needs to work like \addpenalty / \addvspace, that is inspect a previous vertical skip, back up, does its work and then readd the space that was backed up so that a following \addvspace can interact with the space.

It is debatable if after backing up one needs to enlarge the requested space.

MWE showing the problem:

\documentclass{article}

\usepackage{needspace}

\begin{document}

\section{no needspace}

\begin{itemize}
\item x  \item x  \item x  \item x
\end{itemize}

\begin{itemize}
\item y  \item y  \item y  \item y
\end{itemize}

\newpage

\section{with needspace}

\begin{itemize}
\item x  \item x  \item x  \item x
\end{itemize}

\needspace{1cm}

\begin{itemize}
\item y  \item y  \item y  \item y
\end{itemize}

\newpage

\section{with Needspace}

\begin{itemize}
\item x  \item x  \item x  \item x
\end{itemize}

\Needspace{1cm}

\begin{itemize}
\item y  \item y  \item y  \item y
\end{itemize}

\end{document}

Result:

test-needspace.pdf