[pdftex] Am I really on page x?

Pawel Jackowski jackos1 at poczta.onet.pl
Mon Dec 13 17:51:46 CET 2004


Hi All,

Although the problem is connected with TeX in general, I post it here
since some details may be pdfTeX related.

As we know, basic page breaking mechanism don't allow to check on which
page we are. The example code

\def\p{I'm on page \the\pageno.\par}
\p\p\p\p ... % 100 times
\end

will probably produce two pages and a couple of lines at the beginning
of the page 2 will say "I'm on page 1". In fact, what I really need is
not a page number, but the information, if some part of code appears
before or after optimal page break... To explain more precisely, lets
assume we want to pass the information about current text color to the
next page. We can say something like

\def\color#1{\edef\currentcolor{#1}\pdfliteral{\currentcolor}}
\color{0.5 g}
...

and utilize \currentcolor contol sequence in output routine while
shipping out next page. But we still have the sticky problem here! If we
use \color just AFTER the place which becomes the best page break, TeX 
will probably swallow this code anyway and redefine \currentcolor to 
some irrelevant value, which should take place a bit later.

Any tricks? What about large macro packages; how they cope with it?

Best regards, Pawel



More information about the pdftex mailing list