2

I try to achieve the following: I have two matrices with similar structure, but whose entries differ in length. I want the two matrices to have identical and even spacing. This is what I got so far:

\documentclass{article}

\usepackage{tabstackengine}
\stackMath

\begin{document}

\begin{equation}
\setstackgap{L}{2.1\baselineskip}
\fixTABwidth{T}
\mathbf{A}_T(t)  = 
\bracketMatrixstack{
0 & 1 & 0 & 0 \\
\frac{\beta x_3^*(t) - k_S}{m_1+m_3} & -\frac{d_S+d_P}{m_S+m_P} & \frac{c_1x_1^*(t) -A_{S2}}{m_S + m_P} & -\frac{A_{S1}}{m_P+m_S} \\
\frac{\hat V \nu_P}{\hat x_S C_{h_\mu}} & \frac{A_{S2}}{C_{h_1}} & -\frac{1}{2} \frac{\gamma A_{or1}}{C_{h_\rho}}{\sqrt{|\zeta_7^*(t) - d_2|}} & 0 \\
0 & -\frac{A_{S1}}{C_{h_S}} & 0 & -\frac{1}{2} \frac{\gamma g_R^*(t)c_{R}}{\sqrt{|\zeta_3^*(t) - f_C|}} 
} 
\end{equation}
\begin{equation}
\setstackgap{L}{2.1\baselineskip}
\fixTABwidth{T}
\mathbf{A}_L(t) = 
\bracketMatrixstack{
0 & 1 & 0 & 0 \\
\frac{c_1x_3^*(t) - k_S}{m_\rho} & -\frac{d_S+d_P}{m_S+m_P} & \frac{c_2 x_2^*(t) -A_{S2}}{m_S + m_P} & -\frac{A_{S1}}{m_P+m_S} \\
\frac{\hat V n_P}{\hat x_S C_{h_1}} & \frac{A_{S2}}{C_{h_1}} & -\frac{1}{2C_{h_\delta}} \left( \frac{\gamma A_{\mu}}{\sqrt{|x_6^*(t) - f(\rho t)|}} + \frac{\gamma u_R^*(t)b_{Reg}}{\sqrt{|\zeta_3^*(t) + \zeta_4^*(t)|}} \right) & 0 \\
0 & -\frac{A_{S1}}{C_{h_S}} & -\frac{1}{2} \frac{\gamma u_R^*(t)b_{Reg}}{C_{h_S}\sqrt{|x_3^*(t) - p_C|}} & \frac{1}{2} \frac{\gamma u_R^*(t) m_{\gamma}}{C_{h_\delta}\sqrt{|z_1^*(t) -z_6^*(t)|}} 
}
\end{equation}

\end{document}

This is inspired by: Equal spacing in matrices

Now I'd like to have both these matrices formatted equally and aligned. Is there any way to do so? Sorry, I've just started picking up some tabstack knowledge.

Thanks in advance!

  • Eeeew... That looks quite impossible. – percusse Jan 22 '16 at 13:06
3

After lot of manual tweaking ... well if you liked to have something like this:

enter image description here

For above I use ordinary tabular. For space between rows I employ \addlinespace from booktabs, align is from mathtools (amsmath). With geometry I set margins to 20mm (assuming A4 paper size) ...

Code:

\documentclass{article}
\usepackage[margin=20mm]{geometry}

\usepackage{array,booktabs,mathtools}
\newcolumntype{M}[1]{>{\centering\arraybackslash$\displaystyle}m{#1}<{$}}
    \begin{document}
\begin{align}
\mathbf{A}_T(t)  & =
\left[ 
    \begin{tabular}{M{18mm}M{18mm}@{}M{71mm}@{}M{32mm}}
0   &   1 
        &   0 
            &   0                           \\  \addlinespace
\frac{\beta x_3^*(t) - k_S}{m_1+m_3} 
    &   -\frac{d_S+d_P}{m_S+m_P} 
        &   \frac{c_1x_1^*(t) - A_{S2}}{m_S + m_P} 
            &   -\frac{A_{S1}}{m_P+m_S}     \\  \addlinespace
\frac{\hat V \nu_P}{\hat x_S C_{h_\mu}} 
    &   \frac{A_{S2}}{C_{h_1}} 
        &   -\frac{1}{2}\frac{\gamma A_{or1}}{C_{h_\rho}}{\sqrt{|\zeta_7^*(t) - d_2|}} 
            &   0                           \\    \addlinespace
0   &   -\frac{A_{S1}}{C_{h_S}} 
        &   0 
            &   -\frac{1}{2}\frac{\gamma g_R^*(t)c_{R}}{\sqrt{|\zeta_3^*(t) - f_C|}}
\end{tabular}
\right]         \\[3ex]
\mathbf{A}_L(t) & =
\left[
    \begin{tabular}{M{18mm}M{18mm}@{}M{71mm}@{}M{32mm}}
0 & 1 & 0 & 0                               \\  \addlinespace
\frac{c_1x_3^*(t) - k_S}{m_\rho} 
    &   -\frac{d_S+d_P}{m_S+m_P} 
        &   \frac{c_2 x_2^*(t) -A_{S2}}{m_S + m_P} 
            &   -\frac{A_{S1}}{m_P+m_S}     \\  \addlinespace
\frac{\hat{V} n_P}{\hat{x}_S C_{h_1}} 
    &   \frac{A_{S2}}{C_{h_1}} 
        &   -\frac{1}{2C_{h_\delta}} 
            \biggl(\frac{\gamma A_{\mu}}{\sqrt{|x_6^*(t) - f(\rho t)|}} + 
                   \frac{\gamma u_R^*(t)b_{Reg}}{\sqrt{|\zeta_3^*(t) + \zeta_4^*(t)|}} \biggr)
            &   0                           \\    \addlinespace[2ex]   
0   &   -\frac{A_{S1}}{C_{h_S}} 
        &   -\frac{1}{2}\frac{\gamma u_R^*(t)b_{Reg}}{C_{h_S}\sqrt{|x_3^*(t) - p_C|}}
            &   \frac{1}{2}
                \frac{\gamma u_R^*(t) m_{\gamma}}{C_{h_\delta}\sqrt{|z_1^*(t) -z_6^*(t)|}}
\end{tabular}
\right]
\end{align}
    \end{document}

Is this what you looking for?

  • I rest my case. – percusse Jan 22 '16 at 13:51
  • Thank you very much, this looks much like what I am looking for. It's a bit nitty gritty, but is it possible to have absolutely identical column width - the third column in your solution is wider than the first two, for instance. Is it possible to make them identical, too? At the price of having wider colums one and two, of course. – user62795 Jan 22 '16 at 16:55
  • You just adjust width of column as you like. Let me note: your equation is very lengthy, so I try to squeeze it as mach as possible. And adjacent columns in matrix has equal width. To see this, you can add for test vertical bars between columns. More relaxing style you can obtain with \begin{tabular}{M{18mm}M{18mm} M{71mm} M{32mm}} and if last columns are still to narowly, increase width of the last column, for example from 32mm to 35mm, however, after this the equation is not possible fit into text width. – Zarko Jan 22 '16 at 17:31
  • Wonderful, thank you so much. This is very much the solution I had been looking for - thank you! – user62795 Feb 4 '16 at 7:54

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.