0

In a previous topic (Why do horizontal matrices look different than multistory matrices?), it was asked why a vector holds a different horizontal space from what a matrix holds. One solution devised is to use bvector environment. The matrices in the question are for state-space representation of physical systems dynamics. Thus, they are of interest to me.

When I illustrate or try to explain concepts in a clear fashion, I usually use matrices with rules to divide the matrices as follows

enter image description here

As you can see above, the space held by the vector is slightly larger than the one held by the matrix. Further, the space held internally (i.e., between the brackets [ and ]) are slightly larger with the matrix. This leads to visually distracting equations. Thus, in case that I use array to draw matrices, how can I force the two matrices to

  1. hold the same total space
  2. hold the same space between the brackets surrounding them

Also, the vector x in the last equation does not align with the one above it unless I add a phantom content as shown in the empty box. Can I get the two vectors to align without inserting the phantom content?

\documentclass[10pt,norsk, fleqn]{article}
\usepackage[x11names]{xcolor}
\usepackage[a4paper, margin=1.2cm,includeheadfoot]{geometry}
\usepackage{amsmath}
\usepackage{calc}
\usepackage{eqparbox}
\usepackage{nccmath}

\usepackage{adjustbox}


\begin{document}

\newcommand{\ssarray}{
    \begin{array}{cc !{\vrule width 0.1mm}c}
        2 &1 &1
        \\
        3 &-2 &-2
        \\
        \hline
        1 &1 &2
\end{array}
                    }

\begin{adjustbox}{minipage={0.2\textwidth}}
    \begin{fleqn}
        $\begin{aligned}
            \dot{\vec{x}}(t) &= \textbf{A}\vec{x}(t) + \textbf{B}\vec{u}(t)\\
            \vec{y}(t) &= \textbf{C}\vec{x}(t) + \textbf{D}\vec{u}(t)
        \end{aligned} \medspace \to \medspace$
    \end{fleqn}
\end{adjustbox}
\begin{adjustbox}{minipage={0.6\textwidth}}
    \begin{fleqn}
        \begin{alignat*}{2}
            \dot{\textbf{x}} = &\adjustbox{cframe=green 0.1mm}{$\left[\ssarray\right]$} &\vec{x} + \left[
                \begin{array}{c}
                    2
                    \\
                    1
                    \\
                    \hline
                    2
                \end{array}
            \right] \vec{u}
         \\
            \vec{y} = &\adjustbox{cframe=green 0.1mm}{
                        $\left[
                            \begin{array}{cc !{\vrule width 0.1mm}c}
                                2 &-2 &-2
                            \end{array}
                          \right]$
                                                    }
                    &\vec{x} \adjustbox{phantom, cframe=green 0.1mm}{$\medspace +
            \left[
                \begin{array}{c}
                2
                \\
                1
                \\
                \hline
                2
                \end{array}
            \right]
            \vec{u}$}
        \end{alignat*}
    \end{fleqn}
\end{adjustbox}

\end{document}
  • one way is to draw them with matrix library from the tikz package. – Zarko Mar 28 at 8:28
  • There is also \mathmakebox from the mathtools package. – John Kormylo Mar 28 at 15:54
1

Here is a solution using \mathmakebox.

Not sure why you want all the vertical space in the second equation.

\documentclass[10pt,norsk, fleqn]{article}
\usepackage[x11names]{xcolor}
\usepackage[a4paper, margin=1.2cm,includeheadfoot]{geometry}
\usepackage{mathtools}

\begin{document}

\sbox0{$% measure inside width
    \begin{array}{cc|c}
        2 &1 &1
        \\
        3 &-2 &-2
        \\
        \hline
        1 &1 &2
\end{array}$}%
\sbox1{$\left[\usebox0\right]$}% measure outside width
\sbox2{$\left[\begin{array}{c}
        2\\1\\ \hline 2
    \end{array}\right]$}% measure height
$\begin{aligned}
    \vec{x}\ '(t)   &= \textbf{A}\vec{x}(t) + \textbf{B}\vec{u}(t)\\
    \vec{y}(t)      &= \textbf{C}\vec{x}(t) + \textbf{D}\vec{u}(t)
\end{aligned}\ \ \ \to\ \ \ 
\begin{aligned}
    \dot{\textbf{x}} & = \usebox1 \vec{x} + \usebox2 \vec{u}\\
    \vec{y} & = \mathmakebox[\wd1][c]{\left[
      \mathmakebox[\wd0][c]{\begin{array}{cc|c}0&-1&-1\end{array}}
      \right]} \vec{x} \raisebox{0pt}[\ht2][\dp2]{}% or \vphantom{usebox2}
\end{aligned}$
\end{document}

demo

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.