When I run a latex file using Texmaker it generated extra files which are .aux, .log, .out, .bbl and .synctex.gz, how can i delete them so that my files will contain only .pdf and .tex.

  • 1
    Click on the file, hit the delete button on your keyboard. Or use the cleanup function in TeXmaker. But i wouldn't recommend that if you don't know what information does files hold.
    – Johannes_B
    May 15, 2017 at 4:25
  • 3
    Compilation tools like latexmk or arara have rules to clean up after the compile chain. You can also set texmaker to delete the files. But why on earth? Those files are important and don't do any harm.
    – Johannes_B
    May 15, 2017 at 4:46
  • 2
    Tex generates those for a reason, you should not delete them as a matter of course, and if you do delete them you can do it as you delete any file on your system. May 15, 2017 at 6:53
  • Mind the good advice here, but when you're done with a project and want to leave behind a clean directory, this bash function may be of use.
    – mcp
    Mar 10, 2022 at 0:14

3 Answers 3


As said by others, it's not really a great idea to (automatically) remove .aux, .log and similar files. Some of them provide important info in case things go wrong (for example .log), others are needed for things to actually work when you compile your document multiple times (.aux, .toc etc.). Deleting them can break things.

However, if this is related to a desire to have a cleaner working directory, there are a few ways to accomplish that (if not, then apologies for being presumptuous):

  • For those who, like me, do things by hand, you can compile your document with the output-directory parameter.
  • Or you can configure TeXMaker to use an output directory for your files. Other tools may have similar options; I'm no expert on TeX IDEs.

Note, however, that both of these solutions will also put the .pdf file in the output/build directory.

Manual Compilation

The first option works thusly:

pdflatex -output-directory=build yourdocument

(or, instead of build, whichever other output directory you want to use) Before compilation, make sure the build directory exists. Your working directory will look as follows:

├── build/
└── yourdocument.tex

After compilation, it will look like this:

├── build
│   ├── yourdocument.aux
│   ├── yourdocument.pdf
│   └── yourdocument.log
└── yourdocument.tex

Texmaker (unsure on other IDEs)

In Texmaker, go to the menu option Configure Texmaker and select the highlighted option:


Note that texmaker will create the build directory automatically, unlike pdflatex in console mode.

Addendum: Makefiles

If you want to have your pdf and your tex file in the same directory, but all the other files in the build dir, manual intervention is required, as far as I'm aware. I usually use Makefiles to automate my process, but I'll admit that that might not necessarily be a solution for everyone.

Still, a short example for such a Makefile:

        mkdir -p build
        pdflatex -output-directory=build mydocument
        mv build/mydocument.pdf ./

Then I can just type make in the working directory on the terminal and it will do the right thing, giving me this situation:

├── build
│   ├── mydocument.aux
│   └── mydocument.log
├── mydocument.pdf
└── mydocument.tex

Well, It will help you provided that you are using the texstudio editor. Just open your main .tex file. Then compile it once, it will generate the temporary and auxiliary files. Then, go to Tools -> Clean Auxillary files. This will help you, for sure. I don't have any knowledge regarding texmaker and winedit. I hope that these editor provides the same feature as of texstudio. Additionally, you can also delete the temporary files manually by going to the same folder.

Hope it helps.

  • Actually i want to delete by coding only @Siba Mishra
    – Biki Teron
    May 15, 2017 at 4:35

Simply for Texmaker ,compile your file using Quick build then in the top bar navigate Tools then clean, yet you have to do that each time you compile.

Not the answer you're looking for? Browse other questions tagged .