我想画一个三棱柱,从格式的角度来看,它应该像下面的 oktaeder
我的出发点是
\documentclass[tikz,border=3.14mm]{standalone}
\begin{document}
\begin{tikzpicture}
\draw[dashed,thick] (-1,0) -- (0,0.5) edge (0,2.5) -- (1,0) coordinate(BR);
\draw[thick] (-1,0) coordinate(BL) rectangle (1,2) coordinate(TR)
-- (0,2.5) coordinate(T) -- (-1,2) coordinate(TL);
\foreach \X [remember=\X as \Y (initially TL),count=\Z] in {BL,BR,TR,T,TL}
{\path (\Y) -- (\X) node[midway,anchor={90*\Z-90-ifthenelse(\Z==4,45,0)-ifthenelse(\Z==5,45,0)}]{label \Z}; }
\end{tikzpicture}
\end{document}
答案1
这个怎么样?
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{arrows.meta,bending,calc}
\begin{document}
\begin{tikzpicture}[lbl/.style={circle,draw,inner sep=1pt},>={Latex[bend]}]
\draw[dashed,thick] (0,2.5) coordinate(T) (-1,0) coordinate(BL) -- (0,0.5) coordinate(B)
edge (T) -- (1,0) coordinate(BR);
\draw[<-] ($(T)!0.5!(BL)$) to[out=90,in=-45] ++ (-0.5,1) node[lbl,above left]{5};
\draw[<-] ($(T)!0.5!(BR)$) to[out=90,in=-135] ++ (0.5,1) node[lbl,above right]{4};
\draw[<-] (0.1,0.3) to[bend left=20] ++ (0,-0.5) node[lbl,below]{2};
\draw[thick,fill=white,fill opacity=0.7] (BL) rectangle (1,2) coordinate(TR)
-- (0,2.5) -- (-1,2) coordinate(TL);
\path (-0.2,1) node[lbl]{1};
\draw[<-] ($(T)+(-0.1,-0.3)$) to[bend left=20] ++ (0,0.5) node[lbl,above]{3};
\end{tikzpicture}
\end{document}