4

I found here some hints how to insert only one image to a TikZ Paper Folding Diagram. This code does work here.

\documentclass[a4paper,12pt]{standalone}

\usepackage{graphicx} % support the \includegraphics command and options

\usepackage{tikz}
\usetikzlibrary{folding}
\pagestyle{empty}

\begin{document}

\tikz \pic [transform shape,
folding line length=100mm,
face 1={ \node {
\begin{tikzpicture}
\clip (0,0)  circle (5cm) ;
\node[anchor=center] 
{\includegraphics[width=16cm]{insert_your_image_here.jpg}}; 
\end{tikzpicture}
};},
face 2={ \node {};},
face 4={ \node {};}
] { cube folding }; 

\end{document}

I wanted to insert multiple images, but all I tried did fail. This solution seems to work only with a single image inserted to one face only. Any hints how to modify the code for multiple images?

1

2 Answers 2

4

The given code also works for multiple faces, see below.

enter image description here

\documentclass[border=10pt]{standalone}

\usepackage{tikz}
\usetikzlibrary{folding}
\begin{document}

\tikz \pic [transform shape,
folding line length=100mm,
face 1={ \node {
\begin{tikzpicture}
\clip (0,0)  circle (5cm) ;
\node[anchor=center] 
{\includegraphics[width=16cm]{example-image-a}}; 
\end{tikzpicture}
};},
face 2={ \node {
\begin{tikzpicture}
\clip (0,0)  circle (5cm) ;
\node[anchor=center] 
{\includegraphics[width=16cm]{example-image-b}};
\end{tikzpicture}
};},
face 4={ \node {
\begin{tikzpicture}
\clip (0,0)  circle (5cm) ;
\node[anchor=center] 
{\includegraphics[width=16cm]{example-image-c}};
\end{tikzpicture}
};}
] { cube folding }; 

\end{document}
2
  • Works perfect on the first try. Now I try to clip to the polygon face, for the cube to a square. Thanks a lot!
    – Uwe
    Commented Jan 28, 2021 at 11:36
  • @Uwe Go with Rmano's anwer, the nested tikzpictures are indeed unnecessary and potentially harmful.
    – gernot
    Commented Jan 28, 2021 at 15:21
4

I see no need to use nested tikzpictures (in this case they do work, but I would not bet on it); this snippet:

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{folding}
\begin{document}

\tikz \pic [transform shape,
    folding line length=100mm,
    face 1={
        \clip (0,0)  circle (5cm) ;
        \node[anchor=center]
        {\includegraphics[width=16cm]{example-image-a}};
    },
    face 2={
        \clip (0,0)  circle (5cm) ;
        \node[anchor=center]
        {\includegraphics[width=16cm]{example-image-b}};
    },
face 4={
        \clip (0,0)  circle (5cm) ;
        \node[anchor=center]
        {\includegraphics[width=16cm]{example-image-c}};
    },
] { cube folding };

\end{document}

works correctly too (and it's simpler).

enter image description here

In fact, the manual says:

manual

So I suppose that the code will be executed in a kind-of scope environment.

3
  • Thanks a lot, it is much simpler and works well. I tried to use a rectangle instead of the circle but did not manage to center the clip. The rectangle was used as a square.
    – Uwe
    Commented Jan 28, 2021 at 16:55
  • \clip (-5cm, -5cm) rectangle (5cm, 5cm) ; seems to fill the square perfectly
    – Rmano
    Commented Jan 28, 2021 at 18:18
  • \clip (-5cm, -5cm) fills the square perfectly, even if the images are rotated by -90, 90 and 180 degrees. The anchor is = center for every rotation.
    – Uwe
    Commented Jan 28, 2021 at 18:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .