2

I am having a problem properly aligning these vmatrices vertically. My output currently looks like:

enter image description here

Can you help me properly align these matrices? Thanks.

Here is my code:

\documentclass[11pt]{article}
\usepackage{booktabs}
\usepackage[table,x11names,dvipsnames,table]{xcolor}
\usepackage{blkarray}
\usepackage{colortbl}
\usepackage{multicol}
\usepackage{mathtools}

\begin{document}

\begin{align*}
b_{0} & = \begin{vmatrix}
         0.01822 & 1 \\
         1 & 0.01822
       \end{vmatrix} & = -0.9997, &\quad
b_{1} & = \begin{vmatrix}
         0.01822 & -0.25 \\
         1 & -0.0891
       \end{vmatrix} & = 0.2484, &\quad
b_{2} & = \begin{vmatrix}
         0.01822 & 0 \\
         1 & 0.5265
       \end{vmatrix} & = 0.0096, &\\[3pt]
b_{3} & = \begin{vmatrix}
         0.01822 & -0.825 \\
         1 & -0.825
       \end{vmatrix} & = 0.8100, &\quad
b_{4} & = \begin{vmatrix}
         0.01822 & 0.5265 \\
         1 & 0
       \end{vmatrix} & = -0.5265, &\quad
b_{5} & = \begin{vmatrix}
         0.01822 & -0.0891 \\
         1 & -0.25
       \end{vmatrix} & = 0.0842 &
\end{align*}

\end{document} 

2 Answers 2

3

I take it that you would like to align all numbers vertically, including the ones inside the various matrices. If that's the case, the following solution may be of interest to you.

enter image description here

\documentclass[11pt]{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{amsmath,siunitx,mleftright,booktabs}
\sisetup{table-format=1.5,group-digits=false} 
\newenvironment{mymat}[1]{%
  \mleft\vert \begin{array}{@{}#1@{}}}{%
  \end{array} \mright\vert}

\begin{document}
\setlength\arraycolsep{3pt}

\begin{align*}
 b_{0} &= \begin{mymat}{S S[table-format=-1.5]}
         0.01822 & 1 \\
         1 & 0.01822
       \end{mymat} = -0.9997, 
&b_{1} &= \begin{mymat}{S S[table-format=-1.4]}
         0.01822 & -0.25 \\
         1 & -0.0891
       \end{mymat} = \phantom{-}0.2484, 
&b_{2} &= \begin{mymat}{S S[table-format=-1.4]}
         0.01822 & 0 \\
         1 & 0.5265
       \end{mymat} = 0.0096,\\ 
\addlinespace
 b_{3} &= \begin{mymat}{S S[table-format=-1.5]}
         0.01822 & -0.825 \\
         1 & -0.825
       \end{mymat} = \phantom{-}0.8100, 
&b_{4} &= \begin{mymat}{S S[table-format=-1.4]}
         0.01822 & 0.5265 \\
         1 & 0
       \end{mymat} = -0.5265, 
&b_{5} &= \begin{mymat}{S S[table-format=-1.4]}
         0.01822 & -0.0891 \\
         1 & -0.25
       \end{mymat} = 0.0842 .
\end{align*}

\end{document} 
4
  • I just realized a problem. When I tried your approach, and there is a - sign in the first element of the matrix, the - sign goes outside of the | |. Is there a way to fix this?
    – Joe
    Commented Jun 2, 2017 at 6:01
  • @Joe - I'm not sure I understand the issue. Is there something stopping you from placing a - symbol ahead of \begin{mymat}?
    – Mico
    Commented Jun 2, 2017 at 6:10
  • no, for example, if the matrix is c_{0} & = \begin{mymat}{S S[table-format=-1.5]} -0.9997 & 0.0842 \\ 0.0842 & -0.9997 \end{mymat} & = \phantom{-}0.9922, &, the - sign falls outside of the matrix lines. Thanks.
    – Joe
    Commented Jun 2, 2017 at 6:20
  • 1
    For such a matrix, you need to change the argument of mymat from S S[table-format=-1.5] to S[table-format=-1.4] S[table-format=-1.4]. "-1.4" means: "LaTeX, please set aside enough horizontal space for a - symbol, 1 digit before the decimal marker, and 4 digits after the decimal marker."
    – Mico
    Commented Jun 2, 2017 at 6:32
1

Like this?

enter image description here

Ampersands had to be properly distributed: one in equation, one between equation:

\documentclass[11pt]{article}
\usepackage[margin=20mm]{geometry}   % <-- added
\usepackage{booktabs}
\usepackage[table,x11names,dvipsnames,table]{xcolor}
\usepackage{blkarray}
\usepackage{colortbl}
\usepackage{multicol}
\usepackage{mathtools}

\begin{document}
    \begin{align*}
b_{0} & = \begin{vmatrix}
         0.01822 & 1 \\
         1 & 0.01822
       \end{vmatrix} = -0.9997, &
b_{1} & = \begin{vmatrix}
         0.01822 & -0.25 \\
         1 & -0.0891
       \end{vmatrix} = 0.2484,  &
b_{2} & = \begin{vmatrix}
         0.01822 & 0 \\
         1 & 0.5265
       \end{vmatrix} = 0.0096, \\[3pt]
b_{3} & = \begin{vmatrix}
         0.01822 & -0.825 \\
         1 & -0.825
       \end{vmatrix} = 0.8100, &
b_{4} & = \begin{vmatrix}
         0.01822 & 0.5265 \\
         1 & 0
       \end{vmatrix} = -0.5265, &
b_{5} & = \begin{vmatrix}
         0.01822 & -0.0891 \\
         1 & -0.25
       \end{vmatrix} = 0.0842 
    \end{align*}
\end{document}

Note: your equation is very long and can't be placed in text width even if you defined page margins to 20mm (now are spilled out on the right side).

3
  • is it possible to line them up around the = sign? Thanks!
    – Joe
    Commented Jun 2, 2017 at 5:18
  • which one?, you have now around all of them, so you have discrepancy in aligning :(
    – Zarko
    Commented Jun 2, 2017 at 5:27
  • OK, I see, I guess that it will be difficult to align around all the = as some of them have a - sign. Thanks for your help!
    – Joe
    Commented Jun 2, 2017 at 5:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .