2

Is there a simple way of obtaining the remaining space in a sheet in order to align text? Something like [0.5/remainingVerticalSpace] in order to align text at 50% of the remaining vertical space, leave it as white space, or some such thing.

Here's a solution how to get information about remaining free space, however given how it is done, it seems a little bit excessive, is there a simpler way or is this the way that things are done in latex?

Troy
  • 13,741
Jose V
  • 121
  • Please clarify what you're trying to achieve. As of now, what you really need is not so much a way to determine how much (vertical) space is left on a page but, rather, a test to decide whether or not to try to place a given object on the current page. Please confirm/correct this impression. Note that 0.5\remainingVerticalSpace will always be positive length -- unless TeX happens to be at the very bottom of a page, in which case there's definitely no point in trying to place any further material on that page, right? – Mico Apr 24 '17 at 07:44
  • @Mico what i'm trying to achieve is align a sentence (or any element, it'd be useful to know) to the dead-center of the remaining page's white-space, it's for a coverpage – Jose V Apr 24 '17 at 20:39

1 Answers1

4

You don't need to get the remaining space, simply add equal vertical space before and after the text you want to have centered:

\documentclass{article}
\usepackage{lipsum}

\begin{document}
\lipsum[2-3]

\vspace*{\fill}

This is at 50\% of the remaining space.

\vspace*{\fill}

\clearpage

\end{document}

The \vspace* macro ensures that the vertical spacing is inserted even if it lands at the beginning or end of a page.

To generalize this, you can use the \stretch macro to divide the remaining space into unequal amounts. For example \vspace*{\stretch{2}} some text \vspace*{\stretch{1}} will make the first space twice as long as the second one.

  • 1
    To generalize this, you can use the \stretch macro to divide the remaining space into unequal amounts. For example \vspace*{\stretch{2}} some text \vspace*{\stretch{1}} will make the first space twice as long as the second one. – alephzero Apr 24 '17 at 15:54