# latexmk option -c not working

I try to use latexmk, version: 4.39, with the -c option, but it does not give any output.

\documentclass{article}
\begin{document}
Hello, world!
\end{document}


There is no output when I use latexmk -c -pdf test.tex.

But it works fine when I use latexmk -pdf test.tex.

Any idea what is going on? And is there another way to clean up auxiliary files with latexmk after compiling?

## 1 Answer

According to latexmk's documentation, cleanup operations override any compilation operations

 -c     - clean up (remove) all nonessential files, except
dvi, ps and pdf files.
This and the other clean-ups are instead of a regular make.


Try running latexmk -c in a separate step.

latexmk -pdf test.tex # Generate the pdf...
latexmk -c            # ... and then clean aux files


By the way, I would not recommend always cleaning up after building the latex files. The point of using latexmk is to avoid redundant recompilation passes and that is only possible if you preserve your auxiliary files between compilations. If you insist in cleaning up, then it might be simpler to ditch latexmk and just use a simple shell script that calls pdflatex 3 times and then removes the auxiliary files.

#! /bin/sh
lflags='-interaction=batchmode'
pdflatex -draftmode $lflags test bibtex test pdflatex -draftmode$lflags test
pdflatex            \$lflags test

rm -f *.aux *.bbl *.blg *.brf *.dvi \
*.fls *.log *.out *.pdf *.ps *.toc


~

• Three times with pdflatex is not necessarily enough (depending on the document and on the class and style files it uses). Latexmk automates getting the number of runs correct. – John Collins Apr 17 '15 at 13:54