TiKz chain is amazing tool,I am reading Chains with labeled edges example.

This example use matrix to place nodes, then use chain to connect it together. it's fine of course but I am thinking about if we can just place the nodes and then the chain will connect it automatically.

So I just write a simple example:


\tikzset{join/.code=\tikzset{after node path={%
edge[every join]#1(\tikzchaincurrent)\fi}}}
\tikzset{>=stealth',every on chain/.append style={join},
         every join/.style={->}}
\tikzstyle{labeled}=[execute at begin node=$\scriptstyle,
   execute at end node=$]

   \node (A) {A};
   \node [right=of A] (B) {B};
  { [start chain] \chainin (A);
    \chainin (B) [join={node[above,labeled] {\eta_1}}];;

enter image description here

It works perfect now but I am wondering if we can combine the node statements with the draw statement together. Maybe looks like below (it doesn't work of course now)!

  { [start chain] \chainin \node (A) {A};;
    \chainin \node [right=of A] (B) {B}; [join={node[above,labeled] {\eta_1}}];;

Is it possible to make it work?

1 Answer 1


You can simply say on chain to make a node joined to a chain. And also with TikZ v3.00 it is easier to add labels to edges.

{[start chain]
   \node[on chain] (A) {A};
   \node[on chain,join=by {->,"$\eta_1$"},right=of A] (B) {B};
   \node[on chain,join=by {<-,"$\eta_2$"},right=of B] (C) {C};
   \node[on chain,join=by {bend left,->,"$\int dx$"},right=of C] (D) {D};

enter image description here

  • Great, so the example should be changed to use TiKz 3.00. :-).
    – Beatlej
    Mar 13, 2015 at 19:40
  • @Beatlej Not necessarily. With that example it works pretty OK. Note that it is from 2011 so allow for some decay
    – percusse
    Mar 13, 2015 at 20:52

You must log in to answer this question.

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