tom sgouros tomfool at as220.org
Wed Jun 18 17:11:35 CEST 2003

 >On Wed, 18 Jun 2003 12:19:41 +0100 (BST), Ian Collier wrote:

> 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?

<snip>

> 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.

There's a similar problem with \marginpars that occasionally wind up
on the wrong side of the page.  This has been (pretty much) solved
with the mparhack package, which sets special labels for each
\marginpar and uses the page counter to correct the situation on
subsequent runs.  That is, the first time through it's wrong, but the
second time through it's ok.  mparhack.sty is in CTAN:

http://www.ctan.org/tex-archive/macros/latex/contrib/supported/mparhack

-Tom

(I didn't write the package, but I wrote the first draft of the dtx
for Stefan Ulrich, and he kindly left my name on it.)

---------------------------------
tomss at ids.net        401-861-2831
http://sgouros.com