I want to measure the remaining space and use that number on another page. I tried the following:
\documentclass[a4paper,12pt]{article}
\usepackage[top=2cm,bottom=2cm,hmargin=2cm]{geometry}
\usepackage{lipsum}
\begin{document}
\section*{Firstpage}
\lipsum[1-4]
\newcommand\measurepage{\dimexpr\pagegoal-\pagetotal-\baselineskip\relax}
%%The value seems to be calculated correctly
\the\measurepage
\newpage
\section*{Secondpage}
%% Skip the measured space from the page before
\vfill
%%This is not the value stored above
\the\measurepage
\begin{minipage}[t][\measurepage][t]{\textwidth}
\lipsum[3]
\end{minipage}
\end{document}



\edef\measurepage{\the\dimexpr\pagegoal-\pagetotal-\baselineskip\relax}and use it\measurepage– touhami May 10 '16 at 18:02\edef\measurepage{\the\dimexpr\pagegoal-\pagetotal\relax}\rule{1mm}{\measurepage}and it is always moved to the next page if I don't also substract a small number like 3pt. – tobiasBora Sep 30 '21 at 17:41