In order to solve this question:
Wrap automatically into figure if not enough space to place it Here
I need to learn the remaining space on the current page.
I tried this to put a rule of exactly the good size, however this rule is pushed on the next page. Any idea why, and how I could know precisely the remaining available space?
If this is not possible, at least is there a way to have a (not too bad) lower bound, so that I'm guaranteed that the rule won't be pushed on next page? Or maybe I can add some penalty to help the rule to stay on this page?
\documentclass{article}
\usepackage{lipsum}
\usepackage{showframe}
\begin{document}
\lipsum[1-3]
\edef\measurepage{\the\dimexpr\pagegoal-\pagetotal\relax} %
\rule{1mm}{\measurepage}
\end{document}

\pagetotal– David Carlisle Oct 01 '21 at 19:45\pdfsaveposand pick up exact measurements from the previous run – David Carlisle Oct 01 '21 at 19:59