5

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}
4

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

4

Here I use TABstacks, in the form of a \bracketMatrixstack and \bracketVectorstack. Three additional parameters must be set:

  1. \setstackgap{L}{22pt} defines the interrow baselineskip of the stacks;

  2. \setstacktabbedgap{1em} sets the intercolumn gap in the matrix;

  3. \newcommand\mystrut{\rule[-2ex]{0pt}{2ex}} defines a strut that I place just before the end of the stacks, so that the brackets associated with both stacks are the same depth/height.

The MWE:

\documentclass[10pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{tabstackengine}
\TABstackMath
\begin{document}
Minimum working example:

\begin{equation*}
\setstackgap{L}{22pt}
\setstacktabbedgap{1em}
\newcommand\mystrut{\rule[-2ex]{0pt}{2ex}}
\dfrac{\mathrm{d}y}{\mathrm{d}x} = 
\bracketMatrixstack{
-\sum_{i=1}^{a} A & \cdots & B \\
\vdots  & \ddots  & \vdots  \\
B & \cdots & -\sum_{i=1}^{a} A
\mystrut}
+
\bracketVectorstack{
\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\\\mystrut
\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}
\mystrut}
\end{equation*}

\end{document}

enter image description here

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.