7

This is my first post here, so I hope I do it well (I am French).

I don't understand the spacing after \mathinner.

Here is a MWE:

\documentclass[a4paper]{article}

\begin{document}
$\mathinner{}!$

$\mathinner{}{!}$
\end{document}

The spacing before ! is not the same.

I thought ! was of type \mathord so typing {!} shouldn't change the spacing but it does: there is a \thinmuskip in the second line (which is correct between \mathinner and \mathord) but not in the first line and I don't get it. Why is ! not of type \mathord in the first line? And which type is it?

KersouMan
  • 1,850
  • 3
  • 13
  • 15
Didier
  • 1,311

1 Answers1

9

enter image description here

! is \mathclose not \mathord alledgedly to improve the spacing in its conventional use as factorial. However the only case where this affects the space before the ! is with \mathinner (\left\right) where usually you can get the better spacing simply by not using \left\right as shown in the third line here. However the second line shows the spacing that you would get with \mathord, with an unwanted space before the !.

\documentclass{article}

\begin{document}

$ \left(1+2\right)! + 9! $

$ \left(1+2\right){!} + 9{!} $

$ (1+2){!} + 9{!} $

\end{document}

LaTeX defines ! by

\DeclareMathSymbol{!}{\mathclose}{operators}{"21}
David Carlisle
  • 757,742
  • Thank you David (and campa). Is there a command to know the type of an atom? – Didier Aug 24 '21 at 08:21
  • I sometimes wonder: Since all \mathinner really seems to do is distort the spacing, should we consider it a historical mistake in TeX, or are there any real benefits? – Gaussler Aug 24 '21 at 08:46
  • @Didier You can use \showthe\numexpr \mathcode\! / 4096\relax`. – frougon Aug 24 '21 at 08:50
  • @Gaussler I give a full list of all the "benefits" of \mathinner here https://tex.stackexchange.com/a/173740/1090 – David Carlisle Aug 24 '21 at 08:53
  • @DavidCarlisle And are any of those “benefits” actually benefits? If not, doesn’t that confirm my point? – Gaussler Aug 24 '21 at 08:54
  • Sorry there are no benefits at all. Unfortunately it's the only way to get stretch brackets – David Carlisle Aug 24 '21 at 08:55
  • @DavidCarlisle Exactly. This seems to be another example of a design choice made by Knuth that actually kinda ought to be changed (possibly by adding new primitives that are alternatives to \left...\right). – Gaussler Aug 24 '21 at 08:58
  • 1
    @Gaussler luatex – David Carlisle Aug 24 '21 at 09:01
  • 2
    @Gaussler It is certainly an historical mistake to call it ma thinner. Most women, especially mothers, don't want to hear of it. I certainly avoid discussing the issue of \mathinner with my wife. – Steven B. Segletes Aug 24 '21 at 09:24
  • @frougon It doesn’t do anything – Didier Aug 24 '21 at 15:51
  • @Didier \showthe will stop as if for an error and show the number. – David Carlisle Aug 24 '21 at 15:52
  • @Didier It does. You may replace \showthe with \the to obtain the result in the DVI or PDF output, but you'd be better off learning how to read TeX's messages. – frougon Aug 24 '21 at 16:04
  • @Didier Actually, because the division inside \numexpr rounds to the nearest integer (rather than truncates), one should use this instead: \showthe\numexpr (\mathcode\! -"800) / "1000\relax. Without this, the result would be (class number + 1) in case the family number in the\mathcode` were greater than or equal to 8. – frougon Aug 25 '21 at 10:34
  • Thank you frougon. – Didier Aug 26 '21 at 16:56
  • @frougon I guess I do it wrong because here is what I get in the log file:
    1. \relax

    l.4 ...e\numexpr (\mathcode! -"800) / "1000\relax`

    – Didier Aug 27 '21 at 06:27
  • @Didier 5 is correct: this is the class number corresponding to a Closing atom as produced by \mathclose—see the table p. 154 of the TeXbook, which is reproduced here. – frougon Aug 27 '21 at 07:34
  • @frougon Thanks. I didn’t understand what meant this 5. Now, I will know. Thank you again – Didier Aug 28 '21 at 05:32