3

I have written the sum of two hypermatrices with tikz with the following code.

  \documentclass{article}
  \usepackage{tikz-cd} 
  \usetikzlibrary{calc}
  \usetikzlibrary{arrows}

\begin{document}

\begin{equation} \begin{tikzpicture}[every node/.style={minimum width=1.2cm,minimum height=1.2cm}] \matrix (mA) [draw,matrix of math nodes] { b_1^1 b^2_1 b^3_1 & \hspace{1mm} b_1^1 b^2_1 b^3_2 \ b_1^1 b^2_2 b^3_1 & \hspace{1mm} b_1^1 b^2_2 b^3_2 \ }; \matrix (mB) [draw,matrix of math nodes] at ($(mA.south west)+(4.5 cm,3cm)$) { b_1^2 b^2_1 b^3_1 & \hspace{1mm} b_1^2 b^2_1 b^3_2 \ b_1^2 b^2_2 b^3_1 & \hspace{1mm} b_1^2 b^2_2 b^3_2 \ }; \draw[dashed](mA.south west)--(mB.south west); \draw[dashed](mA.north east)--(mB.north east); \draw[dashed](mA.north west)--(mB.north west); \draw[dashed](mA.south east)--(mB.south east); \end{tikzpicture} \ \ + \ \ \begin{tikzpicture}[every node/.style={minimum width=1.2cm,minimum height=1.2cm}] \matrix (mA) [draw,matrix of math nodes] { c_1^1 c^2_1 c^3_1 & \hspace{1mm} c_1^1 c^2_1 c^3_2 \ c_1^1 c^2_2 c^3_1 & \hspace{1mm} c_1^1 c^2_2 c^3_2 \ }; \matrix (mB) [draw,matrix of math nodes] at ($(mA.south west)+(4.5 cm,3cm)$) { c_1^2 c^2_1 c^3_1 & \hspace{1mm} c_1^2 c^2_1 c^3_2 \ c_1^2 c^2_2 c^3_1 & \hspace{1mm} c_1^2 c^2_2 c^3_2 \ }; \draw[dashed](mA.south west)--(mB.south west); \draw[dashed](mA.north east)--(mB.north east); \draw[dashed](mA.north west)--(mB.north west); \draw[dashed](mA.south east)--(mB.south east); \end{tikzpicture} \end{equation}

\end{document}

The output looks like:

enter image description here

I am struggling to lift the addition sign up to the center of the hypermatrices. Any help would be appreciated!

fdzsfhaS
  • 259
  • 1
    The following formatting approach for such matrices may be of passing interest: https://tex.stackexchange.com/questions/192620/plot-3d-stacked-squares-with-shadow – Steven B. Segletes Nov 02 '21 at 15:40

1 Answers1

4

You can use \vcenter to vertically center the pictures (matrices) in the equation.

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd} 
\usetikzlibrary{calc}
\usetikzlibrary{arrows}

\begin{document}

\begin{equation} \vcenter{\hbox{\begin{tikzpicture}[every node/.style={minimum width=1.2cm,minimum height=1.2cm}] \matrix (mA) [draw,matrix of math nodes] { b_1^1 b^2_1 b^3_1 & \hspace{1mm} b_1^1 b^2_1 b^3_2 \ b_1^1 b^2_2 b^3_1 & \hspace{1mm} b_1^1 b^2_2 b^3_2 \ }; \matrix (mB) [draw,matrix of math nodes] at ($(mA.south west)+(4.5 cm,3cm)$) { b_1^2 b^2_1 b^3_1 & \hspace{1mm} b_1^2 b^2_1 b^3_2 \ b_1^2 b^2_2 b^3_1 & \hspace{1mm} b_1^2 b^2_2 b^3_2 \ }; \draw[dashed](mA.south west)--(mB.south west); \draw[dashed](mA.north east)--(mB.north east); \draw[dashed](mA.north west)--(mB.north west); \draw[dashed](mA.south east)--(mB.south east); \end{tikzpicture}}} \ \ + \ \ \vcenter{\hbox{\begin{tikzpicture}[every node/.style={minimum width=1.2cm,minimum height=1.2cm}] \matrix (mA) [draw,matrix of math nodes] { c_1^1 c^2_1 c^3_1 & \hspace{1mm} c_1^1 c^2_1 c^3_2 \ c_1^1 c^2_2 c^3_1 & \hspace{1mm} c_1^1 c^2_2 c^3_2 \ }; \matrix (mB) [draw,matrix of math nodes] at ($(mA.south west)+(4.5 cm,3cm)$) { c_1^2 c^2_1 c^3_1 & \hspace{1mm} c_1^2 c^2_1 c^3_2 \ c_1^2 c^2_2 c^3_1 & \hspace{1mm} c_1^2 c^2_2 c^3_2 \ }; \draw[dashed](mA.south west)--(mB.south west); \draw[dashed](mA.north east)--(mB.north east); \draw[dashed](mA.north west)--(mB.north west); \draw[dashed](mA.south east)--(mB.south east); \end{tikzpicture}}} \end{equation}

\end{document}

enter image description here

Alternatively you could put everything in one tikzpicture.