5

Compiling this example:

\documentclass{scrartcl}

\usepackage{mathtools}
\usepackage{unicode-math}
\setmathfont{Latin Modern Math}

\begin{document}
\begin{equation*}
  \symcal{L}_{\text{QED}} =
    - \underbrace{\frac{1}{4} F_{\mu\nu} F^{\mu\nu}}_\text{Photon}
    + \underbrace{\bar{\psi} (i \gamma^\mu\partial_\mu - m) \psi}_\text{Dirac}
    - \underbrace{eQ\bar{\psi} \gamma_\mu \psi A^\mu}_\text{WW}
\end{equation*}
\end{document}

using lualatex from TeXLive 2016, the second \underbrace is shifted to the left. This only seems to happen when the first thing in the \underbrace is \bar.

Even adding something ridiculous like \hphantom{} resolves the issue.

Only \underbrace{\bar{\psi} (i \gamma^\mu\partial_\mu - m) \psi}_\text{Dirac}:

result1

Adding an \hphantom{} before \bar

result2


A “more minimal” example, to be compiled with luatex

\input ifluatex.sty
\ifluatex
  \input luaotfload.sty
\fi

\font\mf="[latinmodern-math.otf]"
\textfont1=\mf \scriptfont1=\mf \scriptscriptfont1=\mf
\protected\def\underbrace#1{%
  \mathop{\Umathaccent bottom 7 1 "023DF\relax {#1}}\limits
}
\protected\def\hat{\Umathaccent fixed 7 1 "00302\relax}

$\underbrace{z+w}_y$\qquad$\underbrace{\hat{z}+w}_{y}$

\bye

enter image description here

If compiled with xetex, the output is

enter image description here

Changing the math font to xits-math.otf doesn't change the situation. With Asana-Math.otf the output is different:

enter image description here enter image description here

  • This also happens with other accents such as \hat... it should be reported as a bug. – Andrew Swann Aug 8 '16 at 8:42
  • it's enough to use {} not sure yet whether it's a problem in unicode-math or luatex (it's not mathtools, you get the same if you use \[ and just load amstex for \text – David Carlisle Aug 8 '16 at 8:44
  • 1
    It is unicode-math under lualatex that is the problem. Minimal example: \documentclass{article} \usepackage{unicode-math} \begin{document} \begin{displaymath} \underbrace{ABCDEFGH}_P + \underbrace{\bar a IJKLMNOP}_D \end{displaymath} \end{document}. Under XeLaTeX it is fine. – Andrew Swann Aug 8 '16 at 9:46
  • @HenriMenke Indeed LuaLaTeX without unicode-math works fine. – Andrew Swann Aug 8 '16 at 10:31
  • The problem still seems to exist in TeX Live 2017. Bug report for unicode-math: github.com/wspr/unicode-math/issues/391 – Socob Oct 23 '17 at 9:59
2

As a temporary workaround, you could add the empty brace group proposed by David Carlisle in the definition of the over- and underbraces.

\documentclass{article}
\usepackage{amstext}
\usepackage{unicode-math}
\ExplSyntaxOn

\cs_set:Nn \__um_set_math_overunder:Nnnn
 {
  \cs_gset_protected_nopar:Npx #1 ##1
   {
    \mathop
     { \__um_accent:nnn {#2} {#3} {#4} {{}{##1}} } % see the empty braces?
    \limits
   }
 }

\ExplSyntaxOff
\begin{document}
\[
  \symcal{L}_{\text{QED}} =
    - \underbrace{\frac{1}{4} F_{\mu\nu} F^{\mu\nu}}_\text{Photon}
    + \underbrace{\bar{\psi} (i \gamma^\mu\partial_\mu - m) \psi}_\text{Dirac}
    - \underbrace{eQ\bar{\psi} \gamma_\mu \psi A^\mu}_\text{WW}
\]
\end{document}

enter image description here

  • 1
    Better: \__um_accent:nnn {#2} {#3} {#4} {{}{##1}}, so the empty group will not interfere with the spacing at the beginning of the argument (for instance, if it's an operator). – egreg Aug 8 '16 at 10:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.