# unicode-math gobbling up glyphs from other package

I would like Times New Roman as my default font for text and mathematics, and after having tried out several I've found TeX Gyre to have the best coverage. But by using unicode-math for the mathematics, it seems to cause the lilyglyphs package not to display its symbols. The documentation for the latter requires fontspec to be loaded which, if called with the no-math option, produces an error.

Compiling the below MWE using lualatex.

\documentclass{article}

\usepackage{unicode-math}
\usepackage{fontspec}
\usepackage{lilyglyphs}

\setmainfont{Tex Gyre Termes}
\setmathfont{TeX Gyre Termes Math}

\begin{document}
6
\sharp{} %from lilyglyphs
$\widehat{6}$
\end{document}



The MWE includes the Times New Roman numeral but no lilyglyph. The \widehat is also wonky:

Commenting out unicode-math and \setmathfont shows the lilyglyph correctly and the widehat is correct too, but the numeral is no longer Times New Roman (of course):

My desired output is the second picture but with both numerals in Times New Roman. Is this possible?

The accent position seems to be just a feature in the font (you see same position without lilygyphs) I shifted it a bit here (actually it is shifted too far I think).

The \sharp goes as unicode-math delays all its definitions until begin document and TeX Gyre Termes Math does not have the character, you can re-instate the lilyglyphs version.

\documentclass{article}

\usepackage{lilyglyphs}
\let\zzzsharp\sharp
\AtBeginDocument{\let\sharp\zzzsharp}
\usepackage{unicode-math}

\setmainfont{Tex Gyre Termes}
\setmathfont{TeX Gyre Termes Math}

\begin{document}

6
\sharp{} %from lilyglyphs
$\mkern-1mu \widehat{\mkern1mu6}$
\end{document}

• I fixed a few typos: you're reaching new heights! Mar 1 at 21:08
• @egreg new laptop, different keyboard so yes typing worse than my usual excellent standard but hopefully temporary... (thanks) Mar 1 at 21:10
• @egreg do you have a better accent suggestion, I wasn't feeling very creative here. Mar 1 at 21:11
• @DavidCarlisle Thanks this works great! Since I'm using quite a number of glyphs from that package and from a few others too is there any way of defining symbols automatically or am I stuck with redefining each glyph manually? Mar 1 at 21:16
• As far as I can see, the hat is positioned correctly on letters. Unfortunately, there is no way to substitute accents, yet. Will should try to provide it. Mar 1 at 21:19