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?

Uwe
  • 239
  • Welcome! You are nesting tikzpictures, that will explode sooner or later: https://tex.stackexchange.com/a/66037/38080 – Rmano Jan 28 '21 at 11:24

2 Answers2

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}

gernot
  • 49,614
  • 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 Jan 28 '21 at 11:36
  • @Uwe Go with Rmano's anwer, the nested tikzpictures are indeed unnecessary and potentially harmful. – gernot Jan 28 '21 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.

Rmano
  • 40,848
  • 3
  • 64
  • 125
  • 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 Jan 28 '21 at 16:55
  • \clip (-5cm, -5cm) rectangle (5cm, 5cm) ; seems to fill the square perfectly – Rmano Jan 28 '21 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 Jan 28 '21 at 18:50