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
\documentclass[12pt]{amsart}
\usepackage{algorithm2e}
\begin{document}
test
\end{document}
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
\usepackage[all]{xy}
\usepackage{noindent}
\usepackage{multirow}
\usepackage{amssymb,amsmath,latexsym,amsbsy,comment,pifont}
\usepackage{amscd}
\usepackage{palatino}
\usepackage{stmaryrd}
\usepackage{eulervm}
\usepackage{fullpage}
\usepackage[usenames,dvipsnames]{color}
\usepackage{fancybox}
\usepackage{graphicx}
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
\usepackage[vlined]{algorithm2e}
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.
Best Answer
The problem is caused by the
relsize
package (internally loaded byalgorithm2e
); 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:
To prevent this from happening, load the
algorithm2e
package with thenorelsize
package option, as in:A complete example:
Perhaps the
algorithmicx
package could be of interest for you (it provides many possibilities to customize the layout of algorithms) to be used instead ofalgorithm2e
.