# Measuring the distance from text to the top of the page

How can I obtain a measurement from the baseline of any line of text in a document to top of the body of text on a page?

-
I'd probably use TikZ to add a node at the given point; with the y-coordinate of this point and the y coordinate of, for example, current page.center you could calculate the length that you want. – Gonzalo Medina Dec 2 '11 at 4:00
Have a look at the similar question How to define a figure size so that it consumes the rest of a page?. It's solution can be tweaked to give you the length you need. – Martin Scharrer Dec 2 '11 at 9:29

The length \pagetotal is a measure of the accumulated distance from the baseline of the first line of the page. Alternatively, the zref package also allows node placement and coordinate extraction via its savepos module. For example:

\documentclass{article}
\usepackage[showframe]{geometry}% http://ctan.org/pkg/geometry
\usepackage[savepos]{zref}% http://ctan.org/pkg/zref
\newcounter{parcnt} \newcommand{\nl}{\stepcounter{parcnt}\theparcnt}
\begin{document}
\zsavepos{top}\nl\ \the\pagetotal \par
\nl\ \the\pagetotal \par \bigskip \bigskip
\nl\ \the\pagetotal \par
\nl\ \the\pagetotal \par \medskip
\nl\ \the\pagetotal \par
\nl\ \the\pagetotal \par \smallskip \smallskip \smallskip
\nl\ \the\pagetotal \par
\nl\ \the\pagetotal \par \vspace{2cm}

Both the \pagetotal and zref-labels identify a 191.84995pt vertical distance to the first base line. As such, I assume \dimexpr\pagetotal+1em\relax is what you're after (here 1em, from a visual standpoint, seemed to represent the first "\baselineskip").
@YiannisLazarides: Probably - I wasn't sure where to find the first \baselineskip on a page. Any source? – Werner Dec 2 '11 at 16:24
no it was off the top of my head:). Your calculation is correct, however \pagetotal measures from the top of the page (which includes \topskip) - not as you indicated. The correction for the rule height is to add baselineskip-depth (this is more or less the font size or 1em). This will get affected in certain cases with topskip. Was hoping you could shed a bit more light:). – Yiannis Lazarides Dec 2 '11 at 19:18
This doesn't work for me; pagetotal is always 0 (using beamerposter in beamer) – Clément Sep 16 '14 at 13:58