Every time I compile a source code of LaTeX there are a lot of files produced except the .tex file and the .pdf (obviously!). I can guess that they are really useful to some people and obviously to the program creating the final pdf file, but they are not useful to the users. So my question is if there is any way to make them either stop being created at the end or just delete themselves, as the folder in which I create my projects is vastly populated with files I don't need.

Also I really didn't know what tag to place in this post (and I don't know if the one I chose is the right one), so please edit the post with the right tags!

  • Don't delete these files. They are useful for users, even if the users don't know that. If you use the \label/\ref mechanism, for instance, deleting the .aux file after each compilation will make it stop working. If you want to have a table of contents, deleting the .toc file will break it. Etc. – mbork Oct 16 '14 at 18:05
  • @mbork I understand that they are essential for the whole process but I merely ask if there is a way not to "harass" the user. For instance when you compile in ShareLatex you only get the pdf file and nothing else (I know that the other files are used in ShareLatex as well). – Adam Oct 16 '14 at 18:14
  • Some TeX compose-and-compile environments can be told to delete those auxiliary files when done. What tools do you use? – Ethan Bolker Oct 16 '14 at 18:15
  • 3
    This question has been ask quite a lot of times here. Search for "auxiliary" and "delete" or "clean". And if you use one method: make sure that you know to stop the clean up. It is difficult to help people who can't find the log-file because some overeager editor is hiding or deleting it. – Ulrike Fischer Oct 16 '14 at 18:24
  • @EthanBolker In windows I use MikTex and Texmaker and in linux I just started using TeXLive and Vim. – Adam Oct 16 '14 at 18:28

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:


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

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.