3

Is it possible to have a brace defined (with the snakes library) using as reference points 2 nodes in 2 different tikzpictures?

    \begin{tikzpicture}[scale=.6]
        \draw[draw=black, fill=black!20!white] (0,0) grid (4,3) rectangle (0,0);
        \draw[fill=green](1.5,0.5) circle [radius=.3];
        \draw[fill=blue] (0.5, 1.5) circle [radius=.3];
        \draw[fill=purple](1.5, 2.5) circle [radius=.3];

        \node (Bone) at (4,3) {};
    \end{tikzpicture}

    \begin{tikzpicture}[scale=.6]
        \draw[draw=black, fill=black!20!white] (0,0) grid (4,3) rectangle (0,0);
        \draw[fill=blue](1.5,0.5) circle [radius=.3];
        \draw[fill=green] (0.5, 1.5) circle [radius=.3];
        \draw[fill=purple](1.5, 2.5) circle [radius=.3];

        \node (Btwo) at (4,0) {};
    \end{tikzpicture}

I'd like to make a brace that started at 'Bone' and ended at 'Btwo'.

Remark: I'm pretty new to TikZ, so even what I'm trying to do here (in my MWE) may have a much simpler way to do it. Any suggestion would be great :)

  • Read *16.13 Referencing Nodes Outside the Current Pictures * on Tikz user guide. – Sigur Nov 17 '13 at 12:07
6

Use the remember picture option on both figures and then insert a third one with overlay option to connect them.

Note the use of the decorations.pathreplacing library and the changing of node's anchors to adjust the position of the brace. Also you can control the distance of the brace using the option raise=5pt.

\documentclass{report}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}

\begin{document}
\begin{tikzpicture}[scale=.6,remember picture]
    \draw[draw=black, fill=black!20!white] (0,0) grid (4,3) rectangle (0,0);
    \draw[fill=green](1.5,0.5) circle [radius=.3];
    \draw[fill=blue] (0.5, 1.5) circle [radius=.3];
    \draw[fill=purple](1.5, 2.5) circle [radius=.3];
    \node (Bone) at (4,3) {};
\end{tikzpicture}

\begin{tikzpicture}[scale=.6,remember picture]
    \draw[draw=black, fill=black!20!white] (0,0) grid (4,3) rectangle (0,0);
    \draw[fill=blue](1.5,0.5) circle [radius=.3];
    \draw[fill=green] (0.5, 1.5) circle [radius=.3];
    \draw[fill=purple](1.5, 2.5) circle [radius=.3];
    \node (Btwo) at (4,0) {};
\end{tikzpicture}

\begin{tikzpicture}[remember picture,overlay,decoration={brace,raise=5pt}]
    \draw[decorate] (Bone.east) -- (Btwo.east);
\end{tikzpicture}

\end{document}

enter image description here

Use \draw[decorate] (Bone.center) -- (Btwo.center); to connect the center of the nodes.

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.