[XeTeX] strange results of measuring boxes

Marcin Woliński wolinski at mimuw.edu.pl
Fri Jul 24 18:13:32 CEST 2009

Dear XeTeX Gurus!

In an application I'm trying to set the width of a ‘p’ column in LaTeX
tabular to the minimal width which will accommodate for a certain word.
On the TeX level that means I'm measuring the width of an \hbox
containing the word, than use this value to set \hsize within a \vbox
(see the attached file).  In pdfTeX this seems to work reliably.  In
XeTeX the word sometimes gets broken.  As shown in the example, a rather
large value of \emergencystretch is necessary (however, the default
value used by multicol is enough to trigger the problem).  The word
being measured needs to contain a hyphen, either explicit or
discretionary.  And it seems that XeTeX has to be using OpenType fonts,
but then the problem is not specific to TeX Gyre Heros used in the
example.

Can anyone help in understanding the problem?  Questions:

1. Do you get a similar result on the test file, that is the test word
fits in one line in the first \vbox, but gets broken in the second?
(I'm using svn XeTeX 821).

2. Why does (Xe)TeX find a solution during @secondpass in the first
case, but has to resort to @emergencypass in the second?  There seems to
be no overfull in the first \vbox, although the line is reported as
‘tight’ in the trace (why?).  So how come the value of \emergencystretch
influences the second pass???

3. Do you see a way of overcoming this problem without setting
\emergencystretch to 0pt?  Narrow columns in a table are the exact case
where \emergencystretch comes in handy.

4. Do you see a reliable method of measuring the minimal width I need?

With best
Marcin

-------------- next part --------------
A non-text attachment was scrubbed...
Name: testmeasurement.pdf
Type: application/pdf
Size: 6512 bytes
Desc: not available
URL: <http://tug.org/pipermail/xetex/attachments/20090724/2bd39496/attachment.pdf>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testmeasurement.log
Type: text/x-log
Size: 8986 bytes
Desc: not available
URL: <http://tug.org/pipermail/xetex/attachments/20090724/2bd39496/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testmeasurement.tex
Type: text/x-tex
Size: 613 bytes
Desc: not available
URL: <http://tug.org/pipermail/xetex/attachments/20090724/2bd39496/attachment-0001.bin>