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.

I've scoured this forum and it looks to me like I'm setting up the tree correctly, but I'm still getting this error, I have

\usepackage{tikz}
\usepackage{tikz-qtree}

in the header.

Here is the code that is causing the problem:

\begin{tikzpicture}

\Tree 
[.{Boolean Groups}
    [.{Abelian Groups}
        [.Groups]
    ]
    [.{Class 3} 
        [.{Class 5}]
        [.{Class 1}]
        [.{Class 2}]
        [.{Class 4}]
    ]
]

\end{tikzpicture}
share|improve this question
    
Welcome to TeX.sx! A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). –  egreg Jul 11 '12 at 21:24

1 Answer 1

Get used to this error, it's a common one with tikz-qtree: tikz-qtree requires a space before a node's contents and its closing ]. So you need to insert some spaces before each ] in your tree.

\Tree 
[.{Boolean Groups}
    [.{Abelian Groups}
        [.Groups ] % Here
    ]
    [.{Class 3} 
        [.{Class 5} ] % Here etc.
        [.{Class 1} ]
        [.{Class 2} ]
        [.{Class 4} ]
    ]
]

If you need to connect particular nodes in the tree with each other, you can add explicit \node commands and then use regular TikZ drawing commands to connect them. To connect 'Abelian Groups' to 'Class 5' make them each nodes:

\documentclass{article}
\usepackage{tikz-qtree}
\begin{document}

\begin{tikzpicture}

\Tree 
[.{Boolean Groups}
    [.\node (A) {Abelian Groups};
        [.Groups ]
    ]
    [.{Class 3} 
        [.\node (5) {Class 5}; ]
        [.{Class 1} ]
        [.{Class 2} ]
        [.{Class 4} ]
    ]
]
\draw (A) -- (5);
\end{tikzpicture}
\end{document}

output of code

share|improve this answer
    
Awesome thanks that worked, another question, right now I have a line from class 3 to class 5, is there an easy way to add a line from Abelian Groups to Class 5 as well. Most of the info I can find online makes it look like I have to make an arrow or some other thing that doesn't look like all the other lines. For example, I found this: tex.stackexchange.com/questions/59140/… but it looks to be more complicated than I need. Or is this the easiest way? –  Marco Jul 11 '12 at 21:47
    
@Marco See my update. –  Alan Munn Jul 11 '12 at 21:57
    
Wow great, thanks again! –  Marco Jul 11 '12 at 22:02
    
Definitely +1. This is fantastic. Spent at least 45 minutes trying to figure what I did wrong; this answer helped immensely. –  alexy13 Feb 8 at 20:37

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.