[XeTeX] A bug in (Xe)LaTeX?

Herbert Schulz herbs at wideopenwest.com
Thu Aug 18 22:36:28 CEST 2005


On Aug 18, 2005, at 2:55 PM, Peter Dyballa wrote:

> Hello!
>
> Two weeks ago a discussion started whether XeLaTeX could be used to  
> type aesthetically appealing thing with LaTeXiT (http://ktd.club.fr/ 
> programmation/latexit_en.php). Its author, Pierre Chatelier,  
> offered a little bit of LaTeX code to 'catch' particularly a  
> mathematical formula and to report the dimensions of the box into  
> which the 'caught' objects fits. Ross Moore contributed some other  
> code to handle that object in pdfTeX or in classic TeX.
>
> And I kind of 'ported' that code to XeLaTeX to find a script to do  
> the same with XeLaTeX what's so easy in LaTeX. This is the test  
> file's body:
>
>     \usepackage{geometry,graphicx}
>     \usepackage{ifpdf}
>     \pagestyle{empty}
>     \newsavebox{\latexitbox}
>     \newcommand{\latexitscalefactor}{3.600000}    % used in LaTeXiT
>     \newlength{\latexitwidth}
>     \newlength{\latexitheight}
>     \newlength{\latexitdepth}
>     \setlength{\topskip}{0pt}
>     \setlength{\parindent}{0pt}
>     \setlength{\abovedisplayskip}{0pt}
>     \setlength{\belowdisplayskip}{0pt}
>     \normalfont
>
>     \begin{lrbox}{\latexitbox}
>     %  $\displaystyle \frac{\partial}{\partial x} f(x,y) = r^2 +  
> \sum_{0}^{100} x^\frac{1}{3} \cdot y^4$
>       $\displaystyle \frac{\partial}{\partial x} f(x,y) = \frac 
> {\partial}{\partial y} f(x,y) = 0$
>     \end{lrbox}
>
>     \settowidth{\latexitwidth}{\scalebox{\latexitscalefactor} 
> {\usebox{\latexitbox}}}
>     \settoheight{\latexitheight}{\scalebox{\latexitscalefactor} 
> {\usebox{\latexitbox}}}
>     \settodepth{\latexitdepth}{\scalebox{\latexitscalefactor} 
> {\usebox{\latexitbox}}}
>     \addtolength{\latexitdepth}{2\fboxrule}    % correct correction  
> (was 0.72 pt before)
>     %\addtolength{\latexitdepth}{2\fboxsep}    % length contained  
> in \latexitdepth
>     \addtolength{\latexitheight}{\latexitdepth}
>     \newwrite\foo
>      \immediate\openout\foo=\jobname.sizes
>       \immediate\write\foo{\the\latexitdepth (Depth)}
>       \immediate\write\foo{\the\latexitheight (Height)}
>       \immediate\write\foo{\the\latexitheight (TotalHeight)}
>       \immediate\write\foo{\the\latexitwidth (Width)}
>       \immediate\write\foo{\the\fboxsep (fboxsep)}
>       \immediate\write\foo{\the\fboxrule (fboxrule)}
>     \closeout\foo
>
>     \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}
>
>
> This is the LaTeX header:
>
>     \documentclass[10pt]{article}
>     \usepackage{color}\color[rgb]{0.000,0.000,0.000} %pour la couleur
>     \usepackage{amssymb} %maths
>     \usepackage{amsmath} %maths
>
>
> And here is the XeLaTeX header:
>
>     \documentclass[10pt]{article}
>     \usepackage{color}\color[rgb]{0.000,0.000,0.000} %pour la couleur
>     \usepackage{amssymb} %maths
>     \usepackage{amsmath} %maths
>     \usepackage{xunicode,fontspec}
>     \setromanfont[Mapping=tex-text,Numbers=Lining]{Hoefler Text}
>
>
> I used these scripts to LaTeX
>
>     #!/bin/sh
>     jobname=latexit-2
>     latex -file-line-error -interaction nonstopmode ${jobname}.tex  
> > /dev/null
>     x=`grep Width       ${jobname}.sizes | awk -F\( '{print $1}'`
>     y=`grep TotalHeight ${jobname}.sizes | awk -F\( '{print $1}'`
>     echo "$x x $y"
>     dvips -q1 -T $x,$y -f ${jobname}.dvi | ps2pdf14 - AusgabeLaTeX.pdf
>
> or to XeLaTeX the TeX documents:
>
>     #!/bin/sh
>     jobname=xelatexit-2
>     xelatex -no-pdf -file-line-error -interaction nonstopmode $ 
> {jobname}.tex > /dev/null
>     x=`grep Width       ${jobname}.sizes | awk -F\( '{print $1}'`
>     y=`grep TotalHeight ${jobname}.sizes | awk -F\( '{print $1}'`
>     echo "$x x $y"
>     xdv2pdf -p $x,$y -o AusgabeXeLaTeX.pdf ${jobname}.xdv
>
> In both cases I got told these box dimensions: 423.05525pt x  
> 81.84862pt (for LaTeX in half the time).
>
> TeXShop 1.40 on Panther (Mac OS X 10.3.9) was used to view the PDF  
> output. In both cases I see the ¶ in the numerator clipped -- both  
> ¶ifferently but same in the same file:
>
>
> <texshop_image.png>
>  from LaTeX,
> <texshop_image.png>
>  from XeLaTeX
>
> In both cases I see the ¶y in the denominator like these fine:
>
>
> <texshop_image.png>
>  from LaTeX,
> <texshop_image.png>
>  from XeLaTeX
>
>
> Where is my mistake? Or where are my mistakes? (And why do I see  
> the light green background here in Mail with the copies and not in  
> TeXShop?)
>
> Adding
>
>     \addtolength{\latexitheight}{1.25\fboxrule}
>
> in LaTeX to the body gives the best look with some white space  
> above the ¶. Increasing or decreasing that value makes it only  
> worse! In XeLaTeX this makes the ¶ fit exactly, without any space.
>
>
> Outside my appartement it's full moon as I can see: does this  
> explain ...
>
>
> At least it seems as if a way was found to do in XeLaTeX too what  
> is possible in LaTeX.
>
> --
> Greetings
>
>   Pete
>
> "What is this talk of 'release'?  Klingons do not make software
> 'releases'.  Our software 'escapes' leaving a bloody trail of
> designers and quality assurance people in its wake."

Howdy,

I wonder if the problem is that glyphs can extend outside of their  
box. I've put a 0.5pt border around the object (LaTeXit preferences)  
to take care of that. Is there some way of using pdfcrop on a  
generated pdf file and then get the Bounding Box from that?

Good Luck,

Herb Schulz
(herbs at wideopenwest.com)




More information about the XeTeX mailing list