1

I'm trying to put the following three equations into a matrix:

$$x_1 + 2x_2 = 7\\
-2x_1 + 5x_2 = 4\\
-5x_1 + 6x_2 = -3$$

When I use the following bmatrix:

$$\begin{bmatrix}1\;2\;7\\-2\;5\;4\\-5\;6\;-3\end{bmatrix}$$

the resulting matrix is a mess, with no real column separation. Is there a way to specify columns in math mode? I know about presetting column separation widths, but I would rather it be done automatically, rather than as a presetting.

2

In the LaTeX tabular and array environments, as well as in the matrix-like environments such as matrix, pmatrix, bmatrix, and vmatrix, the only widely recognized column separator character is &. If you replace all instances of \; with &, the resulting output will start to look much better.

To make the matrix at hand look really good, though, you may want to switch from using a bmatrix to a bmatrix* environment and impose right-alignment of the column contents. Plus, add a \phantom{-} directive to one of the cells in the middle column to balance the column widths.

enter image description here

\documentclass{article}
\usepackage{mathtools} % for 'bmatrix*' env.
\begin{document}
\[
\begin{bmatrix}1\;2\;7\\-2\;5\;4\\-5\;6\;-3\end{bmatrix}
\quad\text{vs.}\quad
\begin{bmatrix} 1&2&7\\-2&5&4\\-5&6&-3 \end{bmatrix}
\quad\text{vs.}\quad
\begin{bmatrix*}[r] 1&2&7\\-2&5&4\\-5&\phantom{-}6&-3 \end{bmatrix*}
\]
\end{document}
| improve this answer | |
2

have a look --- https://en.wikibooks.org/wiki/LaTeX/Mathematics#Matrices_and_arrays

enter image description here

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

\[
M=
  \begin{bmatrix}
    1 & 2 & 3  \\
    3 & 4 & 5  \\
    5 & 7 & -3
  \end{bmatrix}
\]

\end{document}

OR

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

\[
M=
  \begin{bmatrix*}[r]
    1 & 2 & 3  \\
    3 & 4 & 5  \\
    5 & 7 & -3
  \end{bmatrix*}
\]

\end{document}

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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