# Horizontally centering glyph over text

In the given MWE, note that the new slur command is not centered with the two Fs that it connects.

I've tried adjusting the scale of lilyGlyph, but it remains too far left. I would like the ends of the slur to be centered with either F. But if it's not too difficult, I'd also like to see how one could make the ends centered with the entire F$^x$ unit.

\stackon from the stackengine package may be helpful, as shown in Two-lined text (text over text) (see also Stackengine centering problem). I've supplied an attempt at the bottom of the MWE, but it's still not adequately centered, nor can I find a way to lower it.

(And for anyone curious, this is for a particular type of musical notation.)

%XeLaTeX
\documentclass{report}
\usepackage{fontspec}
\usepackage{graphicx}
\usepackage{lilyglyphs}
\usepackage{stackengine}

\newcommand{\slur}{%
\scalebox{2}[1]{%
\rotatebox{180}{\lilyGlyph[scale=1.5,raise=-2.0]{ties.lyric.default}}%
}%
\phantom{\textendash}%
}

\begin{document}
G$^2$--F$^2$\slur F$^1$--E$^1$

G$^2$--\stackon{F$^2$\phantom{\textendash}F$^1$}{\scalebox{2}[1]{\rotatebox{180}{\lilyGlyph[scale=1.5]{ties.lyric.default}}}}--E$^1$
\end{document}


• I did not manage to install lilyglphys, but would note that \stackon takes an optional length argument to denote the stacking gap, as in \stackon[1pt]{}{}, which you can use to lower the glyph. In a case like this, I would tend to employ the useanchorwidth setting, as well, thus \stackengine{1pt}{...}{...}{O}{c}{F}{T}{S} You can make the slur wider by increasing the {2} following \scalebox. – Steven B. Segletes Jul 6 '16 at 10:29