我想在更大的 tikzpicture 中使用拼图碎片,并使用常规命令(例如“below of”)或在碎片之间绘制路径。但在原始文档中,碎片被放在单独的环境中。定义 \piece 不允许使用如下代码:
\documentclass{scrartcl}
\usepackage{tikz}
\usepackage{jigsaw}
\begin{document}
\begin{tikzpicture}
\piece{1}{-1}{0}{0};
\piece{1}{-1}{0}{0}; % below of piece 1
\path (piece1) edge (piece2); %path from piece1 to piece2
\end{tikzpicture}
\end{document}
找到了一个使用“shift”的解决方案。当从拼图块的指定中间位置减去 -0.5cm 时,它就起作用了。
\begin{tikzpicture}
\node at (0,0) (center) {Center1};
\node at (5,0) (center2) {Center2};
\begin{scope}[shift={(center2)},local bounding box=piece1,xshift=1.5cm,yshift=1.5cm]
\piece{1}{-1}{0}{0}
\end{scope}
\begin{scope}[shift={(center2)},local bounding box=piece2,xshift=1.5cm,yshift=-2.5cm]
\piece{1}{-1}{0}{0}
\end{scope}
\begin{scope}[shift={(center2)},local bounding box=piece3,xshift=-2.5cm,yshift=1.5cm]
\piece{1}{-1}{0}{0}
\end{scope}
\begin{scope}[shift={(center2)}, local bounding box=piece4,xshift=-2.5cm,yshift=-2.5cm]
\piece{1}{-1}{0}{0}
\end{scope}
\path (piece1) edge (piece2);
\end{tikzpicture}
答案1
如果您想运行其他 tikz 命令,显然正确的方法是将其放在每个部分的范围环境中 - (非常简短的)手册可在 - http://ctan.math.washington.edu/tex-archive/graphics/pgf/contrib/jigsaw/jigsaw-doc.tex
平均能量损失
\documentclass{scrartcl}
\usepackage{tikz}
\usepackage{jigsaw}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\piece[teal]{1}{-1}{0}{0};
\end{scope}
\begin{scope}[xshift=1cm]
\piece[violet]{1}{-1}{0}{0};
\end{scope}
\end{tikzpicture}
\end{document}
答案2
您可以使用local bounding box
es 连接这些拼图碎片。
\documentclass{scrartcl}
\usepackage{tikz}
\usepackage{jigsaw}
\begin{document}
\begin{tikzpicture}
\begin{scope}[local bounding box=piece1]
\piece{1}{-1}{0}{0}
\end{scope}
\begin{scope}[local bounding box=piece2,yshift=-2cm]
\piece{1}{-1}{0}{0} % below of piece 1
\end{scope}
\path (piece1.south west) edge (piece2.north west); %path from piece1 to piece2
\end{tikzpicture}
\end{document}