Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[LaTeX] How to force a unary minus sign?

2,357 views
Skip to first unread message

Kelvin Lim

unread,
Feb 17, 2003, 10:18:35 PM2/17/03
to
Hi,

I'm pretty new to LaTeX, so my sincere apologies if this is a trivial
question. I was trying to format the solution to a quadratic equation,
and ran into a bit of a minor formatting hitch. Here's the (reduced)
LaTeX code, using the align* environment from amsmath:

\begin{align*}
p &= \frac{-1 \pm \sqrt{(1)^2-4(1)(-0.084)}}{2(1)}\\
&= 0.168 \text{ or } -1.168\\
\end{align*}

Notice that on the second line of the equation array, what I'm trying to
do is to get the text "0.168 or -1.168". What actually happens,
however, is that the minus sign beside 1.168 seems to be interpreted as
the binary subtraction operator instead of the unary negation operation,
so my output looks more like "0.168 or - 1.168".

After some experimentation, I managed to figure out that I could correct
this by using

\begin{align*}
p &= \frac{-1 \pm \sqrt{(1)^2-4(1)(-0.084)}}{2(1)}\\
&= 0.168 \text{ or $-1.168$}\\
\end{align*}

but this quick-fix seems like a kludge, at best. Is there a better way
of telling LaTeX to use a unary minus instead of a binary minus sign?

Thanks!


kelvin lim

Allin Cottrell

unread,
Feb 17, 2003, 10:59:55 PM2/17/03
to

Not exactly an answer to your question, but

& = \pm 0.168 \\

would do.

Allin Cottrell

Mogens Lemvig Hansen

unread,
Feb 18, 2003, 12:32:18 AM2/18/03
to
I would do

&= \text($0.168$ or $-1.168$}

because the two cases belong together and therefor "should" be in one
box

or

&= 0.168 \quad\text{or}\quad -1.168

As fas as I remember, one can force a unary minus by enclosing things in
a group:

{-1.168}

Then TeX sees "nothing followed by - followed by something", so unary
minus. In your case, "\text{...} - 1.168" becomes the difference
between the text box and 1.168, so binary minus.

I didn't test either example.

Regards,
Mogens

Heiko Oberdiek

unread,
Feb 17, 2003, 11:05:00 PM2/17/03
to
"Kelvin Lim" <kelv...@cmu.edu> wrote:

> &= 0.168 \text{ or $-1.168$}\\
>

> but this quick-fix seems like a kludge, at best. Is there a better way
> of telling LaTeX to use a unary minus instead of a binary minus sign?

{-}1.168 or \mathord-1.168

In math mode braces surround a subformula that is set as "math ord".
So you can get rid of the "math bin" class.

Yours sincerely
Heiko <ober...@uni-freiburg.de>

Danie Els

unread,
Feb 18, 2003, 8:51:24 AM2/18/03
to

Kelvin Lim wrote:

Put the minus in brackets: {-} or \mathord{-}


If you do not want to use the previous sugestion of \pm, then add some
extra space (which will also change the minus for mathop to mathord).

&= 0.168\quad\text{or}\quad -1.168\\

--

Danie Els
(Substitude initials DNJ for first name in e-address)

Danie Els

unread,
Feb 18, 2003, 8:55:10 AM2/18/03
to

Danie Els wrote:

OOps, no it don't

&= 0.168\quad\text{or}\quad{-}1.168\\

Dan Luecking

unread,
Feb 18, 2003, 4:47:09 PM2/18/03
to
On Mon, 17 Feb 2003 22:59:55 -0500, Allin Cottrell <cott...@wfu.edu>
wrote:

>>
>> \begin{align*}
>> p &= \frac{-1 \pm \sqrt{(1)^2-4(1)(-0.084)}}{2(1)}\\
>> &= 0.168 \text{ or $-1.168$}\\
>> \end{align*}
>>
>> but this quick-fix seems like a kludge, at best. Is there a better way
>> of telling LaTeX to use a unary minus instead of a binary minus sign?
>
>Not exactly an answer to your question, but
>
>& = \pm 0.168 \\
>
>would do.
>

Except that -0.168 is a whole lot different than -1.168.
However, -0.5 \pm 0.668 would work.


Dan

--
Dan Luecking Department of Mathematical Sciences
University of Arkansas Fayetteville, Arkansas 72701

0 new messages