7

How can I display an arrow between two tikzpictures (of the same size) so that the arrow is alligned with the centre of the pictures?

\documentclass{article}
\usepackage{tikz}
\begin{document}


\begin{tikzpicture}[
  tlabel/.style={pos=0.4,right=-1pt},
]
\node{$\Rightarrow$}
child {node {$\wedge$}
child {node {$p$}}
child {node {$q$}}}
child {node {$r$}}
;
\end{tikzpicture}

 $\rightarrow$ % the arrow between the pictures

\begin{tikzpicture}[
  tlabel/.style={pos=0.4,right=-1pt},
]
\node{$\Rightarrow$}
child {node {$\wedge$}
child {node {$p$}}
child {node {$q$}}}
child {node {$r$}}
;
\end{tikzpicture}

\end{document}
1

1 Answer 1

3

Do you want something like this?

arrow between

This uses the baseline key with the value (current bounding box.center) to align the centres of the pictures with the current baseline.

\documentclass{article}
\usepackage{tikz}
\begin{document}
  \begin{tikzpicture}[
    tlabel/.style={pos=0.4,right=-1pt},
    baseline=(current bounding box.center)
    ]
    \node{$\Rightarrow$}
    child {node {$\wedge$}
      child {node {$p$}}
      child {node {$q$}}}
    child {node {$r$}}
    ;
  \end{tikzpicture}
  $\rightarrow$ % the arrow between the pictures
  \begin{tikzpicture}[
    tlabel/.style={pos=0.4,right=-1pt},
    baseline=(current bounding box.center)
    ]
    \node{$\Rightarrow$}
    child {node {$\wedge$}
      child {node {$p$}}
      child {node {$q$}}}
    child {node {$r$}}
    ;
  \end{tikzpicture}
\end{document}

If you are drawing trees, you should consider one of the specialised libraries or packages as they offer greater power and flexibility and, in many cases, a syntax which allows you to specify a tree much more concisely.

Packages include forest (based on TikZ), tikz-qtree (obviously TikZ-based), qtree (non-TikZ) and the TikZ library trees (much less powerful and does not support specialised syntax).

2
  • That's exactly what I want, thanks! I tried some tree packages but they didn't display the trees how I want. I only need to draw a few simple trees and tikz seems fine for that.
    – mmgro27
    Aug 9, 2015 at 22:03
  • @notnek Certainly if it works for you, there is no need to fix it ;).
    – cfr
    Aug 9, 2015 at 22:39

You must log in to answer this question.

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