[Tex/LaTex] TikZ chains etc: modify automatic node placement

positioningtikz-chainstikz-pgf

I’m trying to draw a chain, roughly like:

crooked chain

The catch: I want to manually specify the vertical placement of node C, but I still want to use TikZ’s default horizontal placement. Currently, I can only work out how to have the placement of C either completely automatic, or completely manual.

MWE code for the above:

\documentclass{minimal}
\usepackage{tikz} \usetikzlibrary{chains,positioning,scopes}
\begin{document}

\begin{tikzpicture} [start chain=going right,
                     every on chain/.style=join,
                     every join/.style=->]
\node [on chain] {$A$};
\node [on chain] {$B$};
\node [on chain=going below right] {$C$};
\node [on chain] {$D$}; 
\end{tikzpicture}

\end{document}

(I also want to do the same thing with vertical and horizontal interchanged, but I guess the same solution should probably do this as well.)

Best Answer

You can adjust the vertical position by adding a yshift=<distance> key (the horizontal position is adjusted using xshift):

\documentclass{minimal}
\usepackage{tikz} \usetikzlibrary{chains,positioning,scopes}
\begin{document}

\begin{tikzpicture} [start chain=going right,
                     every on chain/.style=join,
                     every join/.style=->]
\node [on chain] {$A$};
\node [on chain] {$B$};
\node [on chain,yshift=-0.5cm] {$C$};
\node [on chain,yshift=1cm] {$D$}; 

\end{tikzpicture}
\end{document}

chain with manual vertical positioning