[XeTeX] bug using \underbrace with unicode-math package

Philip TAYLOR (Webmaster, Ret'd) P.Taylor at Rhul.Ac.Uk
Mon Sep 12 00:06:29 CEST 2011



Daniel Greenhoe wrote:
> Using \underbrace with the unicode-math package under XeLaTeX produces
> garbage output. Here is a minimal example:
>
> \documentclass{book}
>  \usepackage{unicode-math}
>  \setmathfont{xits-math.otf}
> \begin{document}%
>  \[ \underbrace{xyz} \]
> \end{document}%
>
> Using the mathspec package instead of unicode-math seems to be OK.
> The \underbrace with unicode-math problem was discussed almost one year ago.
> Does anyone have a solution?

For reasons that are totally beyond my comprehension, the following
(stolen from http://tex.stackexchange.com/questions/3488/horizontal-braces-with-xetex-take-too-much-space)
appears to solve the problem :

\documentclass{article} \RequirePackage{amsmath} \RequirePackage{unicode-math} \setmathfont{xits-math.otf}

\def\midshift#1{

\setbox0=\hbox{#1}\dimen0=\ht0\advance\dimen0by+\dp0\advance\dimen0by-1ex

\lower.5\dimen0\box0 }

\def\rotatebrace#1{%

\leavevmode\setbox0=\hbox{#1}\rlap{%

\kern.5\wd0\dimen0=\ht0\advance\dimen0by-\dp0%\advance\dimen0by+1ex%

\raise.5\dimen0\hbox{\special{x:gsave}\special{x:rotate 90}}}%

\box0\special{x:grestore}}

\XeTeXmathchardef\bracelu = 0 3 `\⎧

\XeTeXmathchardef\bracemu = 0 3 `\⎨

\XeTeXmathchardef\braceru = 0 3 `\⎩

\XeTeXmathchardef\bracebar = 0 3 `\⎪

\XeTeXmathchardef\braceld = 0 3 `\⎫

\XeTeXmathchardef\bracemd = 0 3 `\⎬

\XeTeXmathchardef\bracerd = 0 3 `\⎭

\def\upbracefill{%

\setbox0=\hbox{\lower.64ex\hbox{\rotatebrace{\midshift{$\bracemu$}}}}\ht0=.1\wd0\dp0=0pt%

\setbox1=\hbox{\lower.64ex\hbox{\rotatebrace{\midshift{$\bracelu$}}\kern-.2em}}\ht1=.1\wd0\dp1=0pt%

\setbox2=\hbox{\lower.64ex\hbox{\rotatebrace{\midshift{$\bracebar$}}}}\ht2=.1\wd0\dp2=0pt%

\setbox3=\hbox{\lower.64ex\hbox{\kern-.2em\rotatebrace{\midshift{$\braceru$}}}}\ht3=.1\wd0\dp3=0pt%

\box1\cleaders\copy2\hfill\box0\cleaders\box2\hfill\box3}

\def\downbracefill{%

\setbox0=\hbox{\lower.64ex\hbox{\rotatebrace{\midshift{$\bracemd$}}}}\ht0=.1\wd0\dp0=0pt%

\setbox1=\hbox{\lower.64ex\hbox{\rotatebrace{\midshift{$\braceld$}}\kern-.2em}}\ht1=.1\wd0\dp1=0pt%

\setbox2=\hbox{\lower.64ex\hbox{\rotatebrace{\midshift{$\bracebar$}}}}\ht2=.1\wd0\dp2=0pt%

\setbox3=\hbox{\lower.64ex\hbox{\kern-.2em\rotatebrace{\midshift{$\bracerd$}}}}\ht3=.1\wd0\dp3=0pt%

\box1\cleaders\copy2\hfill\box0\cleaders\box2\hfill\box3}%

\setmathfont {XITS Math}

\begin {document}

$$ \underbrace{xyz} $$

\end{document}


Philip Taylor


More information about the XeTeX mailing list