我对 Latex 还很陌生,一般使用我在 Stackexchange 上找到的建议在文件中构建立方体。现在我需要在其中写入内容。我尝试像往常一样添加节点(就像我在行附近写入“时间”和“知识”一样),但无法使其工作。
\documentclass{article}
\usepackage{tikz}
\usepackage{xcolor}
\usetikzlibrary{positioning}
\begin{document}
\newcommand{\drawbox}[4]{
\pgfmathsetmacro \angle {30}
\pgfmathsetmacro \xd {{2/3*cos(\angle)}}
\pgfmathsetmacro \yd {{2/3*sin(\angle)}}
\pgfmathsetmacro \x {{#1-1+(#2-1)*(\xd)}}
\pgfmathsetmacro \y {{#3-1+(#2-1)*(\yd)}}
\draw[fill=#4] (\x,\y) -- (\x+1,\y) -- (\x+1,\y+1) -- (\x,\y+1) -- cycle;
\draw[fill=#4] (\x,\y+1) -- (\x+\xd,\y+1+\yd) -- (\x+1+\xd,\y+1+\yd) -- (\x+1,\y+1) -- cycle;
\draw[fill=#4] (\x+1,\y+1) -- (\x+1+\xd,\y+1+\yd) -- (\x+1+\xd,\y+\yd) -- (\x+1,\y) -- cycle;
}
\newcommand{\Depth}{2}
\newcommand{\Height}{2}
\newcommand{\Width}{2}
\begin{tikzpicture}
\draw[->] (-1,-0.5) -- node[below, xshift=4cm] {time}(8,-0.5); %x-achse
\draw[->] (-1,-0.5) -- node[above, rotate=90, xshift=2.8cm] {knowledge}(-1, 7); %y-achse
\draw[->, red, thick] (0,2) -- (58:6.5cm); %diagonal line
\drawbox{1}{1}{1}{yellow!50!brown!40!} %bottom box 1
\drawbox{2}{1}{1}{yellow!50!brown!40!} %bottom box 2
\drawbox{3}{1}{1}{yellow!50!brown!40!} %bottom box 3
\drawbox{4}{1}{1}{yellow!50!brown!40!} %bottom box 4
\drawbox{1.5}{1}{2}{yellow!50!brown!40!} %top box 1
\drawbox{2.5}{1}{2}{yellow!50!brown!40!} %top box 2
\drawbox{3.5}{1}{2}{yellow!50!brown!40!} %top box 3
\drawbox{4.5}{1}{2}{yellow!50!brown!40!} %top box 4
\drawbox{4.5}{1}{3}{yellow!50!brown!40!} %top box 5
\drawbox{4.5}{1}{4}{yellow!50!brown!40!} %top box 6
\drawbox{4.5}{1}{5}{yellow!50!brown!40!} %top box 7
\end{tikzpicture}
\end{document}
如果有人能帮助我,我将非常感激。谢谢!