4

I want to place a node of a tikzpicture depending on a node of a previous tikzpicture.

MWE:

\documentclass[a7paper]{scrartcl}

\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\centering
\begin{tikzpicture}
\node (a) {a};
\node[below left=of a] (b) {b};
\end{tikzpicture}

\newpage

\begin{tikzpicture}
\node[below=of b] (c) {c};
\end{tikzpicture}
\captionof{figure}{test}

\end{document}

Transforming coordinates, so (0,0) from tikzpicture is put in the desired place of the page and Extract x, y coordinate of an arbitrary point on curve in TikZ indicate that using overlay could be an option, but I actually believe that this isn't the right way to go.

Using an overlay also causes problems to the position of the caption.

  • Have you tried your code removing centering in first tikzpicture? – ferahfeza Apr 22 at 20:11
  • @ferahfeza Yes. this would cause both pictures to be left aligned – Ben Apr 22 at 20:12
3

If you add remember picture and overlay,remember picture

\documentclass[a7paper]{scrartcl}

\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\centering
\begin{tikzpicture}[remember picture]
\node (a) {a};
\node[below left=of a] (b) {b};
\end{tikzpicture}

\newpage

\begin{tikzpicture}[overlay,remember picture]
\node[below=of b] (c) {c};
\end{tikzpicture}
\end{document}

you get

enter image description here

Is that what you are looking for or go at least in the right direction?

From the title of the question I am more thinking you may be looking for something like this:

\documentclass[a7paper]{scrartcl}

\usepackage{tikz}
\usepackage{tikzpagenodes}
\usetikzlibrary{positioning}
\usepackage{caption}
\begin{document}

\centering
\begin{tikzpicture}[remember picture]
\node (a) {a};
\node[below left=of a] (b) {b};
\end{tikzpicture}

\newpage

\begin{tikzpicture}[overlay,remember picture]
\path (b|-current page text area.north) coordinate (bshiftedup);
\node[below=0pt of bshiftedup] (c) {c};
\node[anchor=north,align=center,text width=0.9\textwidth] at 
(c.south-|current page text area.center) {\captionof{figure}{test}};
\end{tikzpicture}

\end{document}

enter image description here

That way the continuation really starts at the top of the page, which might be useful if the picture doesn't fit on a page.

  • This is a simple question but it is very useful! – manooooh Apr 22 at 21:22
  • @Ben I am sorry, I do not understand what you are saying. Could you please do me a favor and read your comment and gauge whether or not you would understand it if you hadn't the background information that no one apart from you has? figures are floats, did you consider this when using them to measure white space? There is actually not white space at all because this is an overlay picture. – marmot Apr 22 at 21:58
  • @Ben This caption is a caption made with \captionof and it is wherever you put it. This has nothing to do with overlay but only with node distance and the like. – marmot Apr 22 at 22:22
  • Adding yshift=4pt to the last "caption"-node and changing the text width to \textwidth results in a perfect match for other captionskips/captionwidths – Ben Apr 22 at 22:35
  • @Ben You should delete your comments if they are no longer needed and the answer is already edited. But you should not delete your comment in this case. From my point, I can't understand a word of your conversation with marmot. – JouleV Apr 23 at 9:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.