# I'm getting the error: ! Paragraph ended before \@@label was complete

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}


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}

-
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

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}


-
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 '14 at 20:37

forest allows you to draw trees using a slightly more intuitive syntax, I think:

• no need to leave spaces before the closing bracket, although it isn't a problem if you do so, either;

• no need to preface a new sub-tree with a dot - just use brackets with nesting to represent the tree structure;

• no need to explicitly make things TikZ nodes in order to name them - all nodes are TikZ nodes and can be given a name using name= and, if necessary, extra names using alias=.

In the following code, I've also used a phantom node in order to move the bottom left node outwards, so that the connection between abelian groups and class 5 is displayed more naturally.

\documentclass[tikz, border=5pt, varwidth, multi]{standalone}
\usepackage{forest}

\begin{document}
\begin{forest}
for tree={
parent anchor=south,
child anchor=north,
}
[Boolean Groups
[Abelian Groups, name=abelian groups
[Groups]
[, phantom]
]
[Class 3
[Class 5, name=class 5]
[Class 1]
[Class 2]
[Class 4]
]
]
\draw (abelian groups.south) -- (class 5);
\end{forest}
\end{document}


-