I would like to reliably detect how much space is left on the last page of the document. Preferably, this should be accessible in a \AtEndDocument
or similar hook, so that I can write this information to my own auxiliary file. Another option is if it gets automatically written in the standard .aux
file; I can then recover the information from there in the next run, that's not a big deal. More importantly, it has to take account floats and footnotes on the last page, including [b]
ones.
Use case
When putting together journal issues the "TUGboat" style, where articles need not start at a new page, it is necessary to know how much space was left by the previous article, and this really should be automated and reliable. This would get incorporated into a package I work on which allows for journal issues' compilation.
Examples
In the examples below, the \rule
serves as a measurement tool to detect the resulting space by trial and error.
Example 1 – no figures
\documentclass[a4paper]{article}
\usepackage{lipsum,showframe}
\begin{document}
\lipsum
%\rule[-1ex]{10pt}{0.75\textheight}
\end{document}
% SHOULD GIVE "0.75\textheight"
Example 2 – top figure
\documentclass[a4paper]{article}
\usepackage{lipsum,showframe}
\begin{document}
\lipsum
\begin{figure}[t] \rule{3cm}{3cm} \caption{A black square} \end{figure}
%\rule[-1ex]{10pt}{0.54\textheight}
\end{document}
% SHOULD GIVE "0.54\textheight"
Example 3 – top and bottom figure
\documentclass[a4paper]{article}
\usepackage{lipsum,showframe}
\begin{document}
\lipsum
\begin{figure}[t] \rule{2cm}{2cm} \caption{A small black square} \end{figure}
\begin{figure}[b] \rule{3cm}{3cm} \caption{A black square} \end{figure}
%\rule[-1ex]{10pt}{0.37\textheight}
\end{document}
% SHOULD GIVE "flag: figure/footnote at the bottom of the last page" and "0.37\textheight" OR "0\textheight"
Example 4 – figure on top, footnote on bottom
\documentclass[a4paper]{article}
\usepackage{lipsum,showframe}
\begin{document}
\lipsum
Random text\footnote{A random footnote.}.
\begin{figure}[t] \rule{3cm}{3cm} \caption{A small black square} \end{figure}
%\rule[-1ex]{10pt}{0.50\textheight}
\end{document}
% SHOULD GIVE "flag: figure/footnote at the bottom of the last page" and "0.50\textheight" OR "0\textheight"
\output
hack would be needed, I hope there are people willing to do it for me :) (some people also know the motivation, which comes from my TUG talk...)