2

I was trying to improve the visual on a double exponant (text associated to a tilde) and found the following solution online. The problem is that the spacing after seems a bit odd, any help would be appreciated!

\documentclass[10pt,a4paper]{article}
\begin{document}
The space after $\widetilde{G\mkern 0mu}^{\scriptscriptstyle def}$ is too large.
\end{document} 
9
  • 1
    Well, doesn't a \! before the closing $ do what you want?
    – frougon
    Apr 5, 2020 at 22:19
  • What's the purpose of the \mkern0mu directive?
    – Mico
    Apr 5, 2020 at 22:22
  • @Mico Try it...
    – frougon
    Apr 5, 2020 at 22:25
  • 1
    @Mico Maybe, but that is not the question. :)
    – frougon
    Apr 5, 2020 at 22:29
  • 1
    @WrabbitW You are not serious. I did try \documentclass[10pt,a4paper]{article} \begin{document} The space after $\widetilde{G\mkern 0mu}^{\scriptscriptstyle def}\!$ is too large. \end{document}, the spacing is definitely changed. You can even use several \! in a row like \!\! if that isn't enough for you.
    – frougon
    Apr 5, 2020 at 22:32

3 Answers 3

4

There's not too much space, as far as TeX is concerned.

\documentclass[10pt,a4paper]{article}

\newcommand{\noic}[1]{\kern-\fontcharic\scriptscriptfont\fam`#1 }
\newcommand{\vr}{\kern-0.05pt\vrule width 0.1pt\kern-0.05pt}

\pagestyle{empty}
\begin{document}

$\widetilde{G\mkern 0mu}^{\scriptscriptstyle def}${\vr} x x

$\widetilde{G\mkern 0mu}^{\scriptscriptstyle def\noic{f}}${\vr} x x

\showoutput

\end{document}

enter image description here

The hairline is meant to show where TeX thinks the formula ends. If you look at the space between the hairline and “x”, you'll realize it's the same as the space between the two following letters.

What's the difference between top and bottom? At the end of the superscript, TeX, by rule, adds the italic correction pertaining to the last math letter. As you can see in the log file, from

....\hbox(3.47221+0.97221)x11.59406, shifted -7.2778
.....\OML/cmm/m/it/5 d
.....\OML/cmm/m/it/5 e
.....\OML/cmm/m/it/5 f
.....\kern0.59029
....\mathoff

the italic correction is about 0.6pt (that is, 0.21mm). In the bottom row the italic correction is removed

....\hbox(3.47221+0.97221)x11.00377, shifted -7.2778
.....\OML/cmm/m/it/5 d
.....\OML/cmm/m/it/5 e
.....\OML/cmm/m/it/5 f
.....\kern0.59029
.....\kern -0.59029
....\mathoff

by explicitly inserting a negative kern. The difference is very tiny even at the big magnification in the picture.

The visual problem is due to the shape of the math italic “f”. If you deem the produced hole is too big (I don't think so), then add yourself a negative kern after the formula.

With a proper setting of the “def” text, upright, you get

and the problem is much less evident. The italic correction is about 0.44pt (that is, 0.14mm).

4
  • couldn't you also mention that this should be \mathrm{def} or \mathit{def}` def written in math italic is painful:-) Apr 6, 2020 at 8:37
  • @DavidCarlisle I guess that “def” was just used for testing. But I'll add it.
    – egreg
    Apr 6, 2020 at 8:47
  • Thank you for your answer, I think I get why I am having the spacing. I know I should not put text ''inside'' math mode using \! but it just feel prettier to me!
    – WrabbitW
    Apr 7, 2020 at 5:09
  • @DavidCarlisle I will definively put ''def'' in regular text , sorry if I hurt your eyes so badly.
    – WrabbitW
    Apr 7, 2020 at 5:10
3

The space after the exponent can be reduced using a negative \thinmuskip, which can be done with \!:

\documentclass{article}
\begin{document}

The space after $\widetilde{G\mkern 0mu}^{\scriptscriptstyle def}$ is large.

The space after $\widetilde{G\mkern 0mu}^{\scriptscriptstyle def}\!$ is less
large.

The space after $\widetilde{G\mkern 0mu}^{\scriptscriptstyle def}\!\!$ is even
narrower.

\bigskip
Other possibility: if ``def'' is text, better use
$\widetilde{G}^{\mathrm{def}}$,
$\widetilde{G}^{\scriptscriptstyle\mathrm{def}}$, or
$\widetilde{G\mkern 0mu}^{\scriptscriptstyle\mathrm{def}}$.

\end{document}

enter image description here

4
  • as I just commented to egreg: couldn't you also mention that this should be \mathrm{def} or \mathit{def}` def written in math italic is painful:-) Apr 6, 2020 at 8:37
  • @DavidCarlisle You mean, instead of the \textup I used in the last examples? Because of font size?
    – frougon
    Apr 6, 2020 at 8:39
  • actually I didn't notice the last line (perhaps because my eye was streaming from the pain of the first part:-) (textup would be OK if you used amsmath then it would respect the math font size automatically, but I think \mathrm is better here.) Apr 6, 2020 at 8:42
  • @DavidCarlisle Okay, I've switched to \mathrm, thanks for your advice!
    – frougon
    Apr 6, 2020 at 8:48
2

Consider the following screenshot:

enter image description here

The four math-y terms are generated by $\widetilde{G\mkern 0mu}^{\scriptscriptstyle def}$, $\widetilde{G}^{\scriptscriptstyle def}$,$\widetilde{G}^{\scriptscriptstyle \mathrm{def}}$, and $\widetilde{G}^{\textup{\tiny def}}$, respectively.

The first two terms differ only in the height of the superscript term "def" above the baseline; in both cases, the "def" particle is rendered in math mode. It is known that the letter f has very pronounced side-bearings when typeset in math mode. That's why you're getting the large gap to the next word ("is") -- as well as between "e" and "f". Speaking for myself, I wouldn't use (pure) math-mode "def", regardless of any horizontal spacing issues.

I'm assuming that you will prefer the look of either the third or the fourth term. The former uses math mode -- specifically: \scriptscriptstyle\mathrm{def} -- whereas the letter uses text mode -- \textup{\tiny def}. Observe that the trailing gap generated by the text mode approach is ever so slightly less than that of the math mode approach.

\documentclass{article}
\begin{document}
The space after $\widetilde{G\mkern0mu}^{\scriptscriptstyle def}$ is too large.

The space after $\widetilde{G}^{\scriptscriptstyle def}$ is too large.

The space after $\widetilde{G}^{\scriptscriptstyle \mathrm{def}}$ is too large.

The space after $\widetilde{G}^{\textup{\tiny def}}$ is too large.
\end{document} 
3
  • Thank you for responding but I like the solution of @frougon better, the ''def'''particle refers to the tilde not to G that is why I used the command initially posted.
    – WrabbitW
    Apr 5, 2020 at 22:45
  • @WrabbitW - You're perfectly free to reinsert \mkern0mu. It doesn't affect the horizontal spacing at all.
    – Mico
    Apr 5, 2020 at 22:46
  • 1
    Oh I see, the ''def'' particle is much nicer with this. I will then combine the two solutions. Thank you!
    – WrabbitW
    Apr 5, 2020 at 22:59

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.