Compiling this example:


\setmathfont{Latin Modern Math}

  \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}

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}:


Adding an \hphantom{} before \bar


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

\input ifluatex.sty
  \input luaotfload.sty

\textfont1=\mf \scriptfont1=\mf \scriptscriptfont1=\mf
  \mathop{\Umathaccent bottom 7 1 "023DF\relax {#1}}\limits
\protected\def\hat{\Umathaccent fixed 7 1 "00302\relax}



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. Aug 8, 2016 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 Aug 8, 2016 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. Aug 8, 2016 at 9:46
  • @HenriMenke Indeed LuaLaTeX without unicode-math works fine. Aug 8, 2016 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, 2017 at 9:59

1 Answer 1


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


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

  \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}

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, 2016 at 10:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .