1

Using biblatex and geometry leads to error when compiling with make4ht. The example document is:

\documentclass{article}
\usepackage{biblatex}
\usepackage{geometry}
\begin{document}
Test
\end{document}

Compiling with make4ht -x or -l option gives the following error message:

[ERROR]   htlatex: Compilation errors in the htlatex run
[ERROR]   htlatex: Filename     Line    Message
[ERROR]   htlatex: ./testbibgeom.tex    4        
File ended while scanning use of \@for.

and the .logfile has:

Runaway argument?
\CurrentOption: =\@classoptionslist \do {\@ifundefined {KV@Gm@\CurrentOption \ETC.
! File ended while scanning use of \@for.
<inserted text>
\parl.4 \begin
        {document}
I suspect you have forgotten a `}', causing me
to read past where you wanted me to stop.
I'll try to recover; but if the error is serious,
you'd better type `E' or `X' now and fix your file.

Although there are those error messages, the .html seems ok.

1
  • It seems to be caused by the recent change in biblatex-hooks.4ht, as it now requires the Nameref package to fix other issues. Strange...
    – michal.h21
    Commented Oct 27, 2021 at 20:14

1 Answer 1

2

This issue seems to be introduced by my fix for another issue. When you use BibLaTeX, TeX4ht loads the biblatex-hooks.4ht file:

\:AtEndOfPackage{%
  \def\blx@mknoautolang{%
    \blx@lbxinput{\blx@languagename}%
    {}{}%
  }%
  \def\blx@lbxinput@iii#1#2{%
  \global\csundef{blx@lng@#2}%
  \:IfFileExists{#1.lbx}
    {\blx@lbxinput@iv{#2}{#1}{language '#2' -> '#1'}}
    {\ifcsdef{blx@suffmaptried@#2}
      {}
      {\blx@warning@noline{%
          File '#1.lbx' not found!\MessageBreak
          Ignoring mapping '#2' -> '#1'}%
       \global\cslet{blx@suffmaptried@#2}\@empty}%
     \blx@lbxinput@iv{#2}{#2}{language '#2'}}}

}

\RequirePackage{nameref}

The important bit is

\RequirePackage{nameref}

At this moment, some catcodes are changed (most notably : character can be part of command names). I suspect that this leads to wrong execution of some macros in Nameref.

We still need to load Nameref before BibLaTeX, but it needs to be loaded using the usual catcodes for packages. We can achieve this thanks to the new LaTeX hook mechanism:

\AddToHook{package/before/biblatex}{\RequirePackage{nameref}}

The full biblatex-hooks.4ht now looks like this:

% biblatex-hooks.4ht (2021-10-22-14:44), generated from tex4ht-4ht.tex
% Copyright 2020 TeX Users Group
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any
% later version. The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions
% of LaTeX version 2005/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% The Current Maintainer of this work
% is the TeX4ht Project <http://tug.org/tex4ht>.
%
% If you modify this program, changing the
% version identification would be appreciated.
\immediate\write-1{version 2021-10-22-14:44}

\:AtEndOfPackage{%
  \def\blx@mknoautolang{%
    \blx@lbxinput{\blx@languagename}%
    {}{}%
  }%
  \def\blx@lbxinput@iii#1#2{%
  \global\csundef{blx@lng@#2}%
  \:IfFileExists{#1.lbx}
    {\blx@lbxinput@iv{#2}{#1}{language '#2' -> '#1'}}
    {\ifcsdef{blx@suffmaptried@#2}
      {}
      {\blx@warning@noline{%
          File '#1.lbx' not found!\MessageBreak
          Ignoring mapping '#2' -> '#1'}%
       \global\cslet{blx@suffmaptried@#2}\@empty}%
     \blx@lbxinput@iv{#2}{#2}{language '#2'}}}

}
\AddToHook{package/before/biblatex}{\RequirePackage{nameref}}

Your sample now should compile correctly.

7
  • Michal, you got me curious here. What's the relation between biblatex and nameref that leads to this requirement? Usually, nameref is loaded super late by hyperref (it comes in an AtBeginDocument inside hyperref, which should come very late in the preamble). So, for regular compilation, I'd expect nameref coming after biblatex to be the standard.
    – gusbrs
    Commented Oct 28, 2021 at 12:02
  • @gusbrs it is because I need to fix this issue with BibLaTeX's patching of \ifthenelse: tex.stackexchange.com/a/619816/2891. Maybe it would be best if BibLaTeX added test for TeX4ht, as we can put it's macro to \ifthenelse ourselves, I just thought it would be easier to fix it myself.
    – michal.h21
    Commented Oct 28, 2021 at 12:18
  • Oh, damn, and nameref also patches \ifthenelse... right. But I still sort of don't get why it has to be different from the regular compilation loading order. If biblatex can be loaded safely before nameref usually, why would it have to be otherwise for make4ht? Wouldn't some intervention in nameref.4ht do the job in a safer way? I mean, I still don't know well why hyperref arranges for nameref to be loaded that late, but I suppose there's a reason...
    – gusbrs
    Commented Oct 28, 2021 at 12:44
  • @gusbrs this issue is really strange. I still don't even understand what why it happens, so it starts to be quite frustrating. This kind of package clashes is really hard to debug. Even if I delete the whole contents of nameref.4ht or hyperref.4ht, the issue persists. If someone could find the source, I will gladly use a more clean solution :)
    – michal.h21
    Commented Oct 28, 2021 at 13:26
  • Michal, I also don't get it well. You just got me curious, because I'm also struggling with a "nameref coming so late" issue (other macro though), so it struck me as atypical. On the other hand, hyperref's "to go" recommendation for compatibility issues is "load nameref before it", so it cannot be a big deal either. :)
    – gusbrs
    Commented Oct 28, 2021 at 13:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .