6

I have this simple LaTeX document:

\documentclass{article}

\begin{document}
There is quite a lot of space after a math-mode $W$, if it is followed by a comma.
\end{document}

Rendering

To me, this looks like too much space after the W. Is there any solution to that? I'd prefer a global fix.

6
  • The fastet solution is to manually add some negative kerning, e.g., $W$\kern-.3em,
    – cgnieder
    Jun 6 '17 at 11:46
  • Insert more words after it and see if the space changes. I'd keep the default behaviour, ie, lets TeX decides to you the space to be used.
    – Sigur
    Jun 6 '17 at 11:46
  • 1
    The space shows the comma is not part of the formula.
    – egreg
    Jun 6 '17 at 11:53
  • @egreg That's a nice explanation, but does $A$,show that the comma is part of the formula? ;^) That is, $W$, versus $A$, then W, and A, shows consistent kerning between text and mathmode, even as A and W are kerned differently. Jun 6 '17 at 12:03
  • @egreg OK, but I don't have a full formula, I have a single character in math mode. Do you have any suggestion how to solve this issue?
    – W.Mann
    Jun 6 '17 at 12:05
4

You could (1) Just leave it or (2) Add some arbitrary negative space or (3) Set the comma inside the math allowing the font specified correction to be applied, but relying on a font setup that makes the math comma visually close enough to the text comma or (4) Use the text comma, but insert a kern equal to the spacing correction that would have been applied had the comma been in math mode.

I'd probably do (1) :-)

enter image description here

\documentclass[a4paper]{article}
\showoutput
\parindent0pt

\newcommand\mykern[2]{%
\sbox0{$#1#2$}\sbox2{$#1\hbox{}#2$}%
\kern\dimexpr\wd0-\wd2\relax
#2}

\begin{document}



There is quite a lot of space after a math-mode $W$, if it is followed by a comma.

There is quite a lot of space after a math-mode $W\!$, if it is followed by a comma.

There is quite a lot of space after a math-mode $W,$ if it is followed by a comma.

There is quite a lot of space after a math-mode $W$\mykern{W}{,} if it is followed by a comma.

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.