Is there a command to delete all auxiliary files within the terminal without compiling the tex-file first?

There is such an option for latexmk but then I have to build the pdf first.


Ok, I try to be more explicit: Sometimes things go wrong and one has to delete all the aux, bbl, bcf etc. files. Some editor have this option but since we can compile a tex file with the terminal I was wondering whether there is also a function/program which would delete all those created auxiliary files automatically; e.g. $ cleartex . for all auxiliary files in that directory.

As moewe suggests such a program could have the gitignore list as base to work with.

  • 2
    I assume you would have to have a list of extensions of temporary files and then go through it and delete files you find with the extensions listed there. A start could be github.com/github/gitignore/blob/master/TeX.gitignore. I think I remember a different list with comments hosted on github, can't find it though. – moewe Jun 28 '18 at 7:34
  • 1
    erh, not understod, there are no aux files if the PDF has not been build. latexmk -c *.tex will remove all aux files generated from the given .tex files. – daleif Jun 28 '18 at 7:34
  • It isn't clear what you mean but rm *.aux removes all aux files from the current directory (or del rather than rm in windows cmd prompt) – David Carlisle Jun 28 '18 at 8:10
  • What would be the reason to delete the auxiliary files before running TeX? They are essential for the next run of TeX to be correct (or, at least, more correct than the previous one). – egreg Jun 28 '18 at 8:23
  • 2
    yes, they are essential, but I might start compiling from scratch and having all auxiliary files deleted before compiling (and then keep them for the next rounds compiling). – LukasCB Jun 28 '18 at 11:44

Ok, easiest method I can up with so far is

latexmk -C my-file.tex

I quote from the manual of latexmk for the flag -C:

Clean up (remove) all regeneratable files generated by latex and bibtex or biber. This is the same as the -c option with the addition of dvi, postscript and pdf files, and those specified in the $clean_full_ext configuration variable. This cleanup is instead of a regular make ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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