I have two tikzpictures
:
\documentclass{article}
\usepackage{tikz}
\usepackage{subcaption}
\usetikzlibrary{shapes,arrows}
\begin{document}
\pagestyle{empty}
\tikzstyle{notarget} = [rectangle, rounded corners, minimum
width=1cm, minimum height=1cm,text centered, draw=none,
opacity=0,text opacity=1,align=center]
\tikzstyle{target} = [rectangle, rounded corners, minimum width=1cm, minimum
height=1cm,text centered, draw=black, very thick,text
opacity=1,align=center]
\begin{figure}[ht]
\centering
\begin{subfigure}[b]{0.3\textwidth}
\begin{tikzpicture}[node distance=1.2cm]
\node (n1) [notarget] {I\\PRP};
\node (n2) [notarget, right of=n1] {saw\\VBD};
\node (n3) [target, right of=n2] {a\\DT};
\node (n4) [target, right of=n3] {girl\\NN};
% \draw [thick,->] (n4) -- ++(1cm,0);
\end{tikzpicture}
\caption{}
\end{subfigure}
\qquad\qquad
\centering
\begin{subfigure}[b]{0.3\textwidth}
\begin{tikzpicture}[node distance=1.2cm]
\node (n1) [notarget] {I\\PRP};
\node (n2) [notarget, right of=n1] {saw\\VBD};
\node (n3) [target, right of=n2] {a\\DT};
\node (n4) [target, below of=n3,anchor=north] {girl\\NN};
\draw [thick,->] (n4) -- (n3);
\end{tikzpicture}
\caption{}
\end{subfigure}
\label{fig:rightaction}
\end{figure}
\end{document}
But I do not know how to align the to figures vertically, currently it shows like this:
I would like to align it like this:
I have tried the following answers, without success:
- cannot figure out how to produce some tikz pictures next to each other
- Inline TikZ - vertical centering
- How to make a tikz node, top-aligned with the rest of the text?
UPDATE
I get it working with the help of Guilherme, here is:
\begin{figure}[ht]
\centering
\begin{subfigure}[b]{0.4\textwidth}
\begin{tikzpicture}[node distance=2mm]
\node (n1) [notarget] {I\\PRP};
\node (n2) [notarget, right=of n1] {saw\\VBD};
\node (n3) [target, right=of n2] {a\\DT};
\node (n4) [target, right=of n3] {girl\\NN};
\node (n4') [target, right=of n4,draw=none,anchor=west] {};
\node (n5') [target, below=5mm of n4',anchor=north,draw=none] {};
\draw [thick,->] (n5'.center) -- ++(5mm,0);
\end{tikzpicture}
\caption{}
\end{subfigure}
\qquad\qquad
\centering
\begin{subfigure}[b]{0.4\textwidth}
\begin{tikzpicture}[node distance=2mm]
\node (n1) [notarget] {I\\PRP};
\node (n2) [notarget, right=of n1] {saw\\VBD};
\node (nn) [notarget,draw=none,right=of n2] {};
\node (n3) [target, right=of nn] {girl\\NN};
\node (n4) [target, below=5mm of n3] {a\\DT};
\draw [thick,->] (n4) -- (n3);
\end{tikzpicture}
\caption{}
\end{subfigure}
\end{figure}
UPDATE 2
Finally I've used gemot's solution:
\begin{figure}[ht]
\centering
\begin{tabular}{p{0.4\textwidth}cp{0.4\textwidth}}
\begin{tikzpicture}[node distance=2mm,baseline=(n3)]
\node (n1) [notarget] {I\\PRP};
\node (n2) [notarget, right=of n1] {saw\\VBD};
\node (n3) [target, right=of n2] {a\\DT};
\node (n4) [target, right=of n3] {girl\\NN};
\end{tikzpicture}
&
\tikz\draw [thick,->] (0,0) -- ++(.5cm,0);
&
\begin{tikzpicture}[node distance=2mm,baseline=(n3)]
\node (n1) [notarget] {I\\PRP};
\node (n2) [notarget, right=of n1] {saw\\VBD};
\node (n3) [target, right=of n2] {a\\DT};
\node (n4) [target, below=5mm of n3,anchor=north] {girl\\NN};
\draw [thick,->] (n4) -- (n3);
\end{tikzpicture}
\\
\subcaption{}
&&
\subcaption{}
\end{tabular}
\label{fig:rightaction}
\end{figure}
\tikzmark
(many examples on this site) to mark an alignment point in the first picture and use that in the second picture to do the alignment. This will require two consiecutive runs ofpdflatex
. – Peter Grill Dec 8 '16 at 6:24tikzmark
now, thanks, – ElBaulP Dec 8 '16 at 6:34