# underline breaking ligatures

This is another version of my color question, as I've found another case where the problem occurs.

In some behind the scenes work for spacing reasons, the pieces of a syllable get split up in gregoriotex and then reassembled for printing. Normally this works fine, but we're running into some ligature problems when styling is involved. The results can be seen in the following MWE:

\documentclass{article}

\begin{document}
\Huge
{\itshape f}{\itshape i}

{\itshape fi}

\underline{f}\underline{i}

\underline{fi}
\end{document}


For italics, using the switches allows the ligatures to form across groups, but I don't know of any equivalent for underlining. I've tried \ul from soul, \uline from ulem, \textul from underlin, and \Underline from umoline and they produce the same results as above. Is there some other way/package that would allow this to work?

LuaTeX tag is used because the gregoriotex package (into which any solution is destined to be inserted) is only compatible with Lua(La)TeX (preferably both). Our current trick for making underlining work in LuaTeX is to switch into math mode: $\underline{\rm #1}$. If your answer would require changing that, please indicate that.

• You could try this tex.stackexchange.com/a/437779/2388, it uses attributes like luacolor so probably will work. – Ulrike Fischer May 23 at 13:44
• Maybe you can underline with TikZ, cf. tex.stackexchange.com/questions/405376/… ? – Marijn May 23 at 15:42
• why $\underline{\rm #1}$ ? It is definitely not a good choice for latex (which does not define \rm by default.) – David Carlisle May 23 at 15:58
• That’s only used in Plain TeX. In LaTeX we’re currently using \underline as in the MWE above. Since Plain doesn’t define that macro in text mode, we cheat by switching to math mode. It’s probably an ugly hack, but up until now it’s worked. This issue will probably drive us to switch, but it’s a matter of figuring out to what. – rpspringuel May 23 at 16:43