9

When I do latexmk -c foo.tex, latexmk cleans up as expected. I tried to configure latexmkrc so that this would happen automatically. Here's my latexmkrc file:

$pdf_mode = 1;
$silent = 1;
$cleanup_mode = 2;

However, when I run latexmk, all of the other files (foo.log, foo.aux, etc) are still there. What am I doing wrong?

4
  • May I ask why you want to do this? This means that next time you compile it has to run several times to get references etc up to date. While leaving the aux files it might only take one compilation.
    – daleif
    Jan 28, 2015 at 16:23
  • @daleif my use of latex is not as sophisticated. I use it to take notes, not write papers.
    – jchun
    Jan 29, 2015 at 2:46
  • I still do not see any reason to delete those files all the time
    – daleif
    Jan 29, 2015 at 7:21
  • I used the command suggested by agent-gotse and worked perfectly. However i wonder if this could affect the performance of an application that can run this command multiple times. Could someone answer me? Sep 9, 2015 at 4:30

2 Answers 2

8

The documentation is out-of-date and wrong. Currently, when you specify $cleanup_mode=2, the cleanup action is done first, and then a regular run is done. That's different from what happens when you run latexmk -c foo.tex, which only does the cleanup.

The documentation wasn't updated to reflect a code change many versions ago. I need to correct the documentation (and probably improve the code).

Perhaps you actually want latexmk to do an automatic cleanup after compiling your document. That is a sensible idea, but it's not currently implemented.

2
  • 1
    thanks for the info. Is there some sort of quick hack that I can put together, like making an alias latexmk which executes latexmk -c or something?
    – jchun
    Jan 29, 2015 at 2:49
  • In my opinion, cleaning up only makes sense when the document has reached its no-more-edits-this-is-final form. Doing it at the end of a latexmk run just increases the length of the next run.
    – egreg
    Jan 30, 2015 at 10:36
4

The following command

latexmk -pdf foo.tex && latexmk -c foo.tex

will make latexmk build foo.tex and produce a pdf file. If this is successful, then the cleanup will be executed and you will be left with just the pdf file. You can create an alias for this in your shell if you wish.

1
  • 1
    (in 2022) With this approach there are still files left: .nav, .snm, .vrb
    – mrbela
    Nov 4, 2022 at 10:07

You must log in to answer this question.

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