1

I would like to typeset an equation like shown in the pic. enter image description here

I know how to typeset the equation

\begin{gather}
 \begin{bmatrix} \Phi_{11} & \Phi_{12} \\ \Phi_{21} & \Phi_{22} \end{bmatrix}
 \begin{bmatrix} \Phi_{11} & \Phi_{12} \\ \Phi_{21} & \Phi_{22} \end{bmatrix}
 =
  \begin{bmatrix}
   X_{22} Y_{11} - X_{12} Y_{21} &
   X_{22} Y_{12} - X_{12} Y_{22} \\
   X_{11} Y_{21} - X_{21} Y_{11} &
   X_{11} Y_{22} - X_{21} Y_{12} 
   \end{bmatrix}
\end{gather}

But have no clue how to add the annotation to make the equation look like exactly the one shown in the pic. Any idea?

user1935724
  • 1,339

4 Answers4

3

With nicematrix it is very easy to obtain such an output.

\documentclass{article}
\usepackage{amsmath}
\usepackage{nicematrix}
\newcommand{\Vdashes}{\begin{tikzpicture}[baseline={(0,0)}]
\draw[densely dashed] (0,-1.5) -- (0,1);
\end{tikzpicture}}
\begin{document}
\[
 \Vdashes\begin{bNiceArray}{CCC}[first-col,code-for-first-col =\scriptstyle,
 name=M,
 code-after = {\begin{tikzpicture}
 \path (2-1.south) -- (2-2.south) node[midway,below=1em]{$\mathsf{M}$};
    \end{tikzpicture}}] 
 \mathsf{a}:&\Phi_{11} & \Phi_{12} \\ 
 \mathsf{b}:&\Phi_{21} & \Phi_{22} 
 \end{bNiceArray}\Vdashes
 \begin{bNiceArray}{CC}[name=W,
 code-after = {\begin{tikzpicture}
 \path (2-1.south) -- (2-2.south) node[midway,below=1em]{$\mathsf{W}$};
    \end{tikzpicture}}] 
  \Phi_{11} & \Phi_{12} \\ 
  \Phi_{21} & \Phi_{22} 
 \end{bNiceArray}
 =\Vdashes
 \begin{bNiceArray}{CCC}[first-col,code-for-first-col =\scriptstyle,
  name=T,
 code-after = {\begin{tikzpicture}
 \path (2-1.south) -- (2-2.south) node[midway,below=1em]{$\mathsf{T}$};
    \end{tikzpicture}}] 
  \mathsf{a}:& X_{22} Y_{11} - X_{12} Y_{21} &
   X_{22} Y_{12} - X_{12} Y_{22} \\
  \mathsf{b}:& X_{11} Y_{21} - X_{21} Y_{11} &
   X_{11} Y_{22} - X_{21} Y_{12} 
 \end{bNiceArray}
 \Vdashes
\]
\end{document}

enter image description here

Per request. Not sure if I personally like these underbraces but it is easy to add them. (At least the = sign is at the correct vertical position.)

\documentclass{article}
\usepackage{mathtools}
\usepackage{nicematrix}
\begin{document}
\[
 \underbrace{\begin{bNiceArray}{CCC}[first-col,
 code-for-first-col =\scriptstyle] 
 \mathsf{a}\mathrlap{:}&\Phi_{11} & \Phi_{12} \\ 
 \mathsf{b}\mathrlap{:}&\Phi_{21} & \Phi_{22} 
 \end{bNiceArray}}_{\textstyle =M}
 \underbrace{\begin{bNiceArray}{CC} 
  \Phi_{11} & \Phi_{12} \\ 
  \Phi_{21} & \Phi_{22} 
 \end{bNiceArray}}_{\textstyle =W}
 =
 \underbrace{\begin{bNiceArray}{CCC}[first-col,code-for-first-col =\scriptstyle] 
  \mathsf{a}\mathrlap{:}& X_{22} Y_{11} - X_{12} Y_{21} &
   X_{22} Y_{12} - X_{12} Y_{22} \\
  \mathsf{b}\mathrlap{:}& X_{11} Y_{21} - X_{21} Y_{11} &
   X_{11} Y_{22} - X_{21} Y_{12} 
 \end{bNiceArray}}_{\textstyle =T}
\]
\end{document}

enter image description here

You can shrink the a and b column further if needed.

\documentclass{article}
\usepackage{mathtools}
\usepackage{nicematrix}
\begin{document}
\[
 \underbrace{\begin{bNiceArray}{CCC}[first-col,
 code-for-first-col =\!\!] 
 \mathsf{a}\mathrlap{:}&\Phi_{11} & \Phi_{12} \\ 
 \mathsf{b}\mathrlap{:}&\Phi_{21} & \Phi_{22} 
 \end{bNiceArray}}_{\textstyle =M}
 \underbrace{\begin{bNiceArray}{CC} 
  \Phi_{11} & \Phi_{12} \\ 
  \Phi_{21} & \Phi_{22} 
 \end{bNiceArray}}_{\textstyle =W}
 =
 \underbrace{\begin{bNiceArray}{CCC}[first-col,code-for-first-col =\!\!] 
  \mathsf{a}\mathrlap{:}& X_{22} Y_{11} - X_{12} Y_{21} &
   X_{22} Y_{12} - X_{12} Y_{22} \\
  \mathsf{b}\mathrlap{:}& X_{11} Y_{21} - X_{21} Y_{11} &
   X_{11} Y_{22} - X_{21} Y_{12} 
 \end{bNiceArray}}_{\textstyle =T}
\]
\end{document}

enter image description here

  • would you please replace the dotted line with the braces under matrix as suggested by @Zarko? Also how can I change the spacing between : and [ at both side of the equation as well as that at both sides of =? – user1935724 Apr 06 '20 at 23:13
  • @user1935724 Sure, I added them. Not sure if I'd use them personally, though, I like your original picture better (with all its aspects, including a densely dashed line, but this is all a matter of taste). –  Apr 06 '20 at 23:35
  • very nice thanks a lot! I'd like to further improve it though, how do I make a, b larger and also how to control the space between ] and = also the space between = and a:( and b:) – user1935724 Apr 06 '20 at 23:51
  • @user1935724 If you drop the keys code-for-first-col =\scriptstyle then a and b will become larger. If you replace = by ~=~, say the space around the = will become larger. –  Apr 07 '20 at 00:00
  • actually I am using \! to shrink the space between = and a: but braces got shifted as well which now starts covering = how can I fix that ? – user1935724 Apr 07 '20 at 00:09
  • @user1935724 I added another version, based on the comments. Is that what you want? –  Apr 07 '20 at 00:15
  • perfect, thanks! – user1935724 Apr 07 '20 at 00:22
3

A combination of arydshln and nicematrix, but no explicit TikZ.

Fix the figures in the \rule command to suit you. The optional argument sets the amount of space under the baseline (that's the line passing through the bottom of the equation number) and the second mandatory argument specifies the total height of the rule. With the given code there are 50pt below the baseline and 40 above.

\documentclass{article}
\usepackage{amsmath,array,arydshln,nicematrix}

\begin{document}

\begin{equation}
\newcommand{\matrixname}[2]{% #1 = number of columns to span, #2 = name
  \multicolumn{#1}{C}{\mbox{\Large$#2\smash[b]{\vphantom{\Bigl|}}$}}%
}
\begin{array}[t]{: @{}c@{} : @{}c@{} : @{}c@{} :}
\rule[-50pt]{0pt}{90pt}
\begin{bNiceMatrix}[first-col,last-row]
\mathsf{a:} & \Phi_{11} & \Phi_{12} \\
\mathsf{b:} & \Phi_{21} & \Phi_{22} \\
            & \matrixname{2}{\mathsf{M}}
\end{bNiceMatrix}
&
\begin{bNiceMatrix}[last-row]
\Phi_{11} & \Phi_{12} \\
\Phi_{21} & \Phi_{22} \\
\matrixname{2}{\mathsf{W}}
\end{bNiceMatrix}
={}&
\begin{bNiceMatrix}[first-col,last-row]
\mathsf{a:} & X_{11}Y_{11}-X_{12}Y_{21} & X_{22}Y_{12}-X_{12}Y_{22} \\
\mathsf{b:} & X_{11}Y_{21}-X_{21}Y_{11} & X_{11}Y_{22}-X_{21}Y_{12} \\
            & \matrixname{2}{\mathsf{T}}
\end{bNiceMatrix}
\end{array}
\end{equation}

\end{document}

enter image description here

egreg
  • 1,121,712
2

You may liked more standard way of annotation:

enter image description here

\documentclass{article}
\usepackage{geometry}
\usepackage{amsmath, blkarray}
\usepackage{bm}

\begin{document}
\begin{equation}
 \underbrace{\begin{blockarray}{r[cc]}
a: &    \Phi_{11} & \Phi_{12} \\ 
b: &    \Phi_{21} & \Phi_{22} 
             \end{blockarray}}_{\bf{M}}
 \underbrace{\begin{blockarray}{[cc]}
        \Phi_{11} & \Phi_{12} \\ \Phi_{21} & \Phi_{22}
            \end{blockarray}}_{\bf{W}}
 =
 \underbrace{\begin{blockarray}{r[cc]}
a: &    X_{22} Y_{11} - X_{12} Y_{21} & X_{22} Y_{12} - X_{12} Y_{22} \\
b: &    X_{11} Y_{21} - X_{21} Y_{11} & X_{11} Y_{22} - X_{21} Y_{12} 
    \end{blockarray}}_{\bf{T}}
\end{equation}
\end{document}
Zarko
  • 296,517
  • is there a way that I can control the space between : and [ at both side of the equation as well as that at both sides of =? Thanks – user1935724 Apr 06 '20 at 18:00
  • @user1935724, so far I didn't found the way. Sorry. T my opinion answer which propose nicematrix is way to go. It can be easily adopt to use braces below matrix as I suggested in my answer. – Zarko Apr 06 '20 at 20:05
  • 1
    Thanks @Zarko for the suggestion! – user1935724 Apr 06 '20 at 23:18
2

Already gave many nice suggestions, but consider this one may suits with you:

\documentclass{book}
\usepackage{mathtools}

\begin{document}

\begin{gather}
\begin{matrix}
 \begin{bmatrix} \Phi_{11} & \Phi_{12} \\ \Phi_{21} & \Phi_{22}
\end{bmatrix}\\[6pt]
M
\end{matrix}
\begin{matrix}
 \begin{bmatrix} \Phi_{11} & \Phi_{12} \\ \Phi_{21} & \Phi_{22}
\end{bmatrix}\\[6pt]
W
\end{matrix}
 =
\begin{matrix}
  \begin{bmatrix}
   X_{22} Y_{11} - X_{12} Y_{21} &
   X_{22} Y_{12} - X_{12} Y_{22} \\
   X_{11} Y_{21} - X_{21} Y_{11} &
   X_{11} Y_{22} - X_{21} Y_{12}   \end{bmatrix}\\[6pt]
 T
\end{matrix}
\end{gather}

\end{document}

Edit

\documentclass{book}
\usepackage{mathtools}
\usepackage{array,arydshln}

\begin{document}

\begin{gather}
\begin{array}{:c:}
 \begin{bmatrix} \Phi_{11} & \Phi_{12} \\ \Phi_{21} & \Phi_{22}
\end{bmatrix}\\[6pt]
M
\end{array}
\begin{array}{c}
 \begin{bmatrix} \Phi_{11} & \Phi_{12} \\ \Phi_{21} & \Phi_{22}
\end{bmatrix}\\[6pt]
W
\end{array}
 =
\begin{array}{:c:}
  \begin{bmatrix}
   X_{22} Y_{11} - X_{12} Y_{21} &
   X_{22} Y_{12} - X_{12} Y_{22} \\
   X_{11} Y_{21} - X_{21} Y_{11} &
   X_{11} Y_{22} - X_{21} Y_{12}   \end{bmatrix}\\[6pt]
 T
\end{array}
\end{gather}

\end{document}

Is this meets the requirement?

MadyYuvi
  • 13,693