[luatex] Interfere with page breaking to balance pages

Paul Isambert zappathustra at free.fr
Thu Oct 18 10:42:12 CEST 2012


Selon Taco Hoekwater <taco at elvenkind.com>:

> On 10/17/2012 05:11 PM, Patrick Gundlach wrote:
> >
> >>> you can do something like this:
> >>>
> >>> tex.box["AtBeginShipoutBox"]
> >>>
> >>> that's a bit more luaeque IMO.
> >>
> >> Nice, but when did Taco tell you that secret?  I can't find it in the
> >> LuaTeX manual. :/
>
> Documentation oversight (it happens).
>
> On the original problem: TeX's page breaking is more than a little
> tricky to get 'into' from the Lua end because there are a bunch
> of interwoven C functions that mutually depend on each other's
> calculations. In fact, that is why the current interface is so
> weird: it closely follows what the internals do.
>
> When we exposed the current situation, it was not at all
> clear what a 'good' interface would look like (and personally, I
> am still not sure). So, any constructive thoughts on that would
> be welcome.
>
> A better, cleaner solution would be nice to have, but whatever
> form it takes, it will require some digging and a bit of a rewrite in
> the internal code. And to make sure at the same time that something
> important does not break is tricky, which is also part of why it has
> not been done yet.

Similar to the linebreak callbacks, I've been thinking about the following:

- A pre_shipout would take whatever box is passed to \shipout and return a
similar one; returning nothing would cancel shipout, i.e. it'd be a dead cycle.

- A shipout callback would take what the preceding returns, and return PDF code
representing the page, to be written to the output file; of course it's probably
more complex than that, and not just the page must be written, e.g. a new font
must be written to the PDF and I suppose that's done at the end of the job; so
I'm not sure it's realistic at all.

- A post_shipout could implement whatever must be done after shipout, e.g.
emptying \pdfpageattributes, etc.

Of course all that can be done in good ol' TeX in the output routine, except
point 2, and I don't know if that one would be any good at all.

My illiteracy in C of course prevents me from proposing any thought on the
implementation :)

Best,
Paul




More information about the luatex mailing list