3

I noticed strange behavior, when a hyphen follows inline math mode, if I am using the txfonts package.

If I use the Computer Modern font, the kerning of these two cases, while not precisely the same, seems compatible with what I would expect.

\documentclass[12]{article}
\begin{document}
$S$-axis

\textit{S}-axis
\end{document}

enter image description here

However, using the txfonts, the disparity of these two cases becomes quite pronounced.

\documentclass[12]{article}
\usepackage{txfonts}
\begin{document}
$S$-axis

\textit{S}-axis
\end{document}

enter image description here

I can, of course, resort to manual intervention, such as $S\!$-axis. However, I was wondering if this is to be considered as a flaw in one of the font metrics, or if this is the sort of thing a user is expected to "roll with"?

Since S is a math-mode quantity, I would prefer to use the $S$-axis syntax. But that seems problematic here.

4
  • It's not a kerning issue, but rather the box of S with txfonts is quite larger than the letter itself. Fixing such things is in part what led to newtx; so in a sense I'd say, as you wonder, that this is in fact a flaw in the txfonts.
    – campa
    Commented Oct 6, 2020 at 9:55
  • @campa Thanks for the reply. But I wonder, why does it only affect $S$ and not \textit{S}, if it is the underlying S that is at fault? Commented Oct 6, 2020 at 12:57
  • Well, the italic letters have different bounding boxes for text and math even if they look alike; this is true also for CM (I remember a couple of related questions, I'll see if I can find them). So in the end I believe it still boils down to a (poor?) design choice in txfonts.
    – campa
    Commented Oct 6, 2020 at 13:57
  • @campa I would welcome an answer where you put these thoughts down. Commented Oct 6, 2020 at 14:01

1 Answer 1

4

The italic text letters come from the OT1 (or T1) font with it shape, while the math letters from the OML encoded font (also with the it shape). Although they look very similar, they are not necessarily identical: for example, overlapping the text-italic and the math-italic S in Computer Modern shows that the math version is somewhat broader

\documentclass{article}
\usepackage{xcolor}
\begin{document}
\makebox[0pt][l]{\color{red}\textit{S}}$S$
\end{document}

enter image description here

Furthermore, even they were identical in shape their bounding boxes would in general differ (sometimes a lot), as the following snippet shows for Computer Modern, txfonts and newtx:

\documentclass{article}

\begin{document}

\setlength{\fboxsep}{-\fboxrule}
\mathsurround=0pt

CM: {\usefont{OT1}{cmr}{m}{it}\fbox{S}}
    {\usefont{OML}{cmm}{m}{it}\fbox{S}}

tx: {\usefont{OT1}{txr}{m}{it}\fbox{S}}
    {\usefont{OML}{txmi}{m}{it}\fbox{S}}

newtx: {\usefont{OT1}{ntxtlf}{m}{it}\fbox{S}}
       {\usefont{OML}{ntxmi}{m}{it}\fbox{S}}

\end{document}

enter image description here

In the case of the tx fonts, it is clear that the bounding box of the math-italic S leaves a large empty space on the right of the glyph.

Coming to your question

However, I was wondering if this is to be considered as a flaw in one of the font metrics, or if this is the sort of thing a user is expected to "roll with"?

I would say that it is a (poor?) design choice of the font. I won't go as far as to call it a flaw ;-) because maybe there was a rationale behind it. Anyway, when I type math in a Times setting (well, never, but if I had to) I use the newtx fonts. The text version (newtxtext) is nowadays based on the TeX Gyre Termes, but (quote from the newtx documentation)

newtxmath continues to use the txfonts math glyphs with many metric adjustments and some wholesale modifications.

1
  • An excellent and informative answer. Thanks so much! Commented Oct 7, 2020 at 12:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .