答案1
以下是使用循环的一种实现。将矩阵放入循环中所需的解决方法取自(定义 TikZ 矩阵的快捷方式存在问题。) 和 (为什么当我将 \matrix 路径放入另一个宏中时会失败?)
需要进行一些更改以使编号/索引方案与给定的图片一一对应。
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\def\xs{1} %shift in x direction
\def\ys{0.5} %shift in y direction
\def\nm{5} % number of 2d matrices in the 3d matrix
\foreach \x in {1,2,...,\nm}
{
\matrix [draw, % for the rectangle border
fill=white, % so that it is not transparent
ampersand replacement=\&] %see explanation
(mm\x)%give the matrix a name
at(-\x * \xs, -\x * \ys) %shift the matrix
{
\node {(\x,1,1)}; \& \node {(\x,1,2)};\\
\node {(\x,2,1)}; \& \node {(\x,2,2)};\\
};
}
\draw [dashed,gray](mm1.north west) -- (mm\nm.north west);
\draw [dashed,gray](mm1.north east) -- (mm\nm.north east);
\draw [dashed,gray](mm1.south east) -- (mm\nm.south east);
\end{tikzpicture}
\end{document}
答案2
首次尝试使用tikz
和matrix
库
\documentclass[margin=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix,calc}
\begin{document}
\begin{tikzpicture}[every node/.style={anchor=north east,fill=white,minimum width=1.4cm,minimum height=7mm}]
\matrix (mA) [draw,matrix of math nodes]
{
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
};
\matrix (mB) [draw,matrix of math nodes] at ($(mA.south west)+(1.5,0.7)$)
{
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
};
\matrix (mC) [draw,matrix of math nodes] at ($(mB.south west)+(1.5,0.7)$)
{
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
(1,1,3) & (1,1,3) & (1,1,3) & (1,1,3) \\
};
\draw[dashed](mA.north east)--(mC.north east);
\draw[dashed](mA.north west)--(mC.north west);
\draw[dashed](mA.south east)--(mC.south east);
\end{tikzpicture}
\end{document}
输出