Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 6 down vote accepted

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}
share|improve this answer
    
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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