# Compilation error (combine class + hyperref package): TeX capacity exceeded, sorry [input stack size=5000]

I would like to create a "journal" with several papers, using the combine class.

In the example below, there are one master file and two articles.

Master file:

\documentclass[11pt,a4paper]{combine}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[english,french]{babel}

\title{Journal of }
\author{A. N. Editor}

\begin{document}
\maketitle
\tableofcontents
\begin{papers}

\makeatletter
\let\@begindocumenthook\relax
\makeatother

\coltoctitle{An article}
\coltocauthor{A.~N.~Author}
\label{art1}
\import{art1}
\clearpage

\coltoctitle{Another article}
\coltocauthor{A.~N.~Other}
\label{art2}
\import{art2}
\clearpage

\end{papers}

\end{document}


First article:

\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[english,french]{babel}

\title{An article}
\author{A.~N.~Author}

\begin{document}
\maketitle

Bla bla bla

\end{document}


Second article:

\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[english,french]{babel}

\title{Another article}
\author{A.~N.~Other}

\begin{document}
\maketitle

Bla bla bla

\end{document}


The compilation is stopped and an error message is given:

! TeX capacity exceeded, sorry [input stack size=5000].
\clearpage ...Call@BeforeClearDocument \clearpage

\Call@AfterLastShipout
l.17 \end{document}

If you really absolutely need more capacity, you can ask a wizard to enlarge me.


Note: If the hyperref package is not activated in the preamble of the master file, the entire document is correctly created.

I would like to get a document with hyperlinks (e.g. figures) and bookmarks. Thus, I would like to use hyperref. How can I solve this problem?

-
\clearpage is being defined to expand to a definition that includes \clearpage so you get into an infinite loop didn't spot where the culprit was yet but this may help you narrow it down –  David Carlisle Oct 10 '12 at 20:03
If I uncomment the redefinition of \@begindocumenthook, it hangs at \captions@French ->\captions@French –  egreg Oct 10 '12 at 20:29

I fixed the endless loop in package atveryend 2012/10/15 v1.9. Also hobsub 2012/10/15 v1.15 needs to be updated, because it contains atveryend. The PDF files contain the DTX sources as file attachments. The packages are unpacked by running the DTX files through tex (not latex). The new versions will be part of the next bundle update at a later time.

But the class combine will not work well with hyperref, because internals are overwritten, that are redefined by hyperref (\label, \ref, \@setref, …).

BTW,

\makeatletter
\let\@begindocumenthook\relax
\makeatother


can be abbreviated by

\emptyAtBeginDocument

-
Thanks for answering. Despite the fact that the class combine cannot work well with hyperref, is it possible to have citations colored (in red for example) in the text? –  Vince Nov 8 '12 at 20:05