3

Probably got some obvious error

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

\usepackage[utf8]{inputenc}
\usepackage[german]{babel}
\usepackage[margin=0.5in]{geometry}

\begin{document}
\end{document}

produces

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?

Alan Munn
  • 218,180
sams2
  • 33
  • 1
  • 4
  • 1
    Welcome. \usepackage{tikz-qtree}. It is a package not a class. Your document can have only one class but many packages! – cfr Jun 19 '15 at 20:49
  • The posted document runs without error. If you get an error from that post the full log. – David Carlisle Jun 19 '15 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 Jun 19 '15 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... – David Carlisle Jun 19 '15 at 21:11
  • 1
    @DavidCarlisle This is almost certainly correct, since tikz-qtree is a wrapper for tikz-qtree.tex. – Alan Munn Jun 19 '15 at 22:22

1 Answers1

6

Originally, you had

\documentclass{article}
\documentclass{tikz-qtree}
...

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:

\documentclass{article}
\usepackage{tikz-qtree}
...

EDIT

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.

cfr
  • 198,882
  • 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 Jun 19 '15 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 Jun 19 '15 at 20:57
  • Even \documentclass{article} \usepackage{tikz-qtree} \begin{document} \end{document} produces the same error – sams2 Jun 19 '15 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 Jun 19 '15 at 21:01
  • logfile http://pastebin.com/zCccKxfP – sams2 Jun 19 '15 at 21:14
  • 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 Jun 19 '15 at 22:34
  • @AlanMunn You should answer but you can't. Should this be reopened? Or would you object if I added that information to my answer? – cfr Jun 19 '15 at 22:39
  • @cfr Just add it to your answer. I've encountered this problem before, and the log posted by the OP confirms it. But David had already suggested it too. There's no need for a separate answer, and in some sense it's a very peculiarly local problem. – Alan Munn Jun 19 '15 at 22:47
  • @AlanMunn Well, his suggestion was that the document was saved as .sty which is a bit different. The .tex complication is rather less obvious ;). – cfr Jun 19 '15 at 22:49
  • You're right. I read his comment too fast. – Alan Munn Jun 19 '15 at 22:52