I am trying to use the algorithm2e package. I downloaded the package from CTAN and verified that I can typeset its own documentation (algorithm2e.tex). I then try to write my own document that uses algorithm2e, as follows


This TeX file is in the same directory as all the algorithm2e files that I copied from the web. I blew away all the aux files and other temporaries.

I get Latex error: Missing documentSee the LaTeX manual... etc. I have tried this under TeXWorks, TeXShop, and Texmaker on a Mac Book Pro, all with the same results. I have read the detailed log and output of TeX trying to figure out what TeX thinks is missing, and I haven't found it. Every other document I have tried to typeset works out ok.

If I take out the \usepackage{algorithm2e} command, everything is ok. I also have had no trouble using many other packages, such as


All ok. The only one that seems to cause problems is algorithm2e, and only in my OWN document. To reiterate, it works great when typesetting its own documentation. I tried putting the following in every position in that block of usepackage commands


it didn't matter where I put it, it generates the same error.

I've boiled this down into the smallest example I can make and I'm stumped.

  • 1
    Is there a reason that you didn't install that package via your TeX distribution? Or put the files into your localtexmf folder and refreshed the database? Oct 5, 2012 at 15:03
  • This still does look like you're not putting your .tex file in the correct folder. By the way, you can put relative and absolute paths to a \usepackage quite like in an \input, e.g. \usepackage{../algorithm2e}, \usepackage{algorithm2e/algorithm2e} or \usepackage{D:/myfu/nnypath/to/algorithm2e}. Oct 5, 2012 at 15:12
  • 1
    Add \listfiles to the MWE and get the correct error message (probably Missing \begin{document}) and also the .log file to see the position of the error message (line number, what happened before). Oct 5, 2012 at 15:17
  • @Qrrbrbirlbel that isn't really supported (and will generate warnings from ProvidesPackage that the package names don't match) Oct 5, 2012 at 15:40
  • Did you not forget to run texhash after installing the file?
    – T. Verron
    Oct 5, 2012 at 16:10

1 Answer 1


The problem is caused by the relsize package (internally loaded by algorithm2e); the former package is incompatible with the AMS document classes; processing the following document:


produces the exact problem mentioned in the question; the process ends with many warnings and the obtained .pdf is the following:

enter image description here

To prevent this from happening, load the algorithm2e package with the norelsize package option, as in:


A complete example:



\KwData{this text}
\KwResult{how to write algorithm with \LaTeX2e }
\While{not at end of this document}{
read current\;
go to next section\;
current section becomes this one\;
go back to the beginning of current section\;
\caption{How to write algorithms}


enter image description here

Perhaps the algorithmicx package could be of interest for you (it provides many possibilities to customize the layout of algorithms) to be used instead of algorithm2e.

You must log in to answer this question.

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