4

I have two tikzpicture within a figure and I would like to place one tikz relatively to the other tikz nodes. I tried below of= with no success. The two tikz have different arrows and layouts. Here is the code where I need to place the second tikz under the ABC node.

    \begin{figure}[H]
    \centering
    \begin{tikzpicture}[node distance=4cm]
    \node (1){$ABC$};
    \node (2)[right of=1]{$CD$};
    \path (1) edge (2);
    \end{tikzpicture}

    \begin{tikzpicture}
    [->,>=stealth',shorten >=1pt,auto,node distance=1cm,semithick,scale=-.2]

    \node (236) {$236$};
    \node (136) [below left of=236]{$136$};
    \node (246) [below of=236]{$246$};
    \node (235) [below right of=236]{$235$};

    \path (236) edge (136)  edge (246) edge(235);

    \end{tikzpicture}

    \caption{Example}
    \label{example}
    \end{figure}

How can I place the second tikz under the first one's ABC node?

1
  • 2
    instead of doing two tikzpictures you should revert to one tikzpicture and two scopes which can be aligned accordingly. Much cleaner and much easier for TeX to align.
    – nickpapior
    Aug 22, 2013 at 10:51

1 Answer 1

6

Scopes are your friend here:

\documentclass[border=4pt]{standalone}
\usepackage{tikz}

\begin{document}

    \begin{tikzpicture}[node distance=4cm]
    \node (1){$ABC$};
    \node (2)[right of=1]{$CD$};
    \path (1) edge (2);
    \begin{scope} [below of = 1, yshift = 2.5cm, 
            ->,>=stealth,node distance=1cm,semithick,scale=-.2]
    \node (236) {$236$};
    \node (136) [below left of=236]{$136$};
    \node (246) [below of=236]{$246$};
    \node (235) [below right of=236]{$235$};
    \path (236) edge (136)  edge (246) edge(235);
    \end{scope}
    \end{tikzpicture}

\end{document}

positioning using scope

I included the yshift because it uses the outer node distance of 4cm, and it looked like too much space for my taste. You can remove that or adjust as necessary.

1
  • 1
    nice so each scope can be viewed as a tikzpicture by its own.
    – seteropere
    Aug 22, 2013 at 12:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .