The LaTeX code


causes in latex and pdflatex the mysterious error "Two \documentclass or \documentstyle commands." Why??? Not actually two \documentclass like in the (original) question \documentclass{tikz-qtree} Error Two \documentclass or \documentstyle commands.

Probably irrelevant, but I'm using texlive (2018 version) in a Debian system.

The .log as asked by moewe: https://pastebin.com/BGcHs3Rz.

Answering other comment: the filename is psttest.tex.

  • Welcome to TeX.SX! For me the code works fine (as it should)... I'm also using TeXLive 2018, so I guess there is something else causing that problem. The error message should show in which line the problem happened. Can you show us the log, please? Mar 21, 2019 at 14:10
  • Can you share the full .log file of the LaTeX run on that file? If it is too long to be shared here, you can upload it to a text-sharing website like pastebin.com
    – moewe
    Mar 21, 2019 at 14:11
  • 3
    Do NOT call your document article.tex
    – Johannes_B
    Mar 21, 2019 at 14:15
  • 1
    In situations like this a look at the .log file should tell us which file is problematic. And even if this was not the cause of the error, the .log file can give us vital information about what went wrong because it will contain the full error message with line numbers.
    – moewe
    Mar 21, 2019 at 14:22
  • 5
    As Johannes guessed: You have a file called pstricks.tex in the same folder as this file. But pstricks is the name of a package you load. TeX picks up the wrong file and chaos ensues. Rename pstricks.tex and you should be good.
    – moewe
    Mar 21, 2019 at 14:25

1 Answer 1


The crucial piece of information to understand this error is the line in the .log before the actual error message starts. It reads


! LaTeX Error: Two \documentclass or \documentstyle commands.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.

l.1 \documentclass[12pt]{
! Emergency stop.

l.1 \documentclass[12pt]{
The document may only declare one class.

The (./pstricks.tex means that TeX has opened a file called ./pstricks.tex (i.e. a file in the same directory as your main TeX file called pstricks.tex). As soon as that file is loaded the error occurs in the \documentclass in line 1.

A part of the code of the package pstricks lives in a file called pstricks.tex and that file is loaded by the package. (pstricks.sty has the line \input{pstricks}%, which reads pstricks.tex.)

The way TeX loads files means that files in your current working directory are given preference over files installed by your TeX distribution. In general that is a very useful feature because you can easily override some things locally without changing system files.

But in this case that means that a totally unrelated file called pstricks.tex in the document directory is loaded instead of the package code in pstricks.tex.

The easiest way to avoid that is by renaming your local file to something other than pstricks.tex. In general you should avoid giving files the same name as a class or package, but you can never be entirely sure which names are problematic as packages could load additional .tex files with different names. The only way to be sure is by checking the .log thoroughly if similar issues occur.

Note that the error might have been much more cryptic and might have occurred at a different stage if your pstricks.tex had not contained a \documentclass, for example if it had been only a chapter of your paper that you load in a bigger document with \input or \include.

This is what Johannes_B hinted at in his comment

Do NOT call your document article.tex

Though, incidentally, acrticle.tex would have probably been fine, since article.cls does not attempt to load article.tex.

A similar issue was discussed a few days ago in the German goLaTeX forum https://golatex.de/markdown-in-latex-einbinden-t21651.html where the issue appeared with the markdown package, which loads markdown.tex, when a user called their document Markdown.tex (on a Windows system, which is case insensitive).


You must log in to answer this question.

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