10

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}

\begin{equation}
\frac{x^*}{2} \qquad \frac{x^*}{2\phantom{{}^*}}
\end{equation}

\end{document}

With the following output:

alignment issues

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?

5
  • 4
    The left hand side version is correct.
    – egreg
    Feb 28, 2013 at 14:47
  • @egreg: I still think it looks odd - perhaps even more so in inline fractions (i.e. $\frac{x^*}{2}$). Feb 28, 2013 at 14:51
  • 2
    I would definitely write $x^{*}/2$.
    – egreg
    Feb 28, 2013 at 15:00
  • 1
    @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? Feb 28, 2013 at 15:14
  • 1
    Strongly related Subscripts in partial derivatives. Feb 28, 2013 at 15:23

3 Answers 3

18
\begin{equation*}
\frac{x^*}{2} \quad \frac{x^*}{2\phantom{{}^*}} \quad
\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 third one is the best looking one:

Result

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}

enter image description here

2
  • Thanks, I did not know about \rlap :) Feb 28, 2013 at 15:00
  • 4
    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, 2013 at 15:04
10

How about using \mathrlap from the mathtools-package?

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

\begin{equation}
\frac{x^*}{2} \qquad \frac{x^*}{2\phantom{{}^*}} \qquad \frac{x^{\mathrlap{*}}}{2}
\end{equation}

\end{document}

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

1
3

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.

3
  • 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, 2013 at 17:24
  • 1
    TBH, I can't say I don't consider it nicer looking, I just have the bad readability experience.
    – yo'
    Feb 28, 2013 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. Feb 28, 2013 at 18:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .