Within the mathtools
package, \cramped
is defined as follows.
\providecommand*\cramped[1][\@empty]{
\ifx\@empty#1\@empty
\expandafter \mathpalette \expandafter \MT_cramped_internal:Nn
\else
\expandafter \MT_cramped_internal:Nn \expandafter #1
\fi
}
\def\MT_cramped_internal:Nn #1#2{
\sbox\z@{$\m@th#1\nulldelimiterspace=\z@\radical\z@{#2}$}
\ifx#1\displaystyle
\dimen@=\fontdimen8\textfont3
\advance\dimen@ .25\fontdimen5\textfont2
\else
\dimen@=1.25\fontdimen8
\ifx#1\textstyle\textfont
\else
\ifx#1\scriptstyle
\scriptfont
\else
\scriptscriptfont
\fi
\fi
3
\fi
\advance\dimen@-\ht\z@ \ht\z@=-\dimen@
\box\z@
}
Q1 After reading Appendix G of The TeXbook (Rule 18), why wouldn't the package simply do the following (locally within the math environment)?
\fontdimen13\textfont2=\fontdimen15\textfont2
\fontdimen14\textfont2=\fontdimen15\textfont2
\fontdimen13\scriptfont2=\fontdimen15\scriptfont2
\fontdimen14\scriptfont2=\fontdimen15\scriptfont2
\fontdimen13\scriptscriptfont2=\fontdimen15\scriptscriptfont2
\fontdimen14\scriptscriptfont2=\fontdimen15\scriptscriptfont2
Q2 I omit here the code to make it local because I'm not sure how to do it but surely it's doable(?) Does anyone know how to do it locally?
\fontdimen
assignments are always global.