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.

This is a pretty minor gripe with what is a great library.

\documentclass[border=3em]{standalone}
\usepackage{tikz}
\usetikzlibrary{trees}
\begin{document}
\begin{tikzpicture}[grow=right]
  \node {a}
    child {
      node {b}
    }
    child{
      node {c}
    };
\end{tikzpicture}
\end{document}

This MWE produces the following output:

tree upside down

Note that despite the b node being written before the c node, it is the c node that is on top. This is unintuitive. I'd have expected the b node to be on top, since it's defined first.

I understand why it works that way because without the grow=right option, things are typeset in the obvious order. What I want to know is:

Is there an easy way to have right-growing trees set their nodes in the order you'd expect from reading the source?


Edit

Matthew's suggestion in the comments works well for basic trees. Unfortunately, it breaks the sloped option:

\documentclass[border=3em]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\begin{tikzpicture}[grow=right,yscale=-1,sloped]
  \node {a}
    child {
      node {b}
      edge from parent
      node[above] {Foo}
    }
    child{
      node {c}
    };
\end{tikzpicture}
\end{tikzpicture}
\end{document}

slope is broke

share|improve this question
1  
\node[yscale=-1] ? –  Matthew Leingang May 19 '11 at 14:29
    
@Matthew Nope. That turns the node upside down and leaves its children in the wrong order still. –  Seamus May 19 '11 at 15:43
    
@Matthew ah, as an option to the tikzpicture environment that works. Not as an option on the node –  Seamus May 19 '11 at 15:45
    
That was why I put the question mark and made it a comment—a stab in the dark to test. –  Matthew Leingang May 19 '11 at 17:48

1 Answer 1

up vote 8 down vote accepted

You simply can use the grow' option instead: (pgfmanual v2.10, p.219)

This key has the same effect as grow, only the children are arranged in the opposite order.

\documentclass[border=0,png]{standalone}
\usepackage{tikz}
\usetikzlibrary{trees}
\begin{document}
\begin{tikzpicture}[grow'=right]
  \node {a}
    child {
      node {b}
    }
    child{
      node {c}
    };
\end{tikzpicture}
\end{document}

Result

share|improve this answer
    
how do you get your standalone images to be bigger? I tried that and they come out really small. I cheated and zoomed in the PDF and took a screen shot of it to get the picture a reasonable size! –  Seamus May 19 '11 at 17:00
1  
@Seamus: With the current develop version it is convert={size=<X>x<Y>,...} or shorter png={size=<X>x<Y>}. I also have a tex.sx option to set the maximum size of 630px. Everything above is zoomed down on stackexchange. –  Martin Scharrer May 19 '11 at 17:06
    
@Seamus: helps to be the developer :-P –  Matthew Leingang May 19 '11 at 17:48
    
and for us mere mortals that have the version on CTAN, when will we get these options? ;) –  Seamus May 19 '11 at 23:01
    
@Seamus: Hopefully soon. However, the develop version is available under latex.scharrer-online.de/standalone/browser/dev. Also try the "nightly builds" listed on latex.scharrer-online.de/standalone. –  Martin Scharrer May 20 '11 at 0:16

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.