Continuing Wide acute and wide grave for TeX Gyre Termes and TeX Gyre Termes Math , we try to make wide grave and accute accents work in \smaller
with TeX Gyre Termes (Math) fonts and UTF-8 engines (for NewTX and pdflatex
, cf. How to make wide grave and acute accents accurate also in \smaller when using NewTX and pdflatex? ):
\documentclass{article}
\pagestyle{empty}
\usepackage{unicode-math}
\setmainfont[Ligatures=TeX]{TeX Gyre Termes}
\setsansfont{TeX Gyre Heros}[Scale=0.88]%%% Somewhat ok.
\setmonofont{TeX Gyre Cursor}%%% No explicit turning on ligatures for the monospaced font.
\setmathfont[Ligatures=TeX]{TeX Gyre Termes Math}
\usepackage{scalerel,stackengine}\stackMath
\usepackage{relsize}
%%% thanks to http://tex.stackexchange.com/a/611030
\newcommand\wideacute[1]{%
\ThisStyle{\savestack\tmpA{$\SavedStyle#1$}%
\savestack{\tmpbox}{$\SavedStyle\stretchto{%
\scalerel*[\wd\tmpAcontent]%
{\kern-.83\LMpt\Umathchar"7"0"00B4\kern-.12\LMpt}%
{\rule{0ex}{\textheight}}%
}{2\LMex}$}%
\stackengine{-6.3\LMpt}{\SavedStyle#1}{\tmpbox}{O}{c}{F}{T}{S}}%
}
\newcommand\widegrave[1]{%
\ThisStyle{\savestack\tmpA{$\SavedStyle#1$}%
\savestack{\tmpbox}{$\SavedStyle\stretchto{%
\scalerel*[\wd\tmpAcontent]%
{\kern-.43\LMpt\char"0060%
\kern-.9\LMpt}%
{\rule{0ex}{\textheight}}%
}{1.05\LMex}$}%
\stackengine{-2.3\LMpt}{\SavedStyle#1}{\tmpbox}{O}{c}{F}{T}{S}}%
}
\begin{document}
\newcommand{\test}[1]{\(\displaystyle \wideacute{#1}\ \widegrave{#1}\) \(\textstyle \wideacute{#1}\ \widegrave{#1}\) \(\scriptstyle \wideacute{#1}\ \widegrave{#1}\) \(\scriptscriptstyle \wideacute{{#1}}\ \widegrave{#1}\)}%
\newcommand{\ttest}[1]{\test{#1}\\{\smaller\test{#1}}}%
\newcommand{\tttest}[1]{\ttest{\mathit{#1}}}%
\noindent
\tttest{sum}\\
\tttest{loop}\\
\tttest{pool}\\
\tttest{buffer}\\
\ttest{\sigma_k}
\end{document}
Feeding this to lualatex
results in
As you see, the distance between a word and its accent is somewhat acceptable in normal-size font (though you could also complain there that this distance is too large in the grave'd “loop” and the acute'd “pool”).
However, in the version in \smaller
these two parts overlap, which is undesirable. How to introduce a dependency on the font size so that the normal-size version still looks good (or, at least, not worse than it currently is, i.e., the accent should still sit just above the word) and the smaller-size version looks better (i.e., the accent should not overlap the word)?