##  Class files

Sometimes when you are trying to compile a LaTeX document you get a "compilation timeout" message without further information about what's causing the problem. This article provide some advices to figure 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.

## Enabling additional error messages

Usually when your project times out you 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.

If that doesn't work, go to the next 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.

• 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.
• Missing semicolon in a tikz environment. This is a very common error, 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 and 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.

## 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  IntroductionLorem 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 let ShareLaTeX enable the draft mode for you 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.