TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can I compile my document with other tools and use latexmk -C only for cleaning up?

One application could be to use it then in the clean: section of a Makefile that uses pdflatex for make pdf.

share|improve this question
I don't understand your question. Is there a certain functionality of latexmk -C you're missing, or some part of it that you don't understand? Generally, such questions will probably be answered by the documentation/manual; if not, you could refer to an unclear passage in the manual here and ask for clarification. texdoc.net/pkg/latexmk (page 3) – doncherry Nov 24 '12 at 0:21
I think the OP does not want to build the document using latexmk, only to invoke it to delete the generated files, having compiled the document using different tools. In this case I believe the answer is no, because latexmk only builds the list of removable files when it processes the job, so it won't have this to hand if it does not process the job itself. But one can perhaps provide a less clever cleanup script that just deletes files with certain extensions... – cyberSingularity Nov 24 '12 at 0:45
Actually, maybe yes. Looking at latexmk.pl, it has a branch No fdb file, so do inferior job by parse_log. Trying this out on a small example might also be a quick way to answer the question! – cyberSingularity Nov 24 '12 at 0:59
up vote 14 down vote accepted

Yes, you can use latexmk -C (or -c) just to clean up auxiliary files. By default, -c cleans up the following files types:

@generated_exts = ( 'aux', 'bcf', 'fls', 'idx', 'ind', 'lof', 'lot', 
                'out', 'toc' );

(latexmk.pl, l. 1088f)

-C also cleans up the actual output, i.e pdf, dvi, or what have you. If you want to add more file extensions to this list, have a look at http://tex.stackexchange.com/a/83386/4012.

latexmk -C / -c can be run no matter how you initially compiled your document, and may very well be used only for cleanup.

share|improve this answer
Also, on line 2165 of v4.35, the additional types 'blg', 'ilg', 'log', 'aux.bak', 'idx.bak' are cleaned up, but these are not part of @generated_exts as that variable also serves other purposes for which these entries would not be appropriate! A little later, line 2169, texput.log and texput.aux are taken care of also. – cyberSingularity Nov 24 '12 at 1:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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