This code shows a cube with a horizontal plane inside of it. how I can make this plane vertical?
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}
\foreach \n/\x/\l/\p in{
1/{(0, 4)}/{$1$}/left,
2/{(4, 4)}/{$2$}/south west,
3/{(0, 0)}/{$3$}/below,
4/{(4, 0)}/{$4$}/below,
5/{(0.8, 4.8)}/{$5$}/above,
6/{(4.8, 4.8)}/{$6$}/above,
7/{(.8, 1)}/{$7$}/south east,
8/{(4.8, 1)}/{$8$}/right
}{
\node[inner sep=2pt,circle,draw,fill,label={\p:\l}] (\n) at \x {};
}
\draw (1) -- (2) -- (4) -- (3) -- cycle;
\draw (1) -- (2) -- (6) -- (5) -- cycle;
\draw (2) -- (4) -- (8) -- (6) -- cycle;
\draw (3) -- (1) -- (5);
\draw[dashed] (5) -- (7) -- (3);
\draw[dashed] (7) -- (8);
\draw[pattern=north west lines] ($(1)!0.5!(3)$) -- ($(5)!0.5!(7)$) -- ($(6)!0.5!(8)$) -- ($(2)!0.5!(4)$) -- cycle;
\node (a1) at ($(3)!0.5!(4) - (0,0.5)$) {$1\rightarrow3$};
\node (a2) at ($(a1) - (0,0.5)$) {$5\rightarrow7$};
\node (a3) at ($(a2) - (0,0.5)$) {$6\rightarrow8$};
\node (a4) at ($(a3) - (0,0.5)$) {$2\rightarrow4$};
\end{tikzpicture}
\end{document}
\draw[pattern=north west lines] ($(1)!0.5!(3)$) -- ($(5)!0.5!(7)$) -- ($(6)!0.5!(8)$) -- ($(2)!0.5!(4)$) -- cycle;. This means that you change 1/3;5/7;6/8;2/4 either to 1/2;3/4;7/8;5/6 or to 1/5;2/6;4/8;3/7. – KersouMan Aug 03 '20 at 10:21\draw[pattern=north west lines] ($(1)!0.5!(2)$) -- ($(3)!0.5!(4)$) -- ($(7)!0.5!(8)$) -- ($(5)!0.5!(6)$) -- cycle;or\draw[pattern=north west lines] ($(1)!0.5!(5)$) -- ($(2)!0.5!(6)$) -- ($(4)!0.5!(8)$) -- ($(3)!0.5!(7)$) -- cycle;depending on which plane you want. – KersouMan Aug 03 '20 at 19:03($(1)!0.5!(2)$)is the point located midway between coordinates(1)and(2). Then you compute the other points that you need and you join them with--. Thecycleis here to close the path by joining the last point in the list to the first point in the list. For diagonal plane, you just join the vertices you want by using(1) -- (4) -- (8) -- (6) -- cycleas a list of coordinates for example. – KersouMan Aug 03 '20 at 19:12(1.center) -- (4.center) -- (8.center) -- (6.center) -- cycleforcycleto work correctly. – KersouMan Aug 03 '20 at 19:29