Search code examples
urllatexbibliographybiblatextex4ht

make4ht with biblatex fails for records using \url when title field used but not when title field eliminated


When I use make4ht (or htlatex) to compile a .tex file containing a biblatex bibliography, I get the error:

! Illegal parameter number in definition of \blx@tempa.
<to be read again> 
                   1
l.19 \printbibliography[heading=bibintoc]

This error occurs when the bibliography record in the .bib file contains a url (I use \url{link is here}), and appears to be related to how many fields the record has, such as title, published (or howpublished for @misc), because this error does not occur when I make a much simpler bibliography record without many fields.

Also, I have no troubles with the bibliography when I compile for latex.

MWE (main_test_file.tex):

\documentclass[11pt]{article}

% Use Chicago Manual of Style:
\usepackage[authordate,autocite=inline,backend=biber,natbib]{biblatex-chicago}
\usepackage[colorlinks]{hyperref}
% References file:
\addbibresource{bib_test_file.bib}
%

\begin{document}

Some writing stuff: \autocite{trialurl1} works with make4ht when no extra stuff before $\backslash$url, but doesn't work when add another feature, like a title or howpublished, etc.
% Uncomment the following line, and the make4ht fails:
, as in \cite{trialurl2}.

More interesting stuff: \autocite{vanier} should have no problems with make4ht.

% The list of references is printed:
\printbibliography[heading=bibintoc]

\end{document}

The following fails with the above-mentioned error when trialurl2 is cited:

make4ht -ue mybuild.mk4 main_test_file.tex

but works fine when trialurl2 is not cited. In both cases, it doesn't matter whether I use \cite, \autocite, \citeauthor, etc. The same behavior occurs.

Also, using latex, then biber, then latex, then latex, works fine, even when trialurl2 is cited.

The bib_test_file.bib file is:

@misc{trialurl1,
author = {George, Birdie},
note = {\url{https://mail.yahoo.com/} Accessed 24 July 2020},
year = {2020},
}

@misc{trialurl2,
author = {George, Birdie},
title = {Hi},
note = {\url{https://mail.yahoo.com/} Accessed 24 July 2020},
year = {2020},
}

@book{vanier,
title = {Living Gently in a Violent World: The Prophetic Witness of Weakness},
author = {Vanier, Jean and Hauerwas, Stanley},
edition = {Second},
year = {2018},
publisher = {InterVarsity Press},
}

and the mybuild.mk4 is

Make:add("biber","biber ${input}")
if mode=="draft" then
  Make:htlatex {}
else
  Make:htlatex {}
  Make:biber {}
  Make:htlatex {}
  Make:htlatex {}
  Make:htlatex {}
end

mybuild.mk4 is taken from the answer by michael.h21 here https://tex.stackexchange.com/questions/244828/illegal-parameter-with-biblatex

michael.h21's answer helped me with some other problems but not my current problem, by the way.


Solution

  • Apparently, for biblatex, the .bib file needs changed (see answer by moewe here: https://tex.stackexchange.com/questions/345175/bibtex-url-problem even though the question itself there is not related).

    Instead of:

    note = {\url{https://mail.yahoo.com/} Accessed 24 July 2020},
    

    I should have put:

    url = {https://mail.yahoo.com/},
    urldate = {2020-07-24},
    

    So the .bib file should be:

    @misc{trialurl1,
    author = {George, Birdie},
    url = {https://mail.yahoo.com/},
    urldate = {2020-07-24},
    year = {2020},
    }
    
    @misc{trialurl2,
    author = {George, Birdie},
    title = {Hi},
    url = {https://mail.yahoo.com/},
    urldate = {2020-07-24},
    year = {2020},
    }
    
    @book{vanier,
    title = {Living Gently in a Violent World: The Prophetic Witness of Weakness},
    author = {Vanier, Jean and Hauerwas, Stanley},
    edition = {Second},
    year = {2018},
    publisher = {InterVarsity Press},
    }
    

    Then all is well.