Skip to content

A ‘compile timeout’ means that it took too long to make the PDF for your document. This page explains why this can happen and how to fix it.

Large, High-resolution images

If you have several high-resolution PNG or JPEG images in your document, LaTeX has to resize them every time we compile the PDF, and this can take a long time. Here are some ways to get around this:

  • Use PDF files instead of PNG files for diagrams and plots. If your drawing or plotting software exports to PDF, that will be much faster (and the output will look better). Also converting PNG files to PDF and using those instead of the PNGs will speed things up.
  • Use draft mode when working online, by clicking on the downward-pointing arrow next to the "Recompile" button, and then choose the "Fast (draft)" option. This replaces all of your graphics with boxes and makes the PDF compile much faster.

  • Use lower resolution images for the online version of the document.

See this article for detailed suggestions on handling large images.

Complicated TikZ or pgfplots drawings

TikZ and pgfplots produce great graphics, but they can take a long time to compile. There are several ways you can externalize the TikZ pictures so that LaTeX doesn't have to redraw them from scratch every time it makes a new PDF.


Recent versions of the mhchem package can take longer to compile. Depending on your usage scenario, the chemformula package may compile faster. If you've already been using mhchem, you can try to drop-in chemformula as a replacement:

% \usepackage{mhchem}

Though note that there are syntax and feature differences between mhchem and chemformula, so this may not always work well. For example, \ce{2H2O} will render fine with mhchem, but you'll have to write this as \ch{2 H2O} with a space after the initial 2 with chemformula.


If your project was created some time ago and therefore uses the TeX Live 2017 compiler image, your project would then be using biblatex v3.7. This version of biblatex very slow especially if you're using styles that need to track occurrences of citations, e.g. authoryear-comp, authoryear-icomp, APA etc. You can switch the TeX Live version of your project to a more recent one that is compatible with your project to use a newer and faster version of biblatex.

If you need to keep using TeX Live 2017 for your project and would like to try get around biblatex v3.7's slowness, it may help to try switching to a non-tracking style while compiling online, e.g. authoryear, or (where possible) use BibTeX instead.

Tracing/debugging calls

If you happen to have a \tracingall in your document (perhaps leftover from a template or a project from a local machine), it'll be recording lots and lots of lines in the .log file (which can quickly grow to hundreds of MBs) and showing no sign of stopping. Remove the \tracingall call from your Overleaf project; or use the trace package instead, if you need to debug online.

Infinite loops

LaTeX can fall into an infinite loop when it tries to make the PDF—no matter how long you wait, it will never finish. Infinite loops are most commonly caused by bugs in packages or in user-defined commands, e.g. when a command expands to itself (a process called recursion). So check if you accidentally added a definition like \newcommand{\foo}{\foo} somewhere.

Fatal compile errors blocking the compilation

Unfortunately, some LaTeX compile errors can block the latexmk build process completely and therefore lead to a timeout. In order to debug such errors it may be necessary to add a file named latexmkrc (without any file extension) to your project, on the top level, containing just these three lines:

$pdflatex = 'pdflatex --halt-on-error %O %S';
$lualatex = 'lualatex --halt-on-error %O %S';
$xelatex = 'xelatex --halt-on-error %O %S';

This would then make the compilation halt at the very first compile error message that occurs (albeit without generating any output preview). You can then debug and correct each error you come across until the project is error-free; you can then delete this latexmkrc. (If you still get a timeout even with this latexmkrc file, it is likely that the main cause is one of the issues discussed in previous sections.)

Common errors that may block the compilation process include (but are not limited) to the following:

  • \caption{} should always be placed outside tabular; otherwise it may cause fatal errors if the caption package is loaded. (But longtable does require \caption{...} within it)
  • \caption{...} should not contain \\, \newline, \centering, \raggedright etc.
  • With some templates or packages, \ref{...} or \cite{...} within a \caption may need to be preceded by \protect to avoid fatal errors.
  • Similarly if you're using the soul or changes package to highlight text or strike text out, \cite and \ref may require \protect before them.
  • Check for incomplete \cmidrule{...} within tabulars; it requires a range of columns so you'll need to write \cmidrule{3-3} instead of just \cmidrule{3} if you want a horizontal rule that spans only one column.
  • Avoid nested tabulars. Have a look at the makecell if you'd like to add manual line breaks in a table cell, or the p{...} column type and/or tabularx package if you're looking for ways to create columns that auto-wrap long lines. (In general be very careful with tables...)
  • \author{...} should not contain blank lines.
  • Missing ; at the end of path/node commands, and ] at the end of parameter lists, in tikzpictures
  • The breqn package's dmath environment may run into infinite loops; replace with align and manually break lines if necessary.
  • The flushend package can cause infinite loops. This typically happens when there is too few text on the last page for flushend's algorithm to operate on. The flushend package was removed from the ACM template for this reason.
  • You may want to temporarily remove flushend while you're still actively writing the manuscript. Once you've finalised your contents, you can re-add flushend, and see if it then works better. If not, you may want to use the balance package instead:
    %% don't load flushend
    .... (somewhere in the left column of the last page) 
  • If you have too many tables or figures using the [H] placement identifier, it may cause \(\LaTeX\) to run into an infinite loop trying to find suitable places for all of them. Consider replacing all [H] with [hbt!], and if necessary an occasional \clearpage to flush out all tables and figures in the queue before inserting a page break.
  • Some babel language options may change the meanings of some characters, which may further cause problems when these characters are used in their "normal" context e.g. in math mode. Try adding the shorthands=off option when loading babel to stop this.

Fair Use limits

If you have a very large document, it may just take a long time to compile. We offer longer compile times on our paid plans:

  Free Student, Collaborator, Pro
Timeout 1 minute 4 minutes

We have to set timeouts in order to deal with infinite loops, and also to ensure that we are fair to all of our users.

Still stuck?

If you have a compile timeout error that you cannot resolve, please let us know and we'll take a look for you.

Overleaf guides

LaTeX Basics


Figures and tables

References and Citations


Document structure





Field specific

Class files

Advanced TeX/LaTeX