我有以下立方体的代码:
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[scale=1.7,> = latex]
\pgfmathsetmacro{\cubex}{2}
\pgfmathsetmacro{\cubey}{1}
\pgfmathsetmacro{\cubez}{1}
\draw[black,fill=yellow] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
\draw[black,fill=yellow] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
\draw[black,fill=yellow] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;
\draw[|<->|,yshift=-.5em] (-\cubex,-\cubey,0)--node[below]{$b_0 \cdots b_m$}++(\cubex,0,0);
\draw[|<->|,xshift=-.5em] (-\cubex,-\cubey,0)--node[above,sloped]{$a_0\cdots a_l$}++(0,\cubey,0);
\draw[|<->|,shift={(.5em,-.5em)}] (0,-\cubey,0)--node[below,sloped]{$c_0 \cdots c_n$}++(0,0,-\cubez);
\end{tikzpicture}
\end{document}
答案1
如果您只对 3D 数组感兴趣,那么有一种使用 PSTricks 的简单方法可以获取这些数组:
\documentclass{standalone}
\usepackage{pst-all}
\usepackage[vcentermath,enableskew]{youngtab}
\begin{document}
\begin{pspicture}(-1,-2)(5,1.5)
\psset{viewpoint=1 0.7 0.5}
\ThreeDput[normal=0 1 0](0,0,0){\young(0000,1111,0100,0111)}
\ThreeDput[normal=0 1 0](0,2,0){\young(0000,1111,0100,0111)}
\ThreeDput[normal=0 1 0](0,4,0){\young(0000,1111,0100,0111)}
\end{pspicture}
\end{document}
这种方法的优点是数字也是倾斜的,即块数组看起来确实是三维的,并且很容易添加线条等。