# Text misplacement with certains combinations of \mathring and \overline

If I try to compile the following document

\documentclass{article}

\usepackage{mathtools}

\DeclareMathOperator{\Op}{Op}

\begin{document}

$1 + \mathring \Op(4) = 2$
$\overline{ 1 + \mathring \Op(4) } = 2$
$\mathring{\overline{ 1 + \mathring \Op(4) }} = 2$

\end{document}


the first two equations are displayed correctly, just as I want them. In the last one the text "Op" is misplaced on the right, superimposed on the "(4)". The \mathring symbol is correctly placed, but it has white below it, because the text has been moved. The rest of the formula appears to be formatted just like as the "Op" text was in the right place.

My first impression is that it is a bug of the macro set, but I'm not very confident with such intricacies, so I ask here if this is a mistake of mine or not (proper workarounds are also appreciated!).

In case it helps (I'm using a more or less up-to-date Debian sid):

pdflatex --version pdfTeX 3.1415926-2.5-1.40.14 (TeX Live 2013/Debian) kpathsea version 6.1.1 Copyright 2013 Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX). There is NO warranty. Redistribution of this software is covered by the terms of both the pdfTeX copyright and the Lesser GNU General Public License. For more information about these matters, see the file named COPYING and the pdfTeX source. Primary author of pdfTeX: Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX). Compiled with libpng 1.2.49; using libpng 1.2.49 Compiled with zlib 1.2.8; using zlib 1.2.8 Compiled with poppler version 0.18.4  Thanks. ## 2 Answers It's an example of the amsmath bug with nested accents dealt with in Why do arguments to nested \tilde or \breve commands reappear when amsmath is used? and that manifests itself when the inner accent is placed over multiple symbols. My suggestion is to define an \Opring operator, rather than using \mathring\Op, with low level trickery that doesn't use math accents. \documentclass{article} \usepackage{mathtools} \DeclareMathOperator{\Op}{Op} \DeclareMathOperator{\Opring}{% \text{\vbox{\offinterlineskip \halign{##\cr \hidewidth\r{}\hidewidth\cr \noalign{\kern-1ex}\Op\$\cr
}%
}}%
}
\begin{document}

$1 + \mathring\Op(4) = 2$ % just for comparison
$\overline{ 1 + \Opring(4) } = 2$
$\mathring{\overline{ 1 + \Opring(4) }} = 2$

\end{document}


Saving contents in a box before using it is often an easy-way-out:

\documentclass{article}

\usepackage{mathtools}% http://ctan.org/pkg/mathtools
\newsavebox{\mathbox}
\DeclareMathOperator{\Op}{Op}

\begin{document}

$1 + \mathring \Op(4) = 2$
$\overline{ 1 + \mathring \Op(4) } = 2$
$\mathring{\overline{ 1 + \mathring \Op(4) }} = 2$
$\savebox{\mathbox}{1 + \mathring \Op(4)}\mathring{\overline{ \usebox{\mathbox} }} = 2$

\end{document}

• Yes, I was about to write that I had found the same workaround. Definitely not elegant code, but at least the graphical result is good. Thanks! – Giovanni Mascellani Oct 13 '13 at 22:09
• I think it's the well known bug in amsmath with nested math accents. See tex.stackexchange.com/questions/30327/… – egreg Oct 13 '13 at 22:17