# Overleaf: PDF causing compilation timeout (due to an infinite loop)

I just added a PDF in my Overleaf project (created by myself from Samsung Notes, never had a problem before) and adding this pdf using

\includepdf[pages=-]{Tp12.pdf}


(see pictures below) with

\usepackage{pdfpages}


caused me a timeout error:

Here is my pdf's location (the two first never caused any problem, and are not shorter).

This pdf has a size of 4,97 Mo.

Here is my head declaration in main.tex:

\documentclass{report}

\sceau{Pictures/sceau.jpg}

\usepackage{pdfpages}
\usepackage{xurl}
\usepackage{multicol}
\newenvironment{Figure}
{\par\medskip\noindent\minipage{\linewidth}}
{\endminipage\par\medskip}

\usepackage{hyperref}

\hypersetup{
filecolor=teal,
urlcolor=cyan,
pdftitle={Overleaf Example},
pdfpagemode=FullScreen,
}

\urlstyle{same}

\definecolor{RED}{RGB}{247,197,197}
\definecolor{GREEN}{RGB}{197,247,232}
\definecolor{GREEN_OCTAVE}{RGB}{68,200,81}
\definecolor{BLUE}{RGB}{197,232,247}
\definecolor{GRAY}{gray}{0.9}
\definecolor{lilas}{RGB}{238, 130, 238}

%+++++++++++New Commands++++++++++++
\newcommand{\bc}{\begin{center}}
\newcommand{\ec}{\end{center}}
\def\bi{\begin{enumerate}}
\def\ei{\end{enumerate}}
\newcommand{\dst}{\displaystyle}
\newcommand{\ba}{\begin{array}}
\newcommand{\ea}{\end{array}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\C}{\mathbb{C}}
\newcommand{\N}{\mathbb{N}}
\newcommand{\K}{\mathbb{K}}
\newcommand{\ra}{\rightarrow}
\newcommand{\Ra}{\Rightarrow}
\newcommand{\lra}{\longrightarrow}
\newcommand{\Lra}{\Longrightarrow}
\newcommand{\Eq}{\Leftrightarrow}
\newcommand{\Leq}{\Longleftrightarrow}
\newcommand{\Lagr}{\mathcal{L}}

\begin{document}


I hope I gave everything you need. I can't share the whole project for privacy issues.

• what do you expect anyone here can say? The system has a timelimit so any big enough project will give that error. It is not a tex error it is just a commercial decision to limit the processing time unless you pay more. May 20 at 18:27
• The documentclass report doesn't define \sceau, so \sceau can't occur right after \documentclass without triggering error-messages. Seems \addbibresource right before \begin{document} is not defined by any of the packages exhibited in your preamble. I doubt you gave sufficient information. Portions of code not revealed might form a never ending tail-recursive loop or provide another reason for reaching processing-time-limit. How can one know? If \includepdf[pages=-]{Tp12.pdf} is all you added, then reaching the processing-time limit is likely not to be due to a TeX-related bug. May 20 at 18:45
• @EmileCouzin Overleaf is just a Web-Interface for calling the TeX-program of some release of the TeX-Distribution TeX Live via internet. (Afaik with Overleaf they use some Ubuntu docker-image. Which Ubuntu depends on which release of Tex Live you select after clicking "Menu" on the top-left corner of the window of the browser where overleaf is displayed.)You can look at the error-messages written by the TeX-compiler to the .log-file by clicking the symbol for "Logs and output files" at the right of the "Recompile" button and then clicking "Expand" in the field "Raw logs". If this reveals ... May 21 at 9:07
• @EmileCouzin ... If this reveals that the reaching of the processtime-limit is not due to a bug in your TeX-code but is due to the hugeness of your project, consider installing/using a TeX Distribution on your local machine instead of using overleaf via internet. May 21 at 9:08
• Andreas has uploaded a new version to ctan that will not loop forever here (alhough that will not be on overleaf until the next texlive update) May 22 at 20:11

You can simplify your example to

\documentclass{article}

\usepackage{pdfpages}

\begin{document}

aaa

\includepdf[pages=-]{missing.pdf}

\end{document}


This gives the error

! Package pdfpages Error: Cannot find file missing.pdf'.

See the pdfpages package documentation for explanation.
Type  H <return>  for immediate help.
...

l.9 \includepdf[pages=-]{missing.pdf}

?


If you choose to scroll past the error (effectively what overleaf will do for you) then tex will try to recover but gives a series of spurious internal errors and never terminates

! Package pdfpages Error: Cannot find file missing.pdf'.

See the pdfpages package documentation for explanation.
Type  H <return>  for immediate help.
...

l.9 \includepdf[pages=-]{missing.pdf}

?

! Package pdfpages Error: Cannot find file -'.

See the pdfpages package documentation for explanation.
Type  H <return>  for immediate help.
...

l.9 \includepdf[pages=-]{missing.pdf}

?
! Undefined control sequence.
\AM@expand@range ...M@i \relax \@tempcntb =\AM@ii
\relax \ifnum \@tempcnta <...
l.9 \includepdf[pages=-]{missing.pdf}

?
! Undefined control sequence.
\AM@expand@range ...M@i \relax \@tempcntb =\AM@ii
\relax \ifnum \@tempcnta <...
l.9 \includepdf[pages=-]{missing.pdf}

?
! Missing number, treated as zero.
\relax
l.9 \includepdf[pages=-]{missing.pdf}

?
....


Always check the log file for errors

• Overleaf could make this a bit easier to find, I retracted a close vote on the question, but the genral principle of always check the log file does apply, even on Overleaf. May 21 at 7:01
• Why does TeX never terminate here? What about the “that makes 100 errors” barrier? May 25 at 15:41
• @HenriMenke I really didn't look: it's just usual random unplanned expansion nonsense and evenally after a dozen or so errors gets to \def\foo{\foo}\foo and just hangs in a loop. I mailed him and Andreas has fixed the package so it doesn't do that any more. May 25 at 15:44

I just found out what the problem was: I wrote \includepdf[pages=-]{Tp12.pdf} instead of \includepdf[pages=-]{pdf/Tp12.pdf}` ! It was just that, I forgot to put the file's name before !

• that would give a tex missing file error May 21 at 5:52
• But it didn't ! May 21 at 6:03
• Impossible to say as it doesn't correspond to the code or project that you showed May 21 at 6:09
• Oh, sorry I made a mistake by writing "Pdf12" instead of "Tp12" in my answer ^^ It's edited and now corresponds to my code May 21 at 6:45