5

The xshift in the following figure breaks the bounding box:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{scopes}
\usetikzlibrary{chains}
\usetikzlibrary{backgrounds} % used only for testing with "framed"

\newcommand{\parlistrdeepseq}{
  \begin{tikzpicture}
    [start chain=going below, 
     every on chain/.append style={join},
     every join/.style={->},
     framed]

     \node[on chain] { map f (28:28:28:28:[]) };
     \node(x1)[on chain] { f 28 : (map f (28:28:28:[])) };
     % \node(y1)[below=of \tikzchainprevious.south, xshift=-3cm] {|f 28|};
     { [start chain=t1 going below]
       \node(y1)[on chain, left=of x1, yshift=-1cm] {f 28};
       \node[on chain] {514229};
       \path (x1.south west) edge[->] (y1);
     }
     \node(x2)[on chain] {  y : f 28 : (map f (28:28:[])) };
     { [start chain=t2 going below, transform canvas={xshift=1cm}]
       \node(y2)[on chain, left=of x2, yshift=-1cm] {f 28};
       \node[on chain] {514229};
       \path (x2.south west) edge[->] (y2);
     }
     \node[on chain] {  y : y : y : y []};
   \end{tikzpicture}}

\begin{document}
\parlistrdeepseq
\end{document}

The output with the wrong bounding box is: enter image description here

6

It's not the xshift, it's the transform canvas that causes this behaviour. As it says in the pgfmanual:

when you use canvas transformations pgf loses track of positions of nodes and of picture sizes since it does not take the effect of canvas transformations into account when it computes coordinates of nodes

You should put the xshift into the options for the y2 node instead:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{scopes}
\usetikzlibrary{chains}
\usetikzlibrary{backgrounds} % used only for testing with "framed"

\newcommand{\parlistrdeepseq}{
  \begin{tikzpicture}
    [start chain=going below, 
     every on chain/.append style={join},
     every join/.style={->},
     framed]

     \node[on chain] { map f (28:28:28:28:[]) };
     \node(x1)[on chain] { f 28 : (map f (28:28:28:[])) };
     % \node(y1)[below=of \tikzchainprevious.south, xshift=-3cm] {|f 28|};
     { [start chain=t1 going below]
       \node(y1)[on chain, left=of x1, yshift=-1cm] {f 28};
       \node[on chain] {514229};
       \path (x1.south west) edge[->] (y1);
     }
     \node(x2)[on chain] {  y : f 28 : (map f (28:28:[])) };
     { [start chain=t2 going below]
       \node(y2)[on chain, left=of x2, xshift=1cm, yshift=-1cm] {f 28};
       \node[on chain] {514229};
       \path (x2.south west) edge[->] (y2);
     }
     \node[on chain] {  y : y : y : y []};
   \end{tikzpicture}}

\begin{document}
\parlistrdeepseq
\end{document}
  • But that doesn't translate the edge going out of y:f 28:.... The edge pointing to y2 is supposed to start from the f 28 part of x2. But, with one additional change to the definition of the edge from x2 to y2, it works! The new definition is: \path ($(x2.south west) + (1cm, 0)$) edge[->] (y2); (using the calc library) – Cactus Oct 23 '11 at 5:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.