Any change to my project tex files, even those that do not involve bib files or citations, result in biblatex recompiling the bcf and bbl files. How to prevent this behavior in order to save time remaking the project?

I am using the following makefile:

file.pdf.dummy : *.tex 
    latexmk -xelatex -pv $(MAIN)

    latexmk -xelatex -C $(MAIN)

latexmkrc contains:

$pdf_previewer = "start atril";

$pdf_update_method = 0;

My backend is biber. I tried making the bbl and bcf files immutable, but, biblatex complains that it wants to write to the bcf file and dies.

  • 1
    Please provide use with a complete minimal example which we can use to reproduce the issue. What does the .dummy do? – cfr Feb 1 '16 at 1:17
  • @cfr it's a dummy target aggregate.org/rfisher/Tutorials/Make/make3.html - this one depends on all the tex files in the directory of make. So if a tex file changes, it will cause the target file.pdf.dummy to be out of date calling command latexmk below it. -pvc option on latexmk is to have the previewer open. The previewer is specified in the latexmkrc file below. Basically, the Makefile simply calls Latexmk anytime a tex file changes -- latexmk then figures out what to build. So the problem I reckon is that latexmk always wants to rebuild bcf & bbl files despite no change – Jonathan Feb 1 '16 at 4:03
  • 3
    We probably do need a minimal example, and an exact statement of what was done to get the behavior that is complained about. Xelatex and/or biber only get run by latexmk if any of their input files get changed. If, for example, biber gets run when you are not expecting it, then there has been a change in a bcf or bib file that happened despite your expectations. The output of latexmk tells you what file(s) have changed. – John Collins Feb 1 '16 at 16:19
  • 1
    1. Using latexmk's -pvc option may not be appropriate for this situation. It leaves latexmk continuously running and polling for file changes; and then reruns programs as appropriate. If you want a one-time make with a previewer being opened, use the -pv option. 2. There are also much better solutions for using latexmk with make. See the section "USING latexmk WITH make" in latexmk's documentation. – John Collins Feb 1 '16 at 16:27
  • @JohnCollins I suggested an answer below which resolves the unwanted behavior. I won't accept the answer for a few weeks unless the commenters endorse. I understand the behavior of -pvc and I did change it when testing. I will change it above in order to not confuse future readers. Thanks – Jonathan Feb 1 '16 at 19:04

The problem is that a I was using Mendeley a reference manager, that was updating the global bib file in the background without me noticing it. Hence, the bib file was changing. The default behavior of latexmk is to remake all the bbl files if there is any change to the any citation related stuff, for example, a change to the underlying bib file, or adding a \cite to tex file.

You can prevent this by using a copy of the bib file that isn't linked to the reference manager - and manually update latex's version. OR prevent latexmk from remaking bbl files with the option -bibtex- to latexmk in the Makefile.
The complete Makefile is thus:

file.pdf.dummy : *.tex 
    latexmk -bibtex- -xelatex -pvc $(MAIN)

If you add refs to your bib file you will need to rerun biber. Simply invoke latexmk without the -bibtex- option.

You can also configure this behavior in the latexmkrc file; variable names are explained in the man file, and a good primer on Makefiles - but - the Makefile is a more obvious place for it.

  • 1
    In my experience latexmk is really clever and only runs Biber if necessary, namely if your .bib file changed since last time, or something concerning citation changed in your .tex file. I have, however, never used the -pvc option, so that may play into it. – moewe Feb 1 '16 at 8:12
  • @moewe :: I also thought latexmk was very smart - and only runs biber if necessary. See the excerpt form the documentation: ---- $bibtex_use [1] The variable $bibtex_use possible values are: 0: never use BibTeX or biber. 1: only use BibTeX or biber if the bib files exist. 2: run BibTeX or biber whenever it appears necessary to update the bbl files, without testing for the existence of the bib files. -- the default is to always run. But if you have say 30 refs, it's not a big deal, If you have 1000 it is. I only noticed it now because I'm at ~500. – Jonathan Feb 1 '16 at 18:55
  • 2
    @Jonathan Latexmk definitely does NOT run biber unconditionally, but only runs it if the bcf or the bib file has changed since the last run of pdflatex (or xelatex) under latexmk control. I have just explicitly verified this with the current version on a simple test file. You say that in fact with your document biber is run every time. So there is something else going on beyond what is in your description of your problem. Look at the output from latexmk just before one of the runs of biber. What file(s) are reported to have changed? – John Collins Feb 2 '16 at 2:09
  • 3
    Adding an additional \cite does imply a change in the bcf file, and therefore latexmk will run biber again. Depending on the details, e.g., whether or not the additional \cite results in a change in the numbering of the references, the resulting bbl file may or may not be changed also after biber is run. If the bbl file doesn't change after that, then latexmk won't do an additional run of pdflatex (or xelatex). Could I repeat my request: When latexmk calls biber when you think it shouldn't, what does it report for changed files? – John Collins Feb 2 '16 at 17:28
  • 1
    @moewe done. I just realized that JOHNCOLLINS is the author of latexmk wow. – Jonathan Feb 10 '16 at 23:54

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.