I want to create the net of a flattened hexagonal based box. Each side of the box is a slight trapezium (so in 3D the sides will not be perpendicular to the base, but that's not important to the question). Since each side is the same but only positioned differently I tried the following MWE.
\documentclass{article}
\usepackage{tikz}
\begin{document}
\newcommand{\side}[1][10]{%
\begin{tikzpicture}
\coordinate (sO) at (0,0);
\path (sO)--++(-90:2) coordinate (sB);
\path (sO)--++({#1}:1) coordinate (sC);
\path (sB)--++({-1*#1}:1) coordinate (sD);
\draw (sO)--(sB)--(sD)--(sC)--(sO);
\end{tikzpicture}%
}
\begin{tikzpicture}
\coordinate (O) at (0,0);
\path (O)--++(0:2) coordinate (A1);
\path (O)--++(60:2) coordinate (A2);
\path (O)--++(120:2) coordinate (A3);
\path (O)--++(180:2) coordinate (A4);
\path (O)--++(240:2) coordinate (A5);
\path (O)--++(300:2) coordinate (A6);
\draw (A1)
--node[sloped,rotate=90,anchor=west]{\side}(A2)
--node[sloped,rotate=90,anchor=west]{\side}(A3)
--node[sloped,rotate=90,anchor=west]{\side}(A4)
--node[sloped,rotate=-90,anchor=west]{\side}(A5)
--node[sloped,rotate=-90,anchor=west]{\side}(A6)
--node[sloped,rotate=-90,anchor=west]{\side}(A1);
\end{tikzpicture}
\end{document}
The sides are not flush on the sides of the hexagon. Is there a way to do this elegantly?
Or perhaps my code could be improved, in particular to have the same node information (sometimes I needed rotate=90
, other times rotate=-90
).
inner sep=0pt
innode[sloped,...
Is this what you want?inner sep
though solved that space problem.inner sep=0pt
solves the problem of the spaces. If you state this as an answer I will accept. Concerning the elegance of the code, repeating blocks and repositioning them, I posted a follow on question. Many thanks.