23

This is a weird phenomenon.

Consider the following code:

\documentclass{article}
\begin{document}
  $$Z^* \frac{Z^*}{Z^*}$$
\end{document}

It produces the following picture:

enter image description here

The asterisks appear in various places in comparison to the Z. This looks particularly bad in the denominator. Any idea what's behind this?

  • 2
    Unrelated but you should use \[ ... \] instead of $$ ... $$. There are several threads covering the reason. – Guilherme Zanotelli Nov 3 '16 at 13:31
  • 2
    the denominator use a "cramped" style to avoid spreading things out too much (this is built in to tex the program although the exact amount superscripts are raised in normal and cramped styles are in settable fontdimen parameters) – David Carlisle Nov 3 '16 at 13:31
25

There's nothing weird about the placement of the three superscript asterisks. They are placed at different heights because they occur in three distinct math styles. (Aside: TeX has 8 possible math styles. See p. 140f. in the TeXbook for more information about these 8 styles.)

  • in the first term, TeX is in (uncramped) display style, labelled D in the TeXbook;

  • in the numerator term, TeX is in (un-cramped) text style, labelled T in the TeXbook; and

  • in the denominator term, TeX is in cramped text style, labelled T' in the TeXbook.

I assume you like the first look the best. If that's the case, you could write

\[ Z^* \frac{\displaystyle Z^*}{\displaystyle Z^*} \]

to force all three Z^* terms to have the same look.

Alternatively, you could set up a macro named, say, \ddfrac, as follows:

\newcommand\ddfrac[2]{\frac{\displaystyle #1}{\displaystyle #2}}

and then write

\[ Z^* \ddfrac{Z^*}{Z^*} \]

in the body of the text.

A small MWE: the item on the left shows the result of your original code, and the item on the right shows the output when using the \ddfrac macro:

enter image description here

\documentclass{article}
\newcommand\ddfrac[2]{\frac{\displaystyle #1}{\displaystyle #2}}
\begin{document}
$\displaystyle 
Z^*\frac{Z^*}{Z^*} \quad Z^*\ddfrac{Z^*}{Z^*}$
\end{document}

Addendum, inspired by David Carlisle's comment: pdfLaTeX provides four directives related to math style: \displaystyle, \textstyle, \scriptstyle, and \scriptscriptstyle. (The code above uses only one of these directives -- \displaystyle.) If you happen to use LuaLaTeX, you could employ four additional style-related directives: \crampeddisplaystyle, \crampedtextstyle, \crampedscriptstyle, and \crampedscriptscriptstyle. E.g., if you wanted to impose the "cramped text style look" on the numerator term of \frac, you could define a new macro as follows -- "ct" stands for "cramped text style":

\newcommand\ctfrac[2]{\frac{\crampedtextstyle #1}{\crampedtextstyle #2}}

Second Addendum, prompted by @daleif's comment: The mathtools package provides a directive called \cramped, which typesets its argument in the cramped version of the applicable uncramped math style. Using the mathtools package, then, one would write the preceding \ctfrac macro as follows:

\newcommand\ctfrac[2]{\frac{\cramped[\textstyle]{#1}}{\cramped[\textstyle]{#2}}}
  • 3
    nice answer, for completeness you could mention that luatex has \crampeddisplaystyle\crampedtextstyle\crampedscriptstyle\crampedscriptscriptstyle should you really need to force one of the cramped styles. – David Carlisle Nov 3 '16 at 13:45
  • @DavidCarlisle - Thanks for this suggestion; I've provided an addendum to flesh out what might be done with \crampedtextstyle, etc. – Mico Nov 3 '16 at 13:58
  • 4
    mathtools also have some cramped support – daleif Nov 3 '16 at 13:59
  • 3
    @daleif - Thanks for this suggestion; I've provided a second addendum to show how \cramped might be used in the definition of \ctfrac. – Mico Nov 3 '16 at 14:08
11

If a fraction appears when display style is in force, the numerator will use text style and the denominator will use “cramped” text style; similarly, the numerator and the denominator will be one style level below the starting one, with the denominator in the “cramped” variety.

The cramped variety of a math style uses less high superscript than the uncramped one, in order they don't clash with the fraction line or the vinculum in radicals (also using the cramped variety).

You can define a \ufrac command (uncramped fraction):

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\newcommand{\ufrac}[2]{% uncramped fraction
 \frac{#1}{\mathpalette\ufrac@den{#2}}%
}
\newcommand{\ufrac@den}[2]{#1#2}
\makeatother

\begin{document}

\[
Z^* \frac{Z^*}{Z^*}
\quad
Z^* \ufrac{Z^*}{Z^*}
\]
\[
\textstyle
Z^* \frac{Z^*}{Z^*}
\quad
Z^* \ufrac{Z^*}{Z^*}
\]

\end{document}

enter image description here

I'd avoid forcing display style. In case you'd like to, here's a way

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\newcommand{\ufrac}[2]{% uncramped fraction
 \frac{\mathpalette\ufrac@style{#1}}
      {\mathpalette\ufrac@style{#2}}%
}
\newcommand{\ufrac@style}[2]{%
  \ifx\textstyle#1\displaystyle\else#1\fi#2%
}
\makeatother

\begin{document}

\[
Z^* \frac{Z^*}{Z^*}
\quad
Z^* \ufrac{Z^*}{Z^*}
\]
\[
\textstyle
Z^* \frac{Z^*}{Z^*}
\quad
Z^* \ufrac{Z^*}{Z^*}
\]

\end{document}

enter image description here

  • While I can certainly appreciate the recommendation to avoid forcing the \displaystyle, this result, like barbara's, does not set all three asterisks uniformly. – Steven B. Segletes Nov 3 '16 at 13:54
  • @StevenB.Segletes I don't think it matters. – egreg Nov 3 '16 at 13:58
  • I agree that it wouldn't bother me, but it seems it bothered the OP. – Steven B. Segletes Nov 3 '16 at 14:05
  • @StevenB.Segletes I provided the solution also for the case. – egreg Nov 3 '16 at 14:13
4

david carlisle's comment gives the reason. here's a way to "fix" it:

\documentclass{article}
\begin{document}
  \[Z^* \frac{Z^*}{Z_{\mathstrut}^*}\]
\end{document}

enter image description here

  • 1
    Even that doesn't quite "fix" it. (The non-fractioned asterisk rises above the top of the Z, whereas the other asterisks align to the top of the Z) – Steven B. Segletes Nov 3 '16 at 13:34
  • @StevenB.Segletes that isn't really the main issue but the numerator and denominator still have different settings, the denominator is set still in cramped style but slightly higher because of the strut, any similarity to the uncramped setting in the numerator is accidental (and font dependent). – David Carlisle Nov 3 '16 at 16:34

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.