[XeTeX] It works! (was Re: \botmark and \firstmark not working for me ...)

Ron Aaron ron at ronware.org
Sun Aug 1 20:36:03 CEST 2010

Thanks to everyone who responded.  Here is a short synopsis of the problem as well as my solution.

The problem is simply that a "\mark{}" within a "\vtop" (or \vbox) does not propagate out to the main list.  Thus, it is not possible to use a "mark" directly to find out what footnotes (for example) are on a page, if a footnote is within such a box.  In my particular application, most of the text is within rigidly defined boxes.

The problem is further exacerbated by the fact that the page-breaking algorithm sometimes chooses to put a paragraph on the following page rather than on the page you thought it would be on.   That is to say, the "\output" routine may be invoked after you have seen a paragraph (e.g. with footnotes), but that paragraph may be stuck on the following page.  This implies that a simply "keeping track" of footnotes between invocations of "\output" is not sufficient to properly track footnotes.

"\mark"s are the perfect solution, if they show up!  It turns out to be possible to do things my way and still use marks:

Before "committing" my vbox with footnotes to the main list, I first "vsplit" a copy of it:

	\setbox0\vsplit\textbox to 100in

The really large dimension is simply to ensure that all the text in the box I'm committing is in the "split" part.

Then, code like:


is used to "propagate" the first and last marks on the "split" box.  This ensures that the information I stashed away in my footnote macro will be visible in the "\output" routine.

Similar code is used when one of my vtops is vsplit, but that's just fine-tuning.

I chose to do something wasteful, but which works very well so far: I keep every footnote in an "\hbox", in an array of boxes allocated using "\globboxvector".  As long as I don't exceed the number allocated at one go, there's no problem.

In my page layout, I figure out how much space is left by making a "footnote paragraph" containing all the footnotes pertaining to the page, and getting its dimensions.  On "\output", I also get rid of the "\hboxes" (this also prevents inadvertantly duplicating a footnote).

Hope this is helpful to someone besides me, it sure was interesting figuring this out...

Best regards,

Sending me something private?
Use my GPG public key: AD29415D

More information about the XeTeX mailing list