1

How can I use a tikz folding library to create a box that does not have regular faces?. For instance, consider this sketch:

folding box for popcorn or gift

I need first to create a trapezoid face to use it with the folding library. This is my first attempt:

\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{folding}

\makeatletter 

\def\tikz@lib@fold@trapecio#1#2#3#4#5{%
  \begin{scope}[xshift=.5\tikz@lib@fold@length,yshift=.5\tikz@lib@fold@length]
    #1
  \end{scope}
  \begin{scope}[yshift=0.8\tikz@lib@fold@length,rotate=20]
    #2 
    \node{Edge A};
  \end{scope}
  \begin{scope}[xshift=\tikz@lib@fold@length,yshift=\tikz@lib@fold@length,rotate=-90]
    #3
    \node{Edge B};
  \end{scope}
  \begin{scope}[xshift=\tikz@lib@fold@length,rotate=180]
    #4
    \node{Edge C};
  \end{scope}
  \begin{scope}[rotate=90]
    #5
    \node{Edge D};
  \end{scope}
}

\def\tikzfoldingtetrahedron#1[#2]#3;{%
  \begingroup%
    \tikzset{#2}%
    \tikz@lib@fold@trapecio
        {\tikz@lib@fold@face@A}
        {\tikz@lib@fold@path}
        {\tikz@lib@fold@path}
        {\tikz@lib@fold@path}
        {\tikz@lib@fold@path}
  \endgroup
}
\makeatother


\begin{document}
  \begin{tikzpicture}[scale=1]
  \path pic [
    folding line length=4cm,
    transform shape,
    numbered faces
  ]
  {tetrahedron folding};
  \end{tikzpicture}
\end{document} 

Please, ignore the tetrahedron name, I didn't realize how to define a new folding name. The code gives this picture:

Trapezoid face

How can I fix the connecting lines between the edges? Even if I compute the proper angles, I need two or more different folding lengths. In all the folding library examples I have seen, there is only one folding length.

  • 1
    Could you please describe more clearly what you want to achieve, and where you are stuck. A sketch would be fine. (Naively I would think that a cube is a better starting point for a popcorn bag than a tetrahedron, but this can be only clarified if the goal is clear.) Also please remove all the stuff that is not needed here, you only use \usetikzlibrary{folding}.) – user121799 Jun 19 at 23:40
  • @marmot thank you for helping me to improve the question. I believe now is much more clear what I want to do. – alexis Jun 20 at 14:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.