TikZ doesn't name your nodes by their contents so you can't refer to the nodes as 1,2,3,4,5,n,n+1. Rather you have to refer to them by their position, so you want the 2nd, 3rd, 4th (etc) nodes across. You also only need to iterate over the columns since you're doing one thing to each column and not doing anything on a per-row basis.
\documentclass{article}
%\url{http://tex.stackexchange.com/q/303682/86}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix[matrix of math nodes,row sep=1cm,column sep=.5cm] (m)
{
N: & 1 & 2 & 3 & 4 &\ldots &n-1 &n \\
N':& 2 & 3 & 4 & 5 &\ldots &n & n+1 \\
};
\foreach \x in {2,3,4,5,7,8} {
\draw[<->] (m-1-\x) -- (m-2-\x);
}
\end{tikzpicture}
\end{document}
As all your nodes are actually maths, you can use matrix of math nodes
. I also spaced out the columns a little.
(I lied a little. You can get TikZ to name the nodes whatever you like. However, in this case I think that using the positions is as simple a naming scheme as any.)
Here is a tikz-cd
solution
\documentclass{article}
\usepackage{tikz-cd}
\newcommand{\e}{\varepsilon}
\begin{document}
\begin{tikzcd}[column sep=1.5cm, cells={nodes={draw, circle, inner sep=.5mm}}]
|[draw=none]|\arrow[r] & q_0\arrow[r,"{a,\e\to a}"] & q_1\arrow[r,"{\e,\e\to\e}"]\arrow[<-,loop above,"{a,\e\to a}"]
& q_2\arrow[r,"{\e,\e\to\e}"]\arrow[<-,loop above,"{b,\e\to\e}"] & q_3\arrow[r,"{c,a\to\e}"]
& q_4\arrow[r,"{c,\e\to\e}"] & |[double]|q_5\arrow[ll, bend right,"{\e,\e\to\e}"']
\end{tikzcd}
\end{document}
Best Answer
I don't know too much about security protocols but
tikzpeople
package has been designed by its author Nils Fleischhacker with this intention:There's no
devil
figure, but there existevil
option which can provide funny results: