7

What should I do to get all the 1 with a minus sign (-) in front of them aligned with the other 1 and the 0 in those vectors?

\documentclass[a4paper, 12pt]{book}
\usepackage{amsmath}
\begin{document}
$$
v_1 = \begin{bmatrix} 1 \\ -1 \\ 0 \\0 \end{bmatrix}, \quad
v_2 = \begin{bmatrix} 1 \\ 0 \\ -1 \\0 \end{bmatrix}, \quad
v_3 = \begin{bmatrix} 1 \\ 0 \\ 0 \\-1 \end{bmatrix},
$$
\end{document}

vectors

ecjb
  • 883
  • You could do \documentclass[a4paper, 12pt]{book} \usepackage{amsmath} \begin{document} \[ v_1 = \left[\begin{array}{@{}r@{}} 1 \\ -1 \\ 0 \\0 \end{array}\right], \quad v_2 = \left[\begin{array}{@{}r@{}} 1 \\ 0 \\ -1 \\0 \end{array}\right], \quad v_3 = \left[\begin{array}{@{}r@{}} 1 \\ 0 \\ 0 \\-1 \end{array}\right], \] \end{document} but please use \[ ... \] instead of `$$ ... $$'. –  Feb 27 '19 at 21:01

1 Answers1

10

As you've discovered, the bmatrix environment centers the cell contents. To achieve right-alignment, you may want to load the mathtools package (a superset of the amsmath package) and use a bmatrix* environment with optional argument r.

enter image description here

\documentclass[a4paper, 12pt]{book}
\usepackage{mathtools}
\begin{document}
\[
v_1 = \begin{bmatrix} 1 \\ -1 \\ 0 \\0 \end{bmatrix}, \quad
v_2 = \begin{bmatrix} 1 \\ 0 \\ -1 \\0 \end{bmatrix}, \quad
v_3 = \begin{bmatrix} 1 \\ 0 \\ 0 \\-1 \end{bmatrix}.
\]

\[
v_1 = \begin{bmatrix*}[r] 1 \\ -1 \\ 0 \\0 \end{bmatrix*}, \quad
v_2 = \begin{bmatrix*}[r] 1 \\ 0 \\ -1 \\0 \end{bmatrix*}, \quad
v_3 = \begin{bmatrix*}[r] 1 \\ 0 \\ 0 \\-1 \end{bmatrix*}.
\]
\end{document}
Mico
  • 506,678