I switched to XeLaTeX and unicode-math a while ago. I really like the possibility to combine different fonts for mathematical symbols. But now I run into trouble by combining the \underbrace command with content from different fonts. I actually use Asana as my main math font, but don't like its \underbrace, as these are too wide and with too much space between itself and the content. Therfore I wanted to use some from another font, which gave some grapy output:
\documentclass[]{scrartcl}
\usepackage{amsmath}
\usepackage{polyglossia}
\setmainlanguage[]{english}
\setotherlanguage[spelling=new,babelshorthands=true]{german}
\usepackage{unicode-math}
\setmathfont{Asana-Math.otf}
\begin{document}
Asana math Blubb
\[
\underbrace{1} \quad \underbrace{1+1} \quad \underbrace{1+1+1} \quad \underbrace{1+1+1+1} \quad \underbrace{1+1+1+1+1}
\]
\setmathfont[]{xits-math.otf}
XITS math
\[
\underbrace{1} \quad \underbrace{1+1} \quad \underbrace{1+1+1} \quad \underbrace{1+1+1+1} \quad \underbrace{1+1+1+1+1}
\]
\setmathfont[]{Cambria Math}
Cambria Math
\[
\underbrace{1} \quad \underbrace{1+1} \quad \underbrace{1+1+1} \quad \underbrace{1+1+1+1} \quad \underbrace{1+1+1+1+1}
\]
\setmathfont[]{latinmodern-math.otf}
Latin modern
\[
\underbrace{1} \quad \underbrace{1+1} \quad \underbrace{1+1+1} \quad \underbrace{1+1+1+1} \quad \underbrace{1+1+1+1+1}
\]
\setmathfont[]{texgyrepagella-math.otf}
Neo Euler
\[
\underbrace{1} \quad \underbrace{1+1} \quad \underbrace{1+1+1} \quad \underbrace{1+1+1+1} \quad \underbrace{1+1+1+1+1}
\]
Asana as math font, change font for underbrace only:
\setmathfont[]{Asana-Math.otf}
\[
\underbrace{1} \quad \underbrace{1+1} \quad \underbrace{1+1+1} \quad \underbrace{1+1+1+1} \quad \underbrace{1+1+1+1+1}
\]
\setmathfont[range=\mathunder]{xits-math.otf}
XITS math
\[
\underbrace{1} \quad \underbrace{1+1} \quad \underbrace{1+1+1} \quad \underbrace{1+1+1+1} \quad \underbrace{1+1+1+1+1}
\]
\setmathfont[range=\mathunder]{Cambria Math}
Cambria Math
\[
\underbrace{1} \quad \underbrace{1+1} \quad \underbrace{1+1+1} \quad \underbrace{1+1+1+1} \quad \underbrace{1+1+1+1+1}
\]
\setmathfont[range=\mathunder]{latinmodern-math.otf}
Latin modern
\[
\underbrace{1} \quad \underbrace{1+1} \quad \underbrace{1+1+1} \quad \underbrace{1+1+1+1} \quad \underbrace{1+1+1+1+1}
\]
\setmathfont[range=\mathunder]{texgyrepagella-math.otf}
Neo Euler
\[
\underbrace{1} \quad \underbrace{1+1} \quad \underbrace{1+1+1} \quad \underbrace{1+1+1+1} \quad \underbrace{1+1+1+1+1}
\]
\end{document}
Is there any workaround for this? Or is it in general no good idea to combine different math fonts?
I'm in general not so sure if to stay with unicode-math, as the compilation speed slows down, and for example the XITS font has much too narrow spacing sometimes (using XeTeX, Version 3.1415926-2.4-0.9998, MiKTeX 2.9)
Annotation
According to the first comment I just tried the TeX Gyre Pagella Math which also seems to be a nice font with better
underbraces than Asana-math. But this brought me just to another behavior of unicode-math with XeLaTeX I have noticed
before already but forgotten about. If I run the following code:
\documentclass{article}
\usepackage{amsmath}
\usepackage{unicode-math}
\setmathfont{texgyrepagella-math.otf}
\begin{document}
Test.
\begin{align*}
\frac{1}{x^2} \quad \underbrace{1+1+1+1+1}_F \underbrace{1+1}_F \underbrace{i}_F
\end{align*}
\end{document}

Some minor changes that do not directly affect the math environment can change this behavior:
\documentclass{article}
\usepackage{amsmath}
\usepackage{unicode-math}
\setmathfont{texgyrepagella-math.otf}
\begin{document}
\begin{align*}
\frac{1}{x^2} \quad \underbrace{1+1+1+1+1}_F \underbrace{1+1}_F \underbrace{i}_F
\end{align*}
Some text.
\end{document}

I once got a similar behavior when I did a beamer presentation (using Asana-math, if I remember correctly) where changes anywhere
in the TeX code could affect the braces in the shown way. I thought that this would maybe depend on the special circumstances of
using beamer, but apparently hopping underbraces can appear anytime. Did anybody else see such a behavior of the \underbrace command
before?
TeX Gyre Pagella Mathinstead ofAsana Math– egreg Aug 27 '13 at 15:34