I have several TikZ pictures of different sizes, and I need to use the resizebox function to convert them to the same size and put them into a single figure by subfigure. I also want to add some edges between these subfigures.
The image I expect to get is as follows:
Here is my current approach.
I use \tikz[remember picture] \node () {...}; as mentioned in Draw over mutliple subfigures [duplicate]. The resulting picture is like:
Then I add the resizebox function, but the result is not as expected. It seems that the original positions of the nodes are remembered instead of the resized ones.
How to properly draw over multiple subfigures after resizebox? Any help would be greatly appreciated!
Below is my code:
\documentclass[preview]{standalone}
\usepackage{caption, subcaption} % for subfigure
\usepackage{tikz}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}[b]{0.3\textwidth}
\centering
\tikz[remember picture] \node[draw, dashed] (9) {\resizebox{0.9\linewidth}{!}{\begin{tikzpicture}
\foreach \i in {0,...,9} {\node[draw] (9-\i) at (\i, \i) {\i};}
\end{tikzpicture}}};
\caption{9 boxes}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.3\textwidth}
\centering
\tikz[remember picture] \node[draw, dashed] (6) {\resizebox{0.9\linewidth}{!}{\begin{tikzpicture}
\foreach \i in {0,...,6} {\node[draw] (6-\i) at (-\i,\i) {\i};}
\end{tikzpicture}}};
\caption{6 boxes}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.3\textwidth}
\centering
\tikz[remember picture] \node[draw, dashed] (3) {\resizebox{0.9\linewidth}{!}{\begin{tikzpicture}
\foreach \i in {0,...,3} {\node[draw] (3-\i) at (\i,\i) {\i};}
\end{tikzpicture}}};
\caption{3 boxes}
\begin{tikzpicture}[overlay, remember picture]
\draw (9-9.north east) -- (6.north west);
\draw (9-9.south east) -- (6.south west);
\draw (6-3.north east) -- (3.north west);
\draw (6-3.south east) -- (3.south west);
\end{tikzpicture}
\end{subfigure}
\end{figure}
\end{document}


\resizeboxand uses the original placement. Do you want to actually resize your individual figures or do you just want to reduce the distance between nodes? Maybe, thespylibrary is a better approach to your diagram. – Qrrbrbirlbel Mar 22 '23 at 12:25