2

I have an equation for which I would like the sign to be aligned with the numerator without being a part of it. As a rough example,

\[ - \frac{\sqrt{3q\times r^2}}{y \times z} \]

produces

fraction with minus sign aligned with middle of fraction

but I would prefer

fraction with minus sign aligned with numerator


Rationale: While, in the example above, the default layout is actually better, in my actual document the relevant fraction is coming after a new line and the minus sign is easy to miss. Moving it up to the level of the numerator would make it more conspicuous.

7
  • 2
    \frac{-\sqrt{3q\times r^2}}{y \times z} is more mathematically true.
    – user156344
    Feb 18, 2019 at 10:39
  • @JouleV Absolutely! Unfortunately, my example above is meant to be indicative of my problem without containing too much unecessary clutter, and (while a good representation of the question I'm asking) is maybe not a good representation of my actual maths.
    – owjburnham
    Feb 18, 2019 at 10:42
  • 2
    @JouleV more mathematically true? What does that mean?
    – JPi
    Feb 18, 2019 at 13:12
  • @JPi I meant that it is true and the OP's is false. But as the OP wants to have the wrong one, I said "more mathematically true".
    – user156344
    Feb 18, 2019 at 13:22
  • @JouleV I agree with you in the example I gave. For what it’s worth, my imagined use case was (very roughly) a/b - x/y. In that case, I’d imagine that a/b -x/y (with the sign as part of the numerator) might risk looking like a/b times -x/y. I don’t know whether, in that case, you would agree?
    – owjburnham
    Feb 18, 2019 at 13:33

1 Answer 1

9

I disagree with your rationale.

Anyway, the customer's always right. ;-)

Load mathtools and do

\hphantom{-}\frac{\mathmakebox[0pt][r]{-}\sqrt{3q\times r^2}}{y\times z}

enter image description here

There is a shorthand for \mathmakebox[0pt][r]{...}, namely \mathllap{...}.

4
  • 2
    thanks for help me to know about the tag \mathmakebox...
    – MadyYuvi
    Feb 18, 2019 at 11:03
  • Following JouleV's comment ( tex.stackexchange.com/questions/475470/… ), I also began to disagree with my own rationale (in the particular case in which I was asking the question). But I figured that the question was worth letting stand for future benefit ;-) Thanks for the solution.
    – owjburnham
    Feb 18, 2019 at 11:04
  • 2
    simpler code: \mathllap{-} instead of \mathmakebox
    – daleif
    Feb 18, 2019 at 14:30
  • @barbarabeeton the only thing I'm replacing in egregs code is \mathmakebox[0pt]{r}{-} the rest is the same including the hphantom.
    – daleif
    Feb 18, 2019 at 16:23

You must log in to answer this question.

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