# [OS X TeX] Fwd: [XeTeX] A bug in (Xe)LaTeX?

Bruno Voisin bvoisin at mac.com
Fri Aug 19 06:38:06 EDT 2005

Le 18 août 05 à 23:46, Peter Dyballa a écrit :

> Am 18.08.2005 um 22:46 schrieb Bruno Voisin:
>
>> That probably won't help, but who knows?
>
> No! The \null in the right place makes things work! (I should
> remember this \null a few times before I die!!)

I have tried many things this morning, even ending up replacing as
many LaTeX commands as possible with their plain TeX equivalent, to
no avail. I don't think the \null thing is actually the solution: the
problem lies in the font themselves.

If you comment out the code

> \voffset=-1truein \hoffset=-1truein
>      \ifpdf
>        \pdfpageheight=\latexitheight
>        \pdfpagewidth=\latexitwidth
>      \else
>        \special{papersize=\latexitheight,\latexitwidth}%
>      \fi

then set in the preamble

\setlength{\fboxsep}{0pt}

and put the formula in an \fbox by replacing

>      \shipout\vbox{\scalebox{\latexitscalefactor}{\usebox
> {\latexitbox}}}

with

\shipout\vbox{\fbox{\scalebox{\latexitscalefactor}{\usebox
{\latexitbox}}}}

then you'll realize that, for LaTeX, the formula box is actually
slightly smaller than its content:

[stripped attachment, the OS X TeX list won't accept it]

(see how the frame is superposed on the glyphs themselves).

To understand this, you have to think about how (La)TeX measures
boxes: by adding up dimensions specified in the metrics files for the
fonts. I think the problem we see is just a manifestation of the way
the metrics of the Computer Modern fonts are set. For, if these fonts
are replaced by the Lucida Bright/New Math fonts, then it seems the
problem disappears:

[stripped attachment, the OS X TeX list won't accept it]

(see how the frame lies exactly outside the glyphs).

Thus it seems there's no easy cure for the CM fonts, other than a
rule of thumb consisting in adding some empirically determined length
to the box dimensions determined by (La)TeX. Has anybody had a look
at the source code for OOoLaTeXEquation, to see if the same problem
has been tackled, and how?

A couple more remarks on your code:

- To set the following right:

>       \immediate\write\foo{\the\latexitheight (Height)}
>       \immediate\write\foo{\the\latexitheight (TotalHeight)}

I think you should define a new length \latexittotalheight:

\newlength{\latexittotalheight}

then replace

with

\setlength{\latexittotalheight}{\latexitheight}

and replace

>       \immediate\write\foo{\the\latexitheight (TotalHeight)}

with

\immediate\write\foo{\the\latexittotalheight (TotalHeight)}

- In order to avoid an overfull hbox message, I think you should replace

>      \shipout\vbox{\scalebox{\latexitscalefactor}{\usebox
> {\latexitbox}}}

with

\shipout\vbox{\makebox[0pt][l]{\scalebox{\latexitscalefactor}
{\usebox{\latexitbox}}}}

- The proposed code for dvips doesn't work:

>        \special{papersize=\latexitheight,\latexitwidth}%

in that (i) you must interchange width and height, (ii) you must
preface them with \the and (iii) it must occur inside the shipped out
\vbox to be taken into account. All in all, I think you should
replace the code between \begin{document} and \end{document}:

>     \begin{document}
>     {\voffset=-1truein \hoffset=-1truein
>      \ifpdf
>        \pdfpageheight=\latexitheight
>        \pdfpagewidth=\latexitwidth
>      \else
>        \special{papersize=\latexitheight,\latexitwidth}%
>      \fi
>      \shipout\vbox{\scalebox{\latexitscalefactor}{\usebox
> {\latexitbox}}}%
>     }%
>     \end{document}

with

\begin{document}
\hoffset=-1in
\voffset=-1in
\ifpdf
\pdfpageheight=\latexittotalheight
\pdfpagewidth=\latexitwidth
\shipout\vbox{%
\makebox[0pt][l]{\scalebox{\latexitscalefactor}{\usebox
{\latexitbox}}}}
\else
\shipout\vbox{\special{papersize=\the\latexitwidth,\the
\latexittotalheight}%
\makebox[0pt][l]{\scalebox{\latexitscalefactor}{\usebox
{\latexitbox}}}}
\fi
\end{document}

Hope this helps,

Bruno--------------------- Info ---------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
& FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Post: <mailto:MacOSX-TeX at email.esm.psu.edu>