1

I am creating a format file using mylatexformat. This allows me to precompile my (extremely lengthy preamble, shortening compile time.

However, biber does not respond to addbibresource, complaining either

WARN - I didn't find a database entry for '...'

or, if no bibresource at all was included in the format file:

WARN - No data sources defined!

How can I addbibresource and have a precompiled preamble?

Minimum working example

foo.tex

\documentclass{article} 
\usepackage[backend=biber]{biblatex}
\addbibresource{foo.bib}
\endofdump

\addbibresource{foo2.bib}
\begin{document}
This is just a test. With a citation: \textcite{test1}.
And another: \textcite{test2}.
\printbibliography
\end{document}

foo.bib

@article{test1,
    title = {Some title},
    journaltitle = {Some journal},
    author = {Rob, London},
    date = {2018-01-01}
}

foo2.bib

@article{test2,
    title = {Some title 2},
    journaltitle = {Some journal},
    author = {Rob, London},
    date = {2018-01-02}
}

If I first compile the preamble using:

pdftex -ini -jobname="foo" "&pdflatex" mylatexformat.ltx foo.tex

Then I comment (or delete) the preamble and add %&foo as the first line:

foo.tex (after compiling preamble):

%&foo
\addbibresource{foo2.bib}
\begin{document}
\maketitle
This is just a test. With a citation: \textcite{test1}.
And another: \textcite{test2}.
\printbibliography
\end{document}

biber will now complain:

> biber foo
.
.
.
WARN - I didn't find a database entry for 'test2' (section 0)
  • 1
    On which operating system are you? You don't need to remove the preamble. You can make pdftex use your format using pdftex -fmt="foo" foo.tex. But bibliography files where never a problem for me. – Skillmon likes topanswers.xyz Jan 10 '18 at 20:02
  • Seems as though everything in the preamble of the %&foo file is ignored. You can see this if you add an obviously undefined command like \zzzfooo: No error is produced. – moewe Jan 10 '18 at 22:13
4

You are missing an \endofdump

%&foo
\endofdump
\addbibresource{foo2.bib}
\begin{document}
\maketitle
This is just a test. With a citation: \textcite{test1}.
And another: \textcite{test2}.
\printbibliography
\end{document}

If you use your precompiled format all code in the preamble before \endofdump is ignored. You can verify this by calling an obviously undefined command (say \zzz) in the preamble: It will only cause an error if it is written after \endofdump.

The documentation of contains mylatexformat contains a verbatim copy of the comments in mylatex which has a similar limitation

The ‘mylatex’ format normally skips the whole preamble (believing it to be pre-loaded) and so such new commands do not take effect.

The solution in mylatex is to add a comment with the content mylatex (i.e. the line % mylatex) to the preamble. For mylatexformat the trick is \endofdump.

  • 1
    Isn't this also what the hint in your answer stated? tex.stackexchange.com/a/377033/35864 – moewe Jan 10 '18 at 22:33
  • Yes! Historical me has outsmarted present-day me. Not for the first time. Thanks for linking back to that. – LondonRob Jan 11 '18 at 14:20

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.