Debugging Compilation timeout errors
Sometimes when you are trying to compile a LaTeX document on Overleaf, you get a "compilation timeout" message without further information about what's causing the problem. This article provides some advice on figuring out what might be causing your project to take too long to compile.
If you are trying to compile a big project with many images, go to the compiling big projects section.
Looking for common problems
Below, a list of common problems that may cause compilation to take too long is presented. These are good places to start looking for errors when something goes wrong.
- Tables
Errors in tabular
, longtable
and array
environments. If you place invalid commands, forget or add extra &
or \\
characters or forget the closing environment command, this may cause LaTeX to take too long to figure out what's wrong.
- TikZ pictures
Missing semicolon in a tikz environment. This is a very common error, and the next snippet will cause a compilation timeout error because of the missing semicolon at the end of the first \draw
command.
\begin{tikzpicture}
\draw (0,0)--(3,4)
\draw (2,2)--(5,1);
\end{tikzpicture}
- Adding commands before the
\documentclass
may cause your project to timeout.
- Inserting a blank line in multiple author document may cause an infinite loop in the compilation process. See the example below.
\documentclass{article}
\usepackage[utf8]{inputenc}
\title{Example of faulty code}
\author{John Doe
\and Hubert Harnsworth}
...
If you still are unable to find something wrong in your project, you can try to debug it by hand. See the next section.
Debugging your project
In absence of log messages, the only way to solve your problem is to look for the faulty chunk of code.
If your document imports files to generate the final output, commenting out some lines will help to find the faulty one. Be careful, do not comment out parts that can generate more errors. It's recommended to leave uncommented the preamble and the bibliography-related commands.
See the example below:
\documentclass{article}
\usepackage[utf8]{inputenc}
\begin{document}
\input{introduction.tex}
\input{chapter1.tex}
%\input{chapter2.tex}
%\input{apendix.tex}
\end{document}
In this example only the chapter1 will be compiled.
Once you identify the problematic file, or if your document has only one source file, comment out parts of the text and check if your project compiles with no errors. To comment out a block of text import the comment package and use the comment
environment.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{comment}
\begin{document}
\section{Introduction}
This document contains some dummy information and figures with the
only purpose of taking up some space.
\begin{comment}
\section{Second section}
\begin{tikzpicture}
\draw (0,0)--(1,1)
\draw (0,1)--(1,0);
\end{tikzpicture}
This text and the previous figure won't work
\end{comment}
\end{document}
In this example, only the title of the first section, Introduction, and the text corresponding to that section will be printed in the PDF output. Everything else is commented out.
Enabling additional error messages
When your project times out you usually don't see any error messages. A simple thing that you can try is to add the command \tracingall
in your .tex file, right below \begin{document}
. This will print some additional error messages in some cases.
\documentclass{article}
\usepackage[utf8]{inputenc}
\begin{document}
\tracingall
\section{Introduction}
...
\end{document}
The additional error messages take about three seconds to appear after the compilation project stops.
However, the \tracingall
command itself greatly increases the time taken to compile a project, and can even cause a project with no errors to time out. If you are working on a very large project, it's best to remove the \tracingall
command altogether and to debug as described above.
Compiling big projects
If you have a big document with several high resolution images, your project may take too long to compile, even when there are no errors in the code. The recommendation is to use lower resolution images where possible and to add the draft
option to your \documentclass
command. The draft
option will disable rendering images and will show a placeholder instead, hence improving the compilation time. Helpful to debug the project before the final version.
\documentclass[draft]{article}
\usepackage[utf8]{inputenc}
\begin{document}
\section{Introduction}
1 Introduction Lorem ipsum dolor sit amet, consectetuer adipiscing
elit. Etiam lobortis facilisissem. Nullam nec mi et neque pharetra
sollicitudin. Praesent imperdiet mi necante. Donec ullamcorper..
\begin{figure}[ht]
\includegraphics{lion-logo}
\caption{Something not important}
\end{figure}
Let's cite...
You can enable Draft mode in the Compile Mode menu:
A final recommendation is not to let the errors to pile up just because the PDF is rendered. Ignoring errors and warnings in large documents may slow down the compilation process.
Overleaf guides
- Creating a document in Overleaf
- Uploading a project
- Copying a project
- Creating a project from a template
- Including images in Overleaf
- Exporting your work from Overleaf
- Working offline in Overleaf
- Using Track Changes in Overleaf
- Using bibliographies in Overleaf
- Sharing your work with others
- Debugging Compilation timeout errors
- How-to guides
LaTeX Basics
- Creating your first LaTeX document
- Choosing a LaTeX Compiler
- Paragraphs and new lines
- Bold, italics and underlining
- Lists
- Errors
Mathematics
- Mathematical expressions
- Subscripts and superscripts
- Brackets and Parentheses
- Fractions and Binomials
- Aligning Equations
- Operators
- Spacing in math mode
- Integrals, sums and limits
- Display style in math mode
- List of Greek letters and math symbols
- Mathematical fonts
Figures and tables
- Inserting Images
- Tables
- Positioning Images and Tables
- Lists of Tables and Figures
- Drawing Diagrams Directly in LaTeX
- TikZ package
References and Citations
- Bibliography management in LaTeX
- Bibliography management with biblatex
- Biblatex bibliography styles
- Biblatex citation styles
- Bibliography management with natbib
- Natbib bibliography styles
- Natbib citation styles
- Bibliography management with bibtex
- Bibtex bibliography styles
Languages
- Multilingual typesetting on Overleaf using polyglossia and fontspec
- International language support
- Quotations and quotation marks
- Arabic
- Chinese
- French
- German
- Greek
- Italian
- Japanese
- Korean
- Portuguese
- Russian
- Spanish
Document structure
- Sections and chapters
- Table of contents
- Cross referencing sections and equations
- Indices
- Glossaries
- Nomenclatures
- Management in a large project
- Multi-file LaTeX projects
- Hyperlinks
Formatting
- Lengths in LaTeX
- Headers and footers
- Page numbering
- Paragraph formatting
- Line breaks and blank spaces
- Text alignment
- Page size and margins
- Single sided and double sided documents
- Multiple columns
- Counters
- Code listing
- Code Highlighting with minted
- Using colours in LaTeX
- Footnotes
- Margin notes
Fonts
Presentations
Commands
Field specific
- Theorems and proofs
- Chemistry formulae
- Feynman diagrams
- Molecular orbital diagrams
- Chess notation
- Knitting patterns
- CircuiTikz package
- Pgfplots package
- Typing exams in LaTeX
- Knitr
- Attribute Value Matrices
Class files
- Understanding packages and class files
- List of packages and class files
- Writing your own package
- Writing your own class
- Tips