Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

When I include a matrix in an equation, the first part of the equation is separated off to the left of the page, while the matrix is spaced away in its own centred area on its own line. Here is what I am currently doing:

\[
$M^{-T} = \frac{1}{|det(M)|}$  \begin{bmatrix}
a_{22} & - a_{21} \\
-a_{12} & a_{11} 
\end{bmatrix}
\]

What is the correct approach for this?

share|improve this question
2  
Welcome to TeX.SX! Remove those $ symbols: you're getting an error message for that. –  egreg Feb 14 '12 at 20:31
    
Should it be M^{-T} or M^{-1} on the LHS of the equation? –  Mico Feb 14 '12 at 21:31
add comment

1 Answer 1

up vote 9 down vote accepted

The notation \[ and \] puts TeX in (display) math mode, meaning you don't have to enter math mode again using $ ... $. In fact, this causes an error. Barring that, the alignment should be fine:

enter image description here

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\begin{document}
\[
  M^{-T} = \frac{1}{|\det(M)|}
    \begin{bmatrix}
      \phantom{-}a_{22} & -a_{21} \\
      -a_{12} & \phantom{-}a_{11} 
    \end{bmatrix}
\]
\end{document}​

In the above example I've played around with some parameters:

  • Right-aligned all the entries in the bmatrix (using \phantom) so positive and negative scalar quantities line up. This may be personal preference.
  • amsmath provides \text which sets its argument in the correct font size (although it doesn't matter in your specific case) in text mode. You'll notice a difference in the spacing between det and \text{det} in math mode. Moreover, in math mode, det is intepreted as d multiplied by e, multiplied by t, which is not correct. LaTeX also provides \det natively for this, defined as a math operator (and therefore has a marginally different spacing, but better in general).
share|improve this answer
3  
The \text lesson is a good one, but amsmath also provides \det directly. –  Ryan Reich Feb 14 '12 at 20:40
    
@RyanReich: Thanks! Forgot about that. –  Werner Feb 14 '12 at 20:43
6  
@Werner In any case \operatorname should be used, not \text, if the operator is not predefined. Of course you can predefine it with \DeclareMathOperator. –  egreg Feb 14 '12 at 20:48
    
@egreg: Speaking of which: am I the only one who sets a shorthand \on = \operatorname and just doesn't bother with \DeclareMathOperator at all? –  Ryan Reich Feb 14 '12 at 20:58
    
@RyanReich When an operator is used several times, I find it clearer to define a command. For a couple of applications, \operatorname is not a problem. That's me, of course. –  egreg Feb 14 '12 at 21:20
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.