I tried different versions of WinEdt and MiKTeX but every time I run the code find this error:

! LaTeX Error: Two \documentclass or \documentstyle commands. See the LaTeX manual or LaTeX Companion for explanation. Type H for immediate help. ...
l.450 \documentclass{ ltxdoc}

And as a result it could not create PDF file. I am a beginner and guess it should be about packages used there.

Thanks for comments, I am 100% sure that there is only one \documentclass and here is the list of packages used:


% IEEE Computer Society needs nocompress option
% requires cite.sty v4.0 or later (November 2003)
% normal IEEE

pdftitle={Bare Demo of IEEEtran.cls for Computer Society Journals},%   <!CHANGE!
pdfauthor={Michael D. Shell},%<!CHANGE!
pdfkeywords={Computer Society, IEEEtran, journal, LaTeX, paper,
\hyphenation{op-tical net-works semi-conduc-tor}

  • 5
    the most common reason for getting the error about two \documentclass commands is that you have two \documentclass commands and the fix is to remove one of them. If you show no code how can anyone help? Commented Jan 28, 2017 at 12:18
  • 3
    actually ltxdoc is only used for documenting packages, never in real documents, have you gone \input{somepackage.dtx} in your main file? Commented Jan 28, 2017 at 12:20
  • 2
    the posted code causes no error (other than a missing package keywords} I can only guess that you have saved some file abc.dtx as abc.sty (which would cause that error) Commented Jan 28, 2017 at 13:07
  • 3
    unrelated to the error but do not load kantlipsum in a real document and don't load epsfig in a document written since 1994 Commented Jan 28, 2017 at 13:10
  • 1
    @Schweinebacke @ DavidCharlisle OK, maybe I overreacted. I retracted by close vote, but MWE which do not show the problem are to me the one red rag of this site. They waste the time of all the great people here who try to help the OPs. Commented Jan 28, 2017 at 13:30

1 Answer 1


You will get this error if you rename a documented class or package file abc.dtx as abc.sty. The dtx file is a document with its own \documentclass for typesetting the package documentation. The package file may be extracted from that (usually by running tex on abc.ins)

  • For future readers: I just got this error when I saved the TeX file as a .aux (accidentally) and did a save-as to a .tex file without removing the bad .aux file.
    – Zach
    Commented Nov 5, 2017 at 21:36
  • Likewise: I had named a document file keyval.tex, and when I tried to compile another document in the same folder using standalone class, I got this error. (Standalone uses the keyval package). Both moving the second document to its own folder, and renaming keyval.tex to something else, allowed compilation to complete.
    – Cicada
    Commented May 9, 2020 at 2:57
  • Don't rename keyval.tex to xkeyval.tex, either!
    – Cicada
    Commented May 9, 2020 at 3:00

You must log in to answer this question.

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