GeneralMathematical LaTeX issues...

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
EddArmitage
Posts: 4
Joined: Sat Mar 08, 2008 7:16 pm

Mathematical LaTeX issues...

Post by EddArmitage »

I'm new to using LaTeX and am having a few minor issues with mathematical formulae, specifically with negative numbers (using eg. $-7$) and not equals (ie. $\neq$). Am I using them incorrectly. Attached is my .tex file, but what I think is the important bit is below:

Code: Select all

\begin{eqnarray*}
\begin{vmatrix}
$-7$ & 1 & 0 \\
2 & $-1$ & 3 \\
4 & 1 & 6
\end{vmatrix}
&=&
$-7$\begin{vmatrix}
$-1$ & 3 \\
1 & 6
\end{vmatrix}
-1\begin{vmatrix}
2 & 3 \\
4 & 6
\end{vmatrix} \\
&=&($-7$ \times -9) - ($-1$ \times 0) \\
&=&63
&$\neq$&0
\end{eqnarray*}
It only appears to be the negative numbers outside of the matrices that are causing issues.

Many thanks in advance,

Edd
Attachments
Assignment3.tex
(521 Bytes) Downloaded 281 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
balf
Posts: 158
Joined: Sat Jan 12, 2008 1:11 am

Re: Mathematical LaTeX issues...

Post by balf »

I've seen two errors in your code that have nothing to do with negative numbers or \neq: here are the correct last three lines:
&=&63\\
&\neq&0
\end{eqnarray*}

Moreover, one shouldn't use eqnarray any more,as the horizontal spacing isn't too good, and I've heard it's more or less incompatible with amsmath. You should use the align* environment from amsmath. Here's a more correct (and simpler) code:
\begin{align*}
\begin{vmatrix}
$-7$ & 1 & 0 \\
2 & $-1$ & 3 \\
4 & 1 & 6
\end{vmatrix}
&=
-7\begin{vmatrix}
$-1$ & 3 \\
1 & 6
\end{vmatrix}
-1\begin{vmatrix}
2 & 3 \\
4 & 6
\end{vmatrix} \\
&=(-7 \times -9) - (-1 \times 0) \\
&=63\\
&\neq0
\end{align*}

I would recommend two guides: for maths typesetting in LaTeX: Herbert Voss's mathmode.pdf and Mark Trettin's l2tabu for obsolete commands and packages;here are links:
http://www.dante.de/CTAN/info/math/voss ... thmode.pdf
http://www.dante.de/CTAN/info/l2tabu/en ... tabuen.pdf
(there are also french, german, italian and spanish versions of this one)

B.A.
EddArmitage
Posts: 4
Joined: Sat Mar 08, 2008 7:16 pm

Re: Mathematical LaTeX issues...

Post by EddArmitage »

Thanks for that, it's fixed the problem with the not-equals, but I still can't get negative numbers outside of a matrix using the $-2$ type notation. Using -2 format i get nasty look subtraction operators that are incorrectly spaced.

Edd
balf
Posts: 158
Joined: Sat Jan 12, 2008 1:11 am

Re: Mathematical LaTeX issues...

Post by balf »

I don't understand why you want to write $-2$ inside a matrix environment: all you do is locally leaving math mode for text mode, so that the minus sign becomes a hyphen. If you want the digits vertically aligned, the mathtools package (an amsmath extension) defines a vmatrix* environment, which takes an optional argument l, r or c (the default in amsmath's vmatrix). In case you use mathtools, it's useless to load amsmath.

B.A.
EddArmitage
Posts: 4
Joined: Sat Mar 08, 2008 7:16 pm

Mathematical LaTeX issues...

Post by EddArmitage »

Having seen here about the differences between various uses of hyphens, I thought that was the correct way to input negative numbers.

Edd
balf
Posts: 158
Joined: Sat Jan 12, 2008 1:11 am

Re: Mathematical LaTeX issues...

Post by balf »

I think the $-$ in the examples just meant that you must be in math mode. If you're already so, typing $ makes you leave math mode and the second $ back to it.

B.A.
EddArmitage
Posts: 4
Joined: Sat Mar 08, 2008 7:16 pm

Re: Mathematical LaTeX issues...

Post by EddArmitage »

That was my understanding of what the $ character does, but when they're not used the output looks wrong (see my attached example, line 3 - it's supposed to be a sum of products - and compare it to the negative numbers inside of the matrices). Have you any idea how I can get nice negative numbers like those inside the matrices, but outside of the matrix environment?

Many thanks for your continued help

Edd
Attachments
Q2.tex
A basic example
(926 Bytes) Downloaded 233 times
Q2.pdf
A PDF of the basic example
(8.43 KiB) Downloaded 317 times
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

Re: Mathematical LaTeX issues...

Post by Juanjo »

I've corrected your tex file, that I attach here. Take a close look.
Attachments
Q2.pdf
(24.4 KiB) Downloaded 279 times
Q2.tex
(1.77 KiB) Downloaded 311 times
balf
Posts: 158
Joined: Sat Jan 12, 2008 1:11 am

Re: Mathematical LaTeX issues...

Post by balf »

To EddArmitage: I don't understand very well; the negative numbers inside the matrices aren't nice at all: they're preceded by a hyphen, not a minus sign. The examples given by JuanJo are OK : they're normal mathemetical typography.

B.A.
Post Reply