[XeTeX] Making nice tables

Ross Moore ross at ics.mq.edu.au
Sat Nov 24 07:00:42 CET 2007

Hi Mike,

On 24/11/2007, at 2:45 PM, Mike Maxwell wrote:

> What I *really* want is something like "If the next thing to output  
> is a
> table (etc.), then if it will fit entirely on the current page, put it
> there.  If it won't fit on the current page, but it's less than a page
> long, then float it on to the next page.  (And fill up the current  
> page
> with any body text that's coming up, if that won't cause orphans and
> widows, etc.)  But if the table is more than a page long, then  
> start it
> on the current page if there's room for more than a header row and the
> first row, else start it on the next page, etc."

This is indeed possible.
First you must set the table inside a \vbox  or  \hbox
then measure the size of this box.

There is a way to measure what is currently waiting to be output,
but you will need to read parts of The TeXbook to find out how
to do this. Or someone else on this list may reply.
(It's not something that I do regularly, so the technique
is not at my fingertips.)

Usually this kind of thing is done in the output routine,
but here you want to control it at an earlier stage of

A.  If there is enough room on the page, then set the table.
   (You can use the contents of the box that has been already
    prepared, but there may be an advantage to just doing it
    all over again.)

B.  If it is a big table, then re-typeset the table using
      {longtable} .

C.  If it is a short table, but there is not enough room,
     then put in a \newpage, or enough vertical space to
     encourage a natural break.
     Then do the table in the same way as in A.

> I realize that's a bit simplistic, but I do wish *tex would try a bit
> harder...  Maybe some of the other table packages do?  If I can figure
> out how to test them out, I will.

Maybe there is a package that already does the kind of logic
outlined above. If so, that would be great; otherwise you'll
need to write a bit of serious package-code for yourself.

> Thanks for the ideas.

Hope this helps,


> -- 
> 	Mike Maxwell
> 	maxwell at umiacs.umd.edu
> 	"For over a thousand years, the British Empire was the guardian
> 	 of good grammar and the English language.
> 	 Before the dark times.  Before the Americans."
> 	--Bob Kenobi (Ben Kenobi's younger brother)
> _______________________________________________
> XeTeX mailing list
> postmaster at tug.org
> http://tug.org/mailman/listinfo/xetex

Ross Moore                                         ross at maths.mq.edu.au
Mathematics Department                             office: E7A-419
Macquarie University                               tel: +61 +2 9850 8955
Sydney, Australia  2109                            fax: +61 +2 9850 8114

More information about the XeTeX mailing list