# How to change horizontal alignment of \frac?

Typing \frac{W+W^*}{2} gives a fraction in which the denominator appears to the eye to be in the wrong position. Is there a way to correct this, i.e. place the 2 in under the + (without using arbitrary negative spacing)?

-
Are you using inline-mode or display-mode? –  Johannes_B Dec 18 '13 at 8:38
Welcome to TeX.SX! –  Claudio Fiandrino Dec 18 '13 at 8:54

I propose five possibilities:

\documentclass{article}
\usepackage{mathtools}
\begin{document}
$% no adjustment \frac{W+W^{*}}{2}= % push the denominator left by the width of the asterisk \frac{W+W^{*}}{2\hphantom{^{*}}}= % make the asterisk protrude to the right (and add a correction) \frac{W+W^{\mathrlap{*}}}{2}\,= % push the denominator a bit left \frac{W+W^{*}}{\!2}= % change the order \frac{W^{*}+W}{2}$
\end{document}


Probably the middle one is the best, in this particular case.

-

Use \hphantom:

\documentclass{article}
\begin{document}
$\frac{W+W^*}{2\hphantom{^{*}}}$
\end{document}


The idea is to exploit the fact that ^{*} is the extra parameter in W + W. Adding a horizontal space of extra ^{*} to the denominator (after 2) does the work to bring 2 to the centre of W + W

-
Shouldn't it be \hphantom{^{*}}? –  egreg Dec 18 '13 at 8:44
I got a different answer in another latex group: use \frac{W+W^{\rlap{$\scriptscriptstyle*$}}{2} with the slight advantage that the horizontal line only reaches until the second W. But your answer is more elegant. –  Chrystomath Dec 18 '13 at 9:01