There seems to be a known incompatibility between biblatex
and tex4ht
when using defernumbers=true
.
I have one large .bib
file. In the document I want to group the references into different categories. When using numerical labels, this requires defernumbers=true
to obtain consecutive numbering.
Everything works fine, apart from that htlatex
chokes on this option with the following error:
! LaTeX Error: Missing \begin{document} in `'.
Forcing the run to continue for the example below, I obtain a usable .html, but there is a erroneous span
tag right at the beginning:
<span
class="cmr-10">01 12</span>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
This example illustrates the problem:
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{sample.bib}
@article{Smith42,
AUTHOR = {Smith},
TITLE = {Some Title},
JOURNAL = {Some Journal},
YEAR = {1942},
}
@article{Aronson12,
AUTHOR = {Aronson},
TITLE = {Some Title},
JOURNAL = {Some Journal},
YEAR = {1912},
}
\end{filecontents}
\usepackage[style=numeric,defernumbers=true]{biblatex}
% The following instead of the previous line works with tex4ht, but the numbering is not as desired.
%\usepackage[style=numeric]{biblatex}
\bibliography{sample.bib}
\DeclareBibliographyCategory{group1}
\DeclareBibliographyCategory{group2}
\addtocategory{group1}{Smith42}
\addtocategory{group2}{Aronson12,Smith42}
\begin{document}
\nocite{*}
\printbibliography[category=group1]
\printbibliography[category=group2]
\end{document}
Note that the problem doesn't occur without the option defernumbers=true
. I am using an up-to-date TL 2011 distribution, i.e., a biblatex.sty
version 1.7 dated 2011/11/13 19:09:07 and biblatex.4ht
dated 2011-09-18-16:07.
Is there a workaround for this that doesn't require editing the .bib
file?
Best Answer
I'm not sure if this will help exactly with the problem above - but I'll try to jot down my debugging steps. I was using a customized bibliography sorting in
biblatex
, which then requiresbiber
- and, all being good in the PDF - as soon as I wanted to build this usinghtlatex
,biber
,htlatex
- I got the above error (only when the.aux
file is present)..So first I get something like:
I search with
grep
through files to find this ...backref{1}{myfirstcite}
- and it turns out it is in the.aux
file; contents around that line look like this:So I go back, run
htlatex
again - and now when it stops at error, I press 'I
' in the shell to insert, and then just type\show
and ENTER (ENTER maybe twice) - this spits an additional error message:Ok, so by now, I'm pretty sure
tex4ht
doesn't like\abx@aux@backref
.So, I search first for the macro
\abx@aux@page
- and it turns out it is present inbiblatex.4ht
file (fromtex4ht
); a snippet looks like:... but it also appears in
biblatex.sty
(frombiblatex
).Then I search for
\abx@aux@backref
- and, as suspected - this one is defined inbiblatex.sty
, but not inbiblatex.4ht
; which is probably the reason why it crashes.Now,
\abx@aux@backref
contains an@
, meaning I'd have to define it in between\makeatletter
/\makeatother
- somewhere in the preamble after bothbiblatex
andtex4ht
are loaded. However, often times in similar cases I just do\let\abx@aux@backref\relax
- but, that will not work here, because the original command always has five arguments.So, after another search through
biblatex.sty
, I find: "\protected\def\blx@aux@backref#1#2#3#4#5{...
" - and while that is not the same command, it is certainly to related to something@aux@backref
... So, in the end I put this in my preamble:... and now the
htlatex
,biber
,htlatex
combo seems to pass for me?!Well, not sure how right I am about all this - but certainly hope it helps,
Cheers!