6

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}
  • try \edef\measurepage{\the\dimexpr\pagegoal-\pagetotal-\baselineskip\relax} and use it \measurepage – touhami May 10 '16 at 18:02
  • 1
    note that any such calculation is only approximate: tex's page breaker acts at a different time long after that value is calculated – David Carlisle May 10 '16 at 21:32
8

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}

enter image description here

5

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}

enter image description here

4

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}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.