Probably got some obvious error

\usepackage{tikz-qtree} % <- this wont work




Latex Error: Two \documentclass or \documentstyle commands.

on several editors whatsoever.

Got 2013.20140215-1 texlive-pictures installed. Adding \usepackage{tikz} doesn't help.

Probably I am missing something obvious. Do you have any suggestions?

  • 1
    Welcome. \usepackage{tikz-qtree}. It is a package not a class. Your document can have only one class but many packages!
    – cfr
    Commented Jun 19, 2015 at 20:49
  • The posted document runs without error. If you get an error from that post the full log. Commented Jun 19, 2015 at 20:57
  • @DavidCarlisle The original had \documentclass{tikz-qtree} but it is edited away within the 5 mins so no longer makes sense.
    – cfr
    Commented Jun 19, 2015 at 20:59
  • 1
    @cfr my guess would be OP has while editing saved a document as tikz-qtree.sty so gets the error but would need to see the log... Commented Jun 19, 2015 at 21:11
  • 1
    @DavidCarlisle This is almost certainly correct, since tikz-qtree is a wrapper for tikz-qtree.tex.
    – Alan Munn
    Commented Jun 19, 2015 at 22:22

1 Answer 1


Originally, you had


A LaTeX document can only have one class as the error says. But you can also load packages to extend the functionality of the class. tikz-qtree is not a document class at all: it is a package. So, you want:



After correcting the problem above, you continued to report the same error. This was somewhat puzzling but AlanMunn held the key to this mystery.

As explained by AlanMunn in comments, the package tikz-qtree loads a code file named tikz-qtree.tex. Because your document was itself called tikz-qtree.tex, LaTeX tried to read the document a second time when the package called the code file.

This happens because files in the current directory take precedence over those elsewhere, so LaTeX read your document tikz-qtree.tex rather than the code file tikz-qtree.tex.

Hence, it really did get two \documentclass commands as input - they just both happened to be from the single instance in your document.

I don't know if there is a moral to this story other than that AlanMunn knows everything there is to know about packages which draw trees, but at least it dispels the mystery.

  • Yes, I am just unsure why this produces that kind of error and how to fix this, because I'd like to use that package
    – sams2
    Commented Jun 19, 2015 at 20:54
  • @sams2 Originally, you had 2 \documentclass commands. That caused that error. You shouldn't get that error now you've changed the second, tikz-qtree, one to \usepackage.
    – cfr
    Commented Jun 19, 2015 at 20:57
  • Even <code> \documentclass{article} \usepackage{tikz-qtree} \begin{document} \end{document} </code> produces the same error
    – sams2
    Commented Jun 19, 2015 at 21:00
  • @sams2 It shouldn't. It doesn't for me. As David says, if it does for you, we need the log.
    – cfr
    Commented Jun 19, 2015 at 21:01
  • 3
    @sam2 The subsequent problem arose because your test file was named tikz-qtree.tex which is also the name of the code file that the tikz-qtree package uses. This is not something you could have easily forseen.
    – Alan Munn
    Commented Jun 19, 2015 at 22:34

Not the answer you're looking for? Browse other questions tagged .