I would like to draw a connection between two tikzpicture
, each in a subfigure - in the following MWE, between the nodes n1
and n3
. I think my code makes sense:
\documentclass[a4paper, 12pt]{article}
\usepackage{subcaption}
\usepackage{tikz}
\usetikzlibrary{automata, positioning, arrows, decorations.pathreplacing, calc, chains, shapes.misc}
\begin{document}
some text some more text
\begin{figure*}
%left subfigure
\begin{subfigure}[t]{.45\textwidth}
\begin{tikzpicture}[remember picture]
\node[draw, red] (n1) at (0,0) {};
\end{tikzpicture}
\caption{Caption A}
\end{subfigure}
%
\hfill
% right subfigure
\begin{subfigure}[t]{.45\textwidth}
\begin{tikzpicture}[remember picture]
\node[draw, red] (n2) at (0,0) {};
\node[draw, red] (n3) at (1,1) {};
\end{tikzpicture}
\caption{Caption B}
\end{subfigure}
\begin{tikzpicture}[overlay]
\draw[blue] (n1) -- (n2);
\end{tikzpicture}
\caption{Some caption for A and B.}
\end{figure*}
\end{document}
However, the results tells I am wrong (please note the blue line on the very top): :)
But I don't know what I am doing wrong.