# Math expressions in italic text have more space on the right side than the left side

Minimal reproducible example:

\documentclass{article}

\usepackage{amsmath}
\newtheorem{lemma}{Lemma}

\begin{document}

\begin{lemma}
Suppose that $$a$$ and $$b$$ are integers.
\end{lemma}

\end{document}

Here, the math expressions are placed in an italic context. However, it seems that they receive more spacing on the right than the left. Is this observation true? If so, can I work around it (without manually adding something like \! each time)?

Is this observation true?

Truth, like beauty, is in the eye of the beholder....

....\OT1/cmr/m/it/10 t
....\glue 3.57774 plus 1.53333 minus 1.0222
....\mathon
....\OML/cmm/m/it/10 a
....\mathoff
....\glue 3.57774 plus 1.53333 minus 1.0222
....\OT1/cmr/m/it/10 a
....\OT1/cmr/m/it/10 n
....\OT1/cmr/m/it/10 d
....\glue 3.57774 plus 1.53333 minus 1.0222
....\mathon
....\OML/cmm/m/it/10 b
....\mathoff
....\glue 3.57774 plus 1.53333 minus 1.0222
....\OT1/cmr/m/it/10 a

So that as far as TeX is concerned there is only a normal word space either side of the math letters, however TeX is positioning rectangular boxes and you are looking at sloped non-rectangular letters. Personally I'd let it go but (essentially the opposite of italic correction \/) you could insert some thin negative space but you would have to do this "by hand" TeX has no information about the letter shapes, so can not really help here.

• As mentioned in Mico's answer, the result is different if a and b are just normal text instead of math expressions. Is some form of italic correction happening in \mathon and \mathoff, I guess? – L. F. Oct 8 '19 at 11:09
• @L.F. No there are no extra spaces added by mathon/mathoff (as \mathsurround is 0pt) it is simply that the text italic is a different font which has smaller, and more symmetric sidebearings in this case. As far as TeX is concerned the spacing is equal It is just that the math italic b is somewhat visually to the left of its bounding box, but tex has no information about that. – David Carlisle Oct 8 '19 at 11:43

You wrote,

Here, the math expressions a and b are placed in an italic context. However, it seems that they receive more spacing on the right than the left. Is this observation true?

The answer depends very much on the letter that's rendered either in math mode or in text-italic mode in the italics group. Here are several examples -- the black part uses math mode, and the superimposed red part uses text-italic mode:

For the a-b example you considered in your posting, it is true that the combined whitespace on either side of a and b is about the same for both a and b, and also that there's more asymmetry -- less whitespace to the left and more whitespace to the right -- for the math mode case than for the text-italic case.

More generally, though, the exact differences in the horizontal offsets depend both on which letters are rendered in math mode and on the letter(s) -- if any -- that immediately precede the space before the math mode material.

\documentclass[border=1pt,preview]{standalone}
\usepackage{xcolor}
\newlength\mylen

\newcommand\blurba[2]{\textit{that $#1$ and $#2$ are}}
\newcommand\blurbb[2]{\textit{that #1 and #2 are}}
\newcommand\mykern[2]{\settowidth{\mylen}{\blurba{#1}{#2}}%
\kern-\mylen}
\newcommand\blurb[2]{\blurba{#1}{#2}%
\mykern{#1}{#2}%
\textcolor{red}{%
\blurbb{#1}{#2}}}

\begin{document}
\obeylines
\blurb{a}{b}
\blurb{d}{l}
\blurb{u}{v}
\blurb{x}{z}
\end{document}
• I noticed that in all four lines, the space after the math expressions is more than the case with normal text. This causes me to suspect that some form of italic correction is happening when leaving math mode. Can you shed some light on this? – L. F. Oct 8 '19 at 11:12
• @L.F. - I'm afraid I lack the knowledge required to answer your question. Very sorry. – Mico Oct 8 '19 at 20:38
• Ok ... it seems from David Carlisle’s answer that this is more of a font design oversight. Thank you for your illustration! – L. F. Oct 9 '19 at 8:11

I have confirmed that this is purely a font design issue by using \usepackage{mathptmx}:

Now the problem does not exist anymore.