[texhax] current position in output

Reinhard Kotucha reinhard.kotucha at web.de
Sun Dec 28 05:08:41 CET 2008

tom sgouros writes:
 > I don't know if you'll get the precision you seem to be looking for, but
 > you should try playing with \pagetotal, which is a length that marks
 > where you are on the page (measured from the top), and creeps up (down)
 > towards \pagegoal.  When it gets to \pagegoal, the page-completing
 > machinery clanks into action.  Anyway, you might experiment with those
 > and see if that can't get you where you hope to go.  One little
 > weirdness is that I think \pagegoal isn't set until something 
 > is applied to the page. 

Hi Tom,
I doubt that this is a good advice.  The only reasonable solution is
what Martin proposed.

Your last sentence describes the problem:  The page breaking algorithm
doesn't care about \pagegoal and \pagetotal at all.  You are virtually
writing on endless paper, but whenever a paragraph is finished, the
output routine is called.  If the page is not full at the end of a
particular paragraph, nothing spectacular happens.  Otherwise the last
paragraph has to be split.  The first part appears on page $n$ and the
second part appears on page $n+1$.

Now assume that you convince TeX to print the values of \pagegoal and
\pagetotal to screen.  If you do it at the very end of a paragraph
which doesn't fit on a page completely, you'll notice that \pagetotal
is larger than \pagegoal.  If you ask for the page number, TeX will
tell you that you are still on page $n$ while the stuff actually goes
to page $n+1$.

Where things appear on a page is only known after the output routine
had been run and a new page had been shipped out.

If you really want to know where on the page you are, you have to wait
until the page is shipped out.  This means that you have to modify the
output routine.  But this is extremely difficult and not advisable.

The only reasonable solution is what Martin proposed.  Everything else
is inaccurate and unreliable and not worth to consider.


Reinhard Kotucha			              Phone: +49-511-3373112
Marschnerstr. 25
D-30167 Hannover	                      mailto:reinhard.kotucha at web.de
Microsoft isn't the answer. Microsoft is the question, and the answer is NO.

More information about the texhax mailing list