[Tex/LaTex] Equal height matrix brackets in math mode

formattingmath-modematrices

I'm trying to express a complicated mathematical expression involving the summation of two matrices. One matrix contains a summation with a condition ("a=0 or b=1"), which I'm expressing underneath the Sum symbol using the "substack" approach, as suggested in: https://en.wikibooks.org/wiki/LaTeX/Mathematics

Unfortunately, this causes the matrix bracket top and bottoms to misalign, as shown:
enter image description here

It would look better if this was not the case.

Can this be fixed please?

My MWE is:

\documentclass[10pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}

\begin{document}
Minimum working example:

\begin{equation*}
\dfrac{\mathrm{d}y}{\mathrm{d}x} = 
\begin{bmatrix}
-\sum_{i=1}^{a} A & \cdots & B \\
\vdots  & \ddots  & \vdots  \\
B & \cdots & -\sum_{i=1}^{a} A
\end{bmatrix}
+
\begin{bmatrix}
\sum_{\substack{
        a,b,c,d \\
        a=0~\mathrm{or}~b=1
}} 
A_{ijkl}
-
\sum_{\substack{
        a,b,c,d \\
a=0~\mathrm{or}~b=1
}} 
B_{ijkl} \\
\vdots\\
\sum_{\substack{
        a,b,c,d \\
a=0~\mathrm{or}~b=1
}} 
C_{ijkl}
-
\sum_{\substack{
        a,b,c,d \\
a=0~\mathrm{or}~b=1
}} 
D_{ijkl}
\end{bmatrix}
\end{equation*}

\end{document}

Best Answer

You can use \vphantom in first bmatrix to force a bracket as large as the one used in second bmatrix:

\documentclass[10pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}

\begin{document}
Minimum working example:

\begin{equation*}
\dfrac{\mathrm{d}y}{\mathrm{d}x} = 
\begin{bmatrix}
\vphantom{\sum_{\substack{
        a,b,c,d \\
        a=0~\mathrm{or}~b=1
}}}%
-\sum_{i=1}^{a} A & \cdots & B \\
\vdots  & \ddots  & \vdots  \\
B & \cdots & -\sum_{i=1}^{a} A
\end{bmatrix}
+
\begin{bmatrix}
\sum_{\substack{
        a,b,c,d \\
        a=0~\mathrm{or}~b=1
}} 
A_{ijkl}
-
\sum_{\substack{
        a,b,c,d \\
a=0~\mathrm{or}~b=1
}} 
B_{ijkl} \\
\vdots\\
\sum_{\substack{
        a,b,c,d \\
a=0~\mathrm{or}~b=1
}} 
C_{ijkl}
-
\sum_{\substack{
        a,b,c,d \\
a=0~\mathrm{or}~b=1
}} 
D_{ijkl}
\end{bmatrix}
\end{equation*}

\end{document}

enter image description here

Related Question