我正在尝试将 = 和 + 符号提升到超矩阵的中心。如能得到任何帮助,我将不胜感激!
\begin{equation*}
{\begin{tikzpicture}[every node/.style={anchor=north east,fill=white,minimum width=.7cm,minimum height=5mm}]
\matrix (mA) [draw,matrix of math nodes]
{
1 & 0 \\
0 & 1 \\
};
\matrix (mB) [draw,matrix of math nodes] at ($(mA.south west)+(2.6,2.6)$)
{
0 & -1 \\
1 & 0\\
};
\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={anchor=north east,fill=white,minimum width=.7cm,minimum height=5mm}]
\matrix (mA) [draw,matrix of math nodes]
{
0 & 0 \\
0 & 1 \\
};
\matrix (mB) [draw,matrix of math nodes] at ($(mA.south west)+(2.6,2.6)$)
{
0 & 0 \\
0 & 1\\
};
\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={anchor=north east,fill=white,minimum width=.7cm,minimum height=5mm}]
\matrix (mA) [draw,matrix of math nodes]
{
1 & 0 \\
0 & 0 \\
};
\matrix (mB) [draw,matrix of math nodes] at ($(mA.south west)+(2.6,2.6)$)
{
-1 & 0 \\
0 & 0\\
};
\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={anchor=north east,fill=white,minimum width=.7cm,minimum height=5mm}]
\matrix (mA) [draw,matrix of math nodes]
{
0 & 0 \\
0 & 0 \\
};
\matrix (mB) [draw,matrix of math nodes] at ($(mA.south west)+(2.6,2.6)$)
{
1 & -1 \\
1 & -1\\
};
\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*}
答案1
那么,为什么不为超矩阵创建一个宏呢?假设它们总是2x2x2
,就是这样。
例如,只需在您的代码中在超矩阵的中心添加一个节点以进行您需要的对齐(这样您就可以设置相对于该节点的基线)并更改与号以防止出现问题,但转换为宏\hypermatrix
:
\documentclass {article}
\usepackage {amsmath}
\usepackage {lipsum}
\usepackage {tikz}
\usetikzlibrary{calc,matrix}
\newcommand{\hypermatrix}[8]
{%
\begin{tikzpicture}[baseline=(center),every node/.style={anchor=north east,minimum width=7mm,minimum height=5mm}]
\matrix (mA) [draw,matrix of math nodes,ampersand replacement=\&]
{
#1 \& #2\\
#3 \& #4\\
};
\matrix (mB) [draw,matrix of math nodes,ampersand replacement=\&] at ($(mA.south west)+(2.6,2.6)$)
{
#5 \& #6\\
#7 \& #8\\
};
\draw[dashed](mA.north east)--(mB.north east);
\draw[dashed](mA.north west)--(mB.north west);
\draw[dashed](mA.south east)--(mB.south east);
\node (center) at ($(mA.south east)!0.5!(mB.north west)$) {};
\end{tikzpicture}%
}
\begin{document}
\lipsum[1]
\begin{equation*}
\hypermatrix{1}{0}{0}{1}{0}{-1}{1}{0} =
\hypermatrix{0}{0}{0}{1}{0}{0}{0}{1} +
\hypermatrix{1}{0}{0}{0}{-1}{0}{0}{0} +
\hypermatrix{0}{0}{0}{0}{1}{-1}{1}{-1}
\end{equation*}
\lipsum[2]
\end{document}
答案2
您可以使用 手动提升运算符\raisebox
。对于您的矩阵, .48 似乎可以使它们居中。
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\usetikzlibrary{calc}
\begin{document}
\begin{equation*}
{\begin{tikzpicture}[every node/.style={anchor=north east,fill=white,minimum width=.7cm,minimum height=5mm}]
\matrix (mA) [draw,matrix of math nodes]
{
1 & 0 \\
0 & 1 \\
};
\matrix (mB) [draw,matrix of math nodes] at ($(mA.south west)+(2.6,2.6)$)
{
0 & -1 \\
1 & 0\\
};
\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}
\ \raisebox{.48in}{=} \
\begin{tikzpicture}[every node/.style={anchor=north east,fill=white,minimum width=.7cm,minimum height=5mm}]
\matrix (mA) [draw,matrix of math nodes]
{
0 & 0 \\
0 & 1 \\
};
\matrix (mB) [draw,matrix of math nodes] at ($(mA.south west)+(2.6,2.6)$)
{
0 & 0 \\
0 & 1\\
};
\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}
\ \raisebox{.48in}{+} \
\begin{tikzpicture}[every node/.style={anchor=north east,fill=white,minimum width=.7cm,minimum height=5mm}]
\matrix (mA) [draw,matrix of math nodes]
{
1 & 0 \\
0 & 0 \\
};
\matrix (mB) [draw,matrix of math nodes] at ($(mA.south west)+(2.6,2.6)$)
{
-1 & 0 \\
0 & 0\\
};
\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}
\ \raisebox{.48in}{+} \
\begin{tikzpicture}[every node/.style={anchor=north east,fill=white,minimum width=.7cm,minimum height=5mm}]
\matrix (mA) [draw,matrix of math nodes]
{
0 & 0 \\
0 & 0 \\
};
\matrix (mB) [draw,matrix of math nodes] at ($(mA.south west)+(2.6,2.6)$)
{
1 & -1 \\
1 & -1\\
};
\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}