LaTeX-Compilers work linear. One Compilation process goes through the source code from top to bottom.
This has to consequence that LaTeX-Compilers cannot know by design to which figure you are refering, if the figure comes on a later page of the document or on which page chapter 5 will start.
The necessity of the auxiliary files is strongly connected with the necessity of more than one LaTeX run to get the final result.
The most common files are:
- .log : The log file, contains all the output of the compile run. Loaded files warnings, errors etc. While not necessary for further LaTeX runs it is highly useful for debugging.
- .aux : Contains references, links etc. Gets parsed by the next LaTeX run.
- .toc : Contains the entries for the table of contents
- .bcf : Contains all the needed citations, is needed by biber or bibtex to create the:
- .bbl : Contains the formatted Citations and bibliography items, get's parsed by LaTeX
You can delete those files only after you are sure that no more LaTeX runs are necessary.
This files should be deleted after an error as an error might corrupt the files and although the error has been fixed in the source code is still in the files and gets parsed.
You should always use the package \usepackge[aux]{rerunfilecheck} which issues a warning, if another compiler run is necessary to finish the document. This Package also relies on the auxiliary files.
At last i want to give you the hint to use a build directory as output.
Then all outputfiles are created in this folder (including the pdf).
You can achieve this by compiling with the option --output-directory=foldername:
e.g.:
lualatex --output-directoy=build
The folder has to exist.
This is really handy if you use git and make. Your .gitignore gets as simple as build/ and the clean for make is just rm -rf build
\label/\refmechanism, for instance, deleting the.auxfile after each compilation will make it stop working. If you want to have a table of contents, deleting the.tocfile will break it. Etc. – mbork Oct 16 '14 at 18:05