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
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
- hold the same total space
- 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}
matrix
library from thetikz
package. – Zarko Mar 28 '19 at 8:28