# Error with cleveref + enumerate + tikz-qtree

I get an error in my document in the following circumstance:

1. Using the cleveref package
2. And the tikz-qtree package (for drawing syntax trees)
3. Inside an enumerate environment

Here's a MWE:

\documentclass{article}

%\usepackage{cleveref} %Uncomment for crash

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

\begin{document}

\begin{enumerate}
\item foo
\begin{tikzpicture}
\Tree [.Foo Bar ]
\end{tikzpicture}
\end{enumerate}

\end{document}


Here's a link to the log that running that file (with cleveref uncommented) generates: log file. The first error is:

! Package tikz Error: A node must have a (possibly empty) label text.


I've verified the following things:

• It is not a catcode problem, i.e. the catcode of . and [ is 12 both with and without loading cleveref
• The problem goes away if the tree is not embedded in an enumerate, i.e. delete the entire document body and replace it with only the \begin{tikzpicture}...\end{tikzpicture}
• The problem goes away if you change the enumerate to itemize

I tried running the example with \traceon from the trace package, but got mired in the half-million(!) lines of output.

Based on the esoteric combination of packages, I'm not sure a ready answer exists, but hopefully there is a TeX guru out there familiar with the guts of these packages who sees something I cannot.

-
It also fails with the gb4e and linguex examples. So this is something quite general with lists. –  Alan Munn Mar 15 '11 at 2:06
This question has been upvoted enough times that it looks like it deserves an answer, so I've offered a bounty on it. Most upvoted answer this time next week gets it. –  Seamus Mar 21 '11 at 15:05
@Seamus Thanks for adding the bounty to this question -- it looks like it was just what was needed to smoke out the answer. As far as I understand, if I accept Ulrich's answer, he will get the bounty. You mentioned waiting a week, but consensus seems to be that his answer is deserving. Any objections if I go ahead and accept it? –  Aaron Mar 23 '11 at 18:56
I'm not sure whether accepting the answer will trigger the bounty, since it wasn't offered by the asker. But I'm perfectly happy for Ulrich to get the bounty so go ahead and accept! –  Seamus Mar 23 '11 at 19:01

My money is on a name clash of \@result. There's a suspicious

\@call #1#2->\let \@cont =#2\bgroup \@result ={}#1
#1<-\@subtree
#2<-\@Tree
{\let}
{begin-group character {}

\@result ->
{the character =}
Missing character: There is no = in font nullfont!
{begin-group character {}
{end-group character }}


in the log. Without having checked right now, I conjecture that TikZ has a token register of that name, while cleveref uses it as a macro.

-
\@result is the problem but not in TikZ but in tikz-qtree and in cleveref –  Alain Matthes Mar 21 '11 at 19:17
Sadly, grep -rl '\\@result' reveals nothing in the PGF directories (and all the results of grep -r @result are normal so there's no apparent \csname trickery). Though not knowing much of the mysteries of TeX, could it be encoded in some weird way? –  Andrew Stacey Mar 21 '11 at 19:22
Ah, yes. As Altermundus says, line 30 of tikz-qtree.sty reads \newtoks\@result. That should be easy to patch. I guess that both packages should choose better names! –  Andrew Stacey Mar 21 '11 at 19:24
Ulrich should get the bounty. I'm annoyed that I missed this when I looked into this last week! Changing all instances of \@result to \tkqt@result fixes the problem. I'm in contact with the author of tikz-qtree, so I'll send a fix along to him. –  Alan Munn Mar 21 '11 at 19:25
I've notified the authors of both packages. –  Alan Munn Mar 21 '11 at 19:35
in tikz-qtree.tex you can replace \@result by \qt@result