0

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

output

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)?

1 Answer 1

0

Use

\stackengine{-1.3\LMex}{\SavedStyle#1}{\tmpbox}{O}{c}{F}{T}{S}}%

in the definition of \wideacute and

\stackengine{-.4\LMex}{\SavedStyle#1}{\tmpbox}{O}{c}{F}{T}{S}}%

in the definition of \widegrave.

2
  • Thanks! Is the main insight changing the units from \LMpt to \LMex? Unfortunately, the distance between the accented text and the accent got larger also in normal font: i.imgur.com/p5ipSse.png .
    – user224332
    May 6, 2022 at 21:32
  • I ended up with \stackengine{-1.38\LMex}{\SavedStyle#1}{\tmpbox}{O}{c}{F}{T}{S}}% in \wideacute and \stackengine{-.52\LMex}{\SavedStyle#1}{\tmpbox}{O}{c}{F}{T}{S}}% in \widegrave: imgur.com/g2K03Ko.png .
    – user224332
    May 6, 2022 at 21:40

You must log in to answer this question.