3

The example below work and looks ok. But I think about if there is a more elegant/generic/tikz way to manipulate the space between different chains.

Elegant here means, that it would be nice to specify the space between chains in a relative way. In this example I use explicite fixed values 2cm.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{chains}

\begin{document}
\begin{tikzpicture}
    [start chain=A going below,
     start chain=B going below,
     every node/.style=draw]

    \node at (0,0) {One};

    \node [on chain=A,right=2cm] at (1,0) {Two};
    \node [on chain=A] {\ldots};

    \node [on chain=B,right=4cm] at (2,0) {Three};
    \node [on chain=B] {\ldots};
\end{tikzpicture}
\end{document}

1 Answer 1

4

It is not really clear what you mean by a 'more elegant/generic/TikZ' approach here. Obviously, your code is TikZ.

It is recommended to use the positioning library rather than the older syntax, but I would probably just stick to using chains:

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{chains,scopes}
\begin{document}
\begin{tikzpicture}
  [
    start chain=main going right,
    every node/.style=draw
  ]

  \node [on chain] {One};
  \node [on chain] {Two};
  {[start branch=A going below]
    \node [on chain] {\ldots};
  }
  \node [on chain] {Three};
  {[start branch=B going below]
    \node [on chain] {\ldots};
  }
\end{tikzpicture}
\end{document}

branched chain

4
  • nested chains? nice.
    – buhtz
    Jan 24, 2016 at 15:00
  • How would you use positioning here?
    – buhtz
    Jan 24, 2016 at 15:00
  • btw: Line 6 and 7 could be deleted. Correct? My code works without them.
    – buhtz
    Jan 24, 2016 at 15:05
  • Oops. Yes, absolutely you don't need those. I just forgot to remove them. You can use positioning but the whole idea of chains is really that you don't have to specify explicitly where things are in relation to others but just the general direction.
    – cfr
    Jan 24, 2016 at 19:49

You must log in to answer this question.

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