# Amsart with algorithm2e introduces extraneous text into pdf file with Texlive 2011

I just removed the default Ubuntu TexLive 2009 installation and installed TexLive 2011 using install-tl. However, now I am facing problems with the amsart and algorithm2e packages. Specifically, when I compile a file with the following text:

\documentclass[twoside]{amsart}
\usepackage{algorithm2e}
\begin{document}
This is a test document.
\end{document}


rather than

\documentclass{article}
\usepackage{algorithm2e}
\begin{document}
This is a test document.
\end{document}


then the PDF output produced by pdflatex (or the dvi output produced by latex) contains the following text on the first page (and half of the first page disappears: it is as if this text pushes everything on the first page down).

La-TeX Error:Missing document See the LaTeX manual or LaTeX Companion for >explanation.You’re in trouble here. Try typing ¡re-turn¿ to proceed.If that doesn’t work, type X ¡return¿ to quit.1111111

This text disappears if I use the article style instead, or if I remove the algorithm2e package with amsart. Notice that this text does not appear as a console error message: the compilation shows no errors. This actually occurs at the top of the first page of the output pdf (or dvi) file. In fact, although I put the message in a more human readable form above, it actually contains several line breaks in between words; in particular, almost all the hyphens in the output above are followed by a line break.

Is this a documented problem with TexLive? What could be the reasons for this happening? Is there a workaround?

-
Welcome to TeX.SE. It is always best to compose a MWE that illustrates the problem including the \documentclass so that those trying to help don't have to recreate it. –  Peter Grill Oct 9 '11 at 3:58
Do you perhaps have any .aux files from a previous run? Try deleting those and rerunning. –  Peter Grill Oct 9 '11 at 4:00
Hi Peter Grill, Thanks for your advice. I had tried deleting the aux files before, and that does not work. However, in trying to create an MWE, I think I isolated the cause of the problem. The Text I quoted above appears only when I use the algorithm2e package. I am editing the question to reflect this. –  Piyush Oct 9 '11 at 4:09
Great. Often problems can be solved as you create a MWE. Remove all the code you can which still exhibits the problem and it will be easier to help you. –  Peter Grill Oct 9 '11 at 4:11
I added the minimal amount of code with which I can produce the error to the question. Thanks. –  Piyush Oct 9 '11 at 4:15

The problem here is that algorithm2e, from v4.00 started using the relsize package to scale the size of the algorithm line numbers. However, this clashes with some document class, as stated in the release notes for algorithm2e:

OPTION norelsize: Starting from this release (v4.00), algorithm2e package uses relsize package in order to get relative size for lines numbers; but it seems that some rare classes (such as inform1.cls) are not compatible with relsize; to have algorithm2e working, this option makes algorithm2e not to load relsize package and go back to previous definition by using \scriptsize font for lines numbers.

This seems to also clash with amsart. However, this is fixed using the above package option:

\documentclass[twoside]{amsart}
\usepackage[norelsize]{algorithm2e}% http://ctan.org/pkg/algorithm2e
\begin{document}
This is a test document.
\end{document}

-
Thanks Werner. I actually changed my algorithm code (There was not much of it) to algorithmicx (which is apparently newer) and it compiled. I hope your reply would be useful for others though (searching for "algorithm2e and amsart" on Google brings this reply up as the first link :). –  Piyush Oct 9 '11 at 4:46

When using TexLive 2011 (on the arXiv) with amsart, I had the same error message:

LaTeX Error: Missing document See the La- TeX manual or LaTeX Companion for explanation.You’re in trouble here. Try typing return to pro- ceed.If that doesn’t work, type X return to quit.

and half of the first page disappeared.

Removing the line

\usepackage{relsize}

solved the problem.

(The problem didn't show up with TexLive 2009, and has been fixed with TexLive 2013.)

-
Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format –  texenthusiast Aug 6 '13 at 19:34