8

Some time ago Taco Hoekwater proposed an approach for getting a cramped style for math expressions.

\newdimen\savedrulethickness

\def\docramped#1#2{
    \savedrulethickness=\fontdimen8\textfont3
    \hbox{$\fontdimen8\textfont3=0pt#1\overline{#2}$}
    \fontdimen8\textfont3\savedrulethickness
}

\def\cramped{\mathpalette\docramped}

It works nice

$$
x' \cramped{a'}
$$

so that prime in a' is positioned slightly lower then in the regular case x'. However there is one bug here. The macros does not work for a \scriptscriptstyle:

$$
\scriptscriptstyle
x' \cramped{a'}
$$

An excessive bar is displayed over symbols (\textstyle is processed well). I find the code to be useful so I wonder could someone to fix the bug and explain me what the first #1 and second #2 arguments in \docramped do? Their meaning? Also, I would not like to use some external packages for these purposes because the code above is elegant and very simple. Thanks beforehand.

1 Answer 1

7

With mathtools there is a \cramped macro that uses a different method (with a ‘phantom radical‘). The result is pretty similar to Taco's, without any reassignment of \fontdimen.

I'll use Plain TeX for showing the two methods side by side; left is the mathtools method.

\def\cramped#1{%
  \kern-\nulldelimiterspace\radical0{#1}
}

\newdimen\savedrulethickness
\def\docramped#1#2{
    \savedrulethickness=\fontdimen8\textfont3
    \hbox{$\fontdimen8\textfont3=0pt#1\overline{#2}$}
    \fontdimen8\textfont3\savedrulethickness
}
\def\tacocramped{\mathpalette\docramped}

\noindent\vbox{\hsize=.1\hsize
$$
\eqalign{
x'x'\cr
x'\cramped{x'}\cr
\scriptscriptstyle
x'x'\cr
\scriptscriptstyle
x' \cramped{x'}
}
$$
}%
\vbox{\hsize=.1\hsize
$$
\eqalign{
x'x'\cr
x'\tacocramped{x'}\cr
\scriptscriptstyle
x'x'\cr
\scriptscriptstyle
x' \tacocramped{x'}
}
$$
}
\bye

enter image description here

The prime appears to be bigger than wanted for a very simple reason:

  1. in display style the prime is in subscript style
  2. in test style the prime is in subscript style
  3. in subscript style the prime is in subsubscript style
  4. in subsubscript style the prime is in subsubscript style

If you really need primes in subsubscript style, then you can redefine \prime; this code depends on \text, so it's necessary to go LaTeX:

\documentclass{article}
\usepackage{amsmath}

\AtBeginDocument{%
  \edef\primecode{\mathchar\number\prime\space}%
  \def\prime{{\text{$\primecode$}}}%
}

\begin{document}
$f^{\primecode\primecode}$

$f''$

$f'\scriptstyle f'\scriptscriptstyle f'$
\end{document}

enter image description here

1
  • 1
    To egreg. Your solution with radical \def\cramped#1{% \kern-\nulldelimiterspace\radical0{#1} } is so beautiful so I cannot imagine what's reason to use or implemented any other one.
    – user40791
    Nov 19, 2013 at 13:21

You must log in to answer this question.