# Superscripts appear in various weird places in fractions

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:

\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}}}

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$email protected]{#2}}% } \newcommand{\[email protected]}[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}

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$email protected]{#1}} {\mathpalette\[email protected]{#2}}% } \newcommand{\[email protected]}[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}

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}