# [texhax] Calculate remaining space after a page break and a \penalty of 10000

Wolfgang Lorenz wl-chmw at gmx.de
Sat Nov 13 15:03:38 CET 2010

Am Sat, 13 Nov 2010 02:15:41 +0100
schrieb Paul Isambert <zappathustra at free.fr>:

> Ok. I kind of see what you mean.

Good :-)

> Now, the first problem is of course as mentioned by Donald: after a
> section, or any \penalty10000, you don't have the real \pagetotal, so
> you can't properly build the song.

Yes, I will have to address this one. But Donald's approach seems to
suffice.

> I can see two solutions: solution one is LuaTeX.

Sounds promising. So it means, that soon I will be trying to learn a
new language... Maybe... But for the moment I will stick to (La-)TeX.

> Solution two is: when using columns, don't make one big box, but
> small ones instead, with penalties inbetween, as follows:
>
> penalty
> box: 1... 5...
> penalty
> box: 2... 6...
> penalty
> box: 3... 7...
> penalty
> box: 4...
>
> and TeX will break (in your example) after "3... 7...".

Unfortunately that wouldn't work, because the verse boxes may differ in
height (and depth) and most certainly differ in width. The width could
be addressed by inserting the right amount of glue between the boxes in
the rows, but boxes with different height would lead to unwanted
vertical spaces between the verses. Here is a sketch, of what I mean:

-----------        -----------
1.. 4..            1.. 4..
... 5..            ...
2.. ...     =>     2.. 5..
3.. 6..                ...
...                3.. 6..
-----------        --...------

Anyway, thanks for all your help. Now I can stop agonizing about if and
how it is possible to correctly measure the upcoming page's free space
or not, because -- as it seems -- it ain't. So I will leave it to the
user to limit the space for the "first page" if this should be
necessary.

Cheers,
Wolfgang