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.

There is a comment between two child nodes down below, that if removed would cause tree to render completely wrong. Why?

\documentclass[10pt]{article}
\usepackage{tikz}
\usetikzlibrary{trees}
\tikzstyle{every node}=[draw=black, thin, minimum height=3em]

\begin{document}
\footnotesize
\begin{tikzpicture}[
    supervisor/.style={%
        text centered, text width=12em,
        text=black
    },
    teammate/.style={%
        text centered, text width=12em,
        text=black
    },
    subordinate/.style={%
        grow=down,
        xshift=-3.2em, % Horizontal position of the child node
        text centered, text width=12em,
        edge from parent path={(\tikzparentnode.205) |- (\tikzchildnode.west)}
    },
    level1/.style ={level distance=4em,anchor=west},
    level2/.style ={level distance=8em,anchor=west},
    level3/.style ={level distance=12em,anchor=west},
    level4/.style ={level distance=16em,anchor=west},
    level 1/.style={%
        edge from parent fork down,
        sibling distance=14em,
        level distance=5em
    }
]
    \node[anchor=south,supervisor](super){Supervisor\\Supervisory position\\Location}[]

    child{node [teammate] {Teammate6\\Position4\\Location4}
        child[subordinate,level1] {node {Subordinate1}}
        child[subordinate,level2] {node {Subordinate2}}}
    % - why is this comment required for proper rendering of the tree???
    child{node [teammate] {Teammate7\\Position5\\Location5}
        child[subordinate,level1] {node {First\\Subordinate}}
        child[subordinate,level2] {node {Subordinate2}}
        child[subordinate,level3] {node {Third\\Teammate}}
        child[subordinate,level4] {node {Longtext-\\teammate}}};

\end{tikzpicture}

\end{document}

With a comment:

enter image description here

Without a comment:

enter image description here

share|improve this question
3  
I'm actually quite surprised that it even works. You're in general not allowed to have empty lines inside \node ... ;, since empty line is transformed into \par and that can cause troubles. –  yo' Feb 14 at 14:35
    
You can make that an answer! –  ajeh Feb 14 at 14:37

1 Answer 1

up vote 8 down vote accepted

Well, in general, you are not allowed to have empty lines inside \node ... ; or \coordinate ... ; or \draw ... ; or such. The reason is that empty line isn't just a whitespace that is easily trimmed, it transforms into a \par, which can cause a mess in such places.

So It's actually a bit of a surprise that the code compiles with those empty lines. It's certainly better to avoid them: either remove them completely, or at least add %, which "eats everything until the next end-of-line including this end-of-line", so no \par is generated.

share|improve this answer

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.