27

I use TeXLive 2012 and compile with run

latexmk -pvc -pdf -quiet test.tex

later I clean the directory with

latexmk -C

But test.bbl remains. How can I help latexmk to find bbl files?

test.bbl (first lines)

% $ biblatex auxiliary file $
% $ biblatex bbl format version 2.1 $
% Do not modify the above lines!
%
% This is an auxiliary file used by the 'biblatex' package.
% This file may safely be deleted. It will be recreated by
% biber as required.
%
Jonas Stein
  • 8,909

3 Answers3

28

By default, latexmk treats .bbl files as non-regeneratable. This is because the .bib from which they are made is not always available. See the documentation for a fuller explanation, especially the explanation of the $bibtex_use variable. To get latexmk -C to delete .bbl files, put the following in an initialization file:

$bibtex_use = 2;
John Collins
  • 11,183
  • 3
  • 32
  • 33
  • 4
    Oh my, you were faster than me by 10 seconds. :) In other news, I know that this is probably not the best place to say this, but your awesome work with latexmk inspired me to write arara. I really admire all the effort you've put into the tool. Thanks a million. – Paulo Cereda Nov 19 '12 at 18:26
  • 6
    Is $bibtex_use = 2; equivalent to -bibtex? – Jonas Stein Nov 19 '12 at 18:34
  • 7
    Yes. The option -bibtex simply sets $bibtex_use to 2. – John Collins Nov 19 '12 at 22:29
  • Thanks for the answer, what do you mean by " initialization file", the makefile? – zyy Nov 02 '22 at 14:43
20

Another option to the presumably canonical answer John gave is specifying $clean_ext in a latexmkrc file, which contains your personalized global options. This file can be in one of the places I outlined in my answer to Latexmk: makeglossaries, Biber and pdfLaTeX / Where to put latexmkrc?. Also see the latexmk manual.

My complete list of extensions looks like this:

$clean_ext = 'synctex.gz synctex.gz(busy) run.xml tex.bak bbl bcf fdb_latexmk run tdo %R-blx.bib'

(As a result of -- I think -- SyncTeX, latexmk, Texmaker, biblatex, Biber, todonotes)

doncherry
  • 54,637
  • Just to clarify, in some situations (like, if your .bib file is in a search path, not the current dir, and latexmk doesn't find it), latexmk may sometimes not delete the bbl file even if you have put bbl in the $clean_ext string in .latexmkrc. That is, you'd need to use Johns answer from above to make it clean out bbl files. I think this is explained in the the latexmk docs; see -bibtex-cond. – postylem Jun 22 '22 at 15:31
2

Reading from the documentation:

-bibtex-cond1

... .bbl files are only treated as precious if one or more bibfiles fails to exist.

Thus you simply do:

latexmk -bibtex-cond1 -C
zyy
  • 2,146