I want to draw several tikz picture like these ones, but with different numbers of nodes in each row and arrows between the top and bottom row between different nodes.
e.g
and
etc.
I want to create a macro, that I can reuse for every drawing. For example that is parametrized with 3 lists, 2 lists listing the nodes in the top and bottom rows e.g. [h_0,h_1,h_2], [h'_0,h'_1] and one that is a list of pairs [(h_0,h'_0), (h_2,h'_1)] - so the macro will draw the two chains and then draw an arrow between the node in the top row and the node in the bottom row for each of the given pairs.
I am quite a Latex beginner and I am unsure really where to start or what is a reasonable way in Latex to approach this sort of parametrization and iteration.
This is the markup I used to draw the above diagram:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,chains,scopes}
\begin{document}
\begin{tikzpicture}
{[node distance=0.4cm,
start chain=going right,
every join/.style=->]
\node [on chain] (start) {$h_0$};
\node [on chain,join] {$h_1$};
\node [on chain,join] {$h_2$};
\node [on chain,join] (C1) {$h_3$};
\node [on chain, below=1cm of start] (start) {$h_0'$};
\node [on chain,join] {$h_1'$};
\node [on chain,join] {$h_2'$};
\node [on chain,join] {$h_3'$};
\node [on chain,join] (C2) {$h_4'$};
\draw[thick,<->] (C1.south east)--(C2.north west);
}
\end{tikzpicture}
\end{document}

\edefs are basically there so that you can use\twoStoryChainwith a prepared list stored in another macro (i.e.\twoStoryChain{\myFirstRow}{\mySecondRow}{I-0/II-3}). If you do not want/need this, you can replace the\qrr…macros in the for-each loops with{#1},{#2}and{#3}accordingly. Note that using non-expandable macros for the elements (for example\mathrm) will break this algorithm twice: Firstly in the\edefpart (which can be avoided, see above), then when it is used as part of the node name. – Qrrbrbirlbel Feb 23 '13 at 15:02