使用 tikz 格式化两个超矩阵的总和

使用 tikz 格式化两个超矩阵的总和

我已经使用以下代码用 tikz 编写了两个超矩阵的总和。

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

输出如下所示:

在此处输入图片描述

我正在努力将加法符号提升到超矩阵的中心。任何帮助都将不胜感激!

答案1

您可以使用\vcenter它将等式中的图片(矩阵)垂直居中。

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

在此处输入图片描述

或者,你可以将所有内容放在一个地方tikzpicture

相关内容