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? – David Carlisle Jan 28 '17 at 12:18
  • 2
    actually ltxdoc is only used for documenting packages, never in real documents, have you gone \input{somepackage.dtx} in your main file? – David Carlisle Jan 28 '17 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) – David Carlisle Jan 28 '17 at 13:07
  • 2
    unrelated to the error but do not load kantlipsum in a real document and don't load epsfig in a document written since 1994 – David Carlisle Jan 28 '17 at 13:10
  • I'm voting to close this question as off-topic because the MWE never showed the bit of code that caused the error. – samcarter is at topanswers.xyz Jan 28 '17 at 13:13

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 Nov 5 '17 at 21:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.