Measure remaining space on page and use it on another page
For more details
What is the difference between \def and \newcommand?
What is the difference between \let and \edef?
A solution is to use \edef
method
\edef\measurepage{\the\dimexpr\pagegoal-\pagetotal-\baselineskip\relax}
MWE
\documentclass[a4paper,12pt]{article}
\usepackage[top=2cm,bottom=2cm,hmargin=2cm]{geometry}
\usepackage{lipsum}
\begin{document}
\section*{Firstpage}
\lipsum[1-4]
\edef\measurepage{\the\dimexpr\pagegoal-\pagetotal-\baselineskip\relax}
%%The value seems to be calculated correctly
\measurepage
\newpage
\section*{Secondpage}
%% Skip the measured space from the page before
\vfill
%%This is not the value stored above
\measurepage
\begin{minipage}[t][\measurepage][t]{\textwidth}
\lipsum[3]
\end{minipage}
\end{document}
This might work too. I use the existing definition of \measurepage
, but set a new length, \remainder
, to its value. I then use \remainder
in the minipage
argument.
\documentclass[a4paper,12pt]{article}
\usepackage[top=2cm,bottom=2cm,hmargin=2cm]{geometry}
\usepackage{lipsum}
\newlength\remainder
\newcommand\measurepage{\dimexpr\pagegoal-\pagetotal-\baselineskip\relax}
\begin{document}
\section*{Firstpage}
\lipsum[1-4]
%%The value seems to be calculated correctly
\remainder=\measurepage\relax\the\remainder
\newpage
\section*{Secondpage}
%% Skip the measured space from the page before
\vfill
%%This is not the value stored above
\the\measurepage
\begin{minipage}[t][\remainder][t]{\textwidth}
\lipsum[3]
\end{minipage}
\end{document}
You can get more exact values by storing the actuall positions in the aux-file. This need two compilations (the x are only there to show the locations):
\documentclass[a4paper,12pt]{article}
\usepackage[top=2cm,bottom=2cm,hmargin=2cm]{geometry}
\usepackage{lipsum}
\usepackage{zref-savepos}
\begin{document}
\section*{Firstpage}
\lipsum[1-4]
x\zsavepos{start}\par\vfill\mbox{x}\zsavepos{end}
\newpage
\section*{Secondpage}
%% Skip the measured space from the page before
\vfill
%the y position has its zero at the bottom
\begin{minipage}[t][\dimexpr\zposy{start}sp-\zposy{end}sp][t]{\textwidth}
\lipsum[3]\vfill xxxx
\end{minipage}
\end{document}