I: [texhax] please help numbering equations
Ian Collier
imc at comlab.ox.ac.uk
Wed Jun 18 13:19:41 CEST 2003
romeomedina at libero.it hath written:
>I don't know how LaTeX would want you to do it,
>but in plain TeX one could try to define a macro like this:
>\def\eqnum{\ifodd\pageno\eqno\else\leqno\fi},
>and use it this way:
>$$E=mc^2\eqnum(57)$$
>I've experimented it myself, and it seems to work,
>except that at the beginning of a new page it sometimes failes.
>Maybe some TeXperts can tell why?
How does TeX know where to break the page? Answer: in general, it
will typeset just a little bit more than will fit on one page, and
then uses mathematical algorithms to find the least worst place to
put a pagebreak. (In contrast, TeX breaks paragraphs into lines by
typesetting the whole paragraph and then finding the optimal line
breaks. Obviously this means that if you have a long paragraph
starting at the bottom of a page, TeX may have to typeset quite a
bit more than will fit on the page. But that's a digression.)
Clearly, \pageno can only be incremented after the pagebreak is known;
and by that time, TeX may have already typeset the first line (or a few
lines) of the next page. So if an equation lands at the top of a new
page, it may already have been typeset using the previous value of
\pageno.
There is no good way to fix this that I can think of. A bad way to
fix it might be to force the pagebreak by adding an empty box having
the same height as the equation and then some negative vspace to cancel
the effect of the box.
--
---- Ian Collier : imc at comlab.ox.ac.uk : WWW page below
------ http://users.comlab.ox.ac.uk/ian.collier/imc.shtml
More information about the texhax
mailing list