# Nicer alignment of x^*/2

I'm trying to typeset $\frac{x^*}{2}$, but I can't find a (simple) way to make the alignment look nice. So far, I've tried the following:

\documentclass{article}
\begin{document}

$$\frac{x^*}{2} \qquad \frac{x^*}{2\phantom{{}^*}}$$

\end{document}


With the following output:

In the left one, it looks odd because the x is very off-center, and in the right example the fraction bar is extended way more to the right than what's really necessary.

Is there a nicer (and still simple enough) way to typeset this fraction?

-
The left hand side version is correct. – egreg Feb 28 '13 at 14:47
@egreg: I still think it looks odd - perhaps even more so in inline fractions (i.e. $\frac{x^*}{2}$). – Tomas Lycken Feb 28 '13 at 14:51
I would definitely write $x^{*}/2$. – egreg Feb 28 '13 at 15:00
@HendrikVogt: I think your link is broken (at least it points to a topic that's not even vaguely related...). Would you mind double-checking? – Tomas Lycken Feb 28 '13 at 15:14
Strongly related Subscripts in partial derivatives. – Hendrik Vogt Feb 28 '13 at 15:23

\begin{equation*}
\frac{x\rlap{$^*$}}{\,2\,}
\end{equation*}


The correct one is the first one, as the ugly syntax of the other two demonstrates :-) However, I have to admit that the latter is the best looking one:

# Update

As egreg noted in a comment, the problem with the third solution is that it is not clear if the * applies only to x, or to the whole fraction. Thiking about this, I've found another solution which avoids this problem, has a cleaner syntax, and still (imho) looks better than the first one.

The following MWE shows first the standard way, second my first attempt, and third my new proposed solution. I put them in the context of a bigger expression, and aligned them vertically at the right bar, for easier comparison:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
\Big|\frac{x^*}{2}               \Big|&=y \\
\Big|\frac{x\rlap{$^*$}}{\,2\,}  \Big|&=y \\
\Big|\frac{x^*\!}{2}             \Big|&=y
\end{align*}
\end{document}


-
Thanks, I did not know about \rlap :) – ralfix Feb 28 '13 at 15:00
Did you try adding a symbol after \frac{x\rlap{$^*$}}{\,2\,}? It will be pushed below the asterisk. I'm still convinced that \frac{x^*}{2} is the best: with your \rlap (by the way \mathrlap from mathtools should be used) it's ambiguous whether the asterisk applies to x or to the whole fraction. – egreg Feb 28 '13 at 15:04
+1 for the \! proposal! – Hendrik Vogt Feb 28 '13 at 19:55

How about using \mathrlap from the mathtools-package?

\documentclass{article}
\usepackage{mathtools}
\begin{document}

$$\frac{x^*}{2} \qquad \frac{x^*}{2\phantom{{}^*}} \qquad \frac{x^{\mathrlap{*}}}{2}$$

\end{document}


This inserts the asterisk without adding additional space and thus keeping the fraction line as long as in the first example:

-
The \mathrlap suggestion has the same drawback as egreg explains in his comment to JLDiaz' answer. – Hendrik Vogt Feb 28 '13 at 19:57

Aligning things that should not be aligned is a bad idea. Very similar example to yours is adding \phantom{-} in front of 0 and 1 in matricis comprising only 0, 1 and -1. You align the numbers, but you lose the visual distinction between 1 and -1.

Here, it is a bit different but still valid: I, as a reader, would really get the impression that there's a missing symbol after 2, just because the whole denominator is not centered, whereas I expect it to be centered.

Conclusion: Two options are correct: \frac{x^*}{2} and x^*/2.

-
Today, we are fated to disagree about phantom minus signs :) I right-align all my matrices by default, specifically for this purpose. – Ryan Reich Feb 28 '13 at 17:24
TBH, I can't say I don't consider it nicer looking, I just have the bad readability experience. – yo' Feb 28 '13 at 17:33
@RyanReich -- matrices aren't fractions. for matrices, aligning so that the numerical value of comparable elements is parallel is appropriate, and there, the phantom minus sign or right-alignment (in the absence of non-matching decimal places) is the proper thing to do. likewise for tabular material. – barbara beeton Feb 28 '13 at 18:48