6

I cannot get tex4ht to work with biblatex-chicago. Compile the MWE below with pdflatex generates the following errors:

(/usr/local/texlive/2015/texmf-dist/tex/latex/biblatex/lbx/english.lbx)))

Package biblatex Warning: Language 'american' not supported.
(biblatex)                Using fallback language 'english' on input line 14.


! Package biblatex Error: Patching 'ifthen' package failed.

See the biblatex package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.14 \begin{document}

? 

Package biblatex Warning: Patching footnotes failed.
(biblatex)                Footnote detection will not work.

! Package biblatex Error: Patching \MakeUppercase failed.

See the biblatex package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.14 \begin{document}

? 

I tried loading babel with various options but this did not change anything.

EDIT 1 My initial example was too minimal: I now realize the problem only occurs when trying to use these packages as part of a custom class.

EDIT 2 The same error occurs when just loading biblatex with the style=chicago-notes option, so I have edited the MWE to reflect that. To simplify debugging, I've put tex4ht into the MWE so that you can just run pdflatex on it directly.

File mwe.cls:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{mwe}[2016/02/10 biblatex-chicago + tex4ht test]
\LoadClass{article}
\RequirePackage[style=chicago-notes]{biblatex}
\endinput

File bib4ht.tex:

\documentclass{mwe}
\usepackage{tex4ht}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@Book{Sample,
author={Last, First},
title={Sample Book},
year=2016
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}
Test.\cite{Sample}
\end{document}
  • You shouldn't load babel with a mere english as the option: choose american or british (or canadian, or ...). Given that you hope to use biblatex-chicago, the most common thing to do would be to add \usepackage[american]{babel}. Normally, I recommend loading csquotes too, but that is not needed to make your example work. That is, your example plus \usepackage[american]{babel} makes htlatex fun without errors for me. – jon Feb 11 '16 at 2:11
  • @jon That didn't work for me. – musarithmia Feb 11 '16 at 2:24
  • Hmm, works for me: babel.sty 2016/02/01 3.9o; english.ldf 2012/08/20 v3.3p; biblatex-chicago.sty 2014/08/15 v 2.9a; biblatex2.sty 2015/12/22 v3.2; english.lbx 2015/12/22 v3.2; american.lbx 2015/12/22 v3.2; cms-american.lbx 2013/10/29 v 2.8 – jon Feb 11 '16 at 2:38
  • 2
    Hmm, I get a very different error: ! Package biblatex Error: Patching 'ifthen' package failed. (appears right after a biblatex warning that 'american' is not supported and that the package would fall back to 'english', which was just loaded.) Then errors for a failure to patch \MakeUppercase and \MakeLowercase... – jon Feb 11 '16 at 4:40
  • 2
    what is strange that this error happens only when biblatex is loaded in the class file. It compiles correctly if it is used in the package or directly in the document – michal.h21 Feb 11 '16 at 16:35
1

TL;DR Don't load biblatex from a class file when using tex4ht, unless someone can solve this problem. If I turn my class file into a package, it works fine.

biblatex with the chicago style option calls the package biblatex2.sty, and this file runs a series of tests on the class in order to patch certain commands. I think that when processing with tex4ht and using a custom class, for some reason biblatex doesn't get through these tests successfully.


Below are notes from my investigation, which might be useful to someone who wants to actually answer the question. If you do, I'll gladly reward a bounty.

I added\usepackage{tex4ht} and \tracingall to the .tex file and compiled with pdflatex. The place where the error is output happens just after line 1409146 of the .log file:

\@firstoftwo #1#2->#1
#1<-\csname etb@tgl@blx@tempa\endcsname
#2<-\etb@err@notoggle {blx@tempa}\@gobbletwo
{\csname}

\etb@tgl@blx@tempa #1#2->#1
#1<-\blx@err@patch {'ifthen' package}
#2<-

\blx@err@patch #1->\blx@error {Patching #1 failed} {This is an internal issue t
ypically caused by a conflict\MessageBreak between biblatex and some other pack
age. Modifying\MessageBreak the package loading order may fix the problem}
#1<-'ifthen' package

\blx@error #1#2->\begingroup \blx@safe@actives \PackageError {biblatex}{#1}{#2.
}\endgroup
#1<-Patching 'ifthen' package failed
#2<-This is an internal issue typically caused by a conflict\MessageBreak betwe
en biblatex and some other package. Modifying\MessageBreak the package loading
order may fix the problem
{\begingroup}
{entering semi simple group (level 1) at line 15}

All I can tell is that the error is issued because of some problem with the way etb@tgl@blx@tempa is being passed to \@firstoftwo.


The same error arises if I do what biblatex-chicago is doing internally, which is just to do \RequirePackage[style=chicago-notes]{biblatex}. Biblatex.sty, then, by default calls biblatex2.sty.

The 'ifthen' error happens after line 135 of biblatex2.sty. It is issued when \TE@hook is undefined. The only package that defines that command (I grepped all of them) is xifthen. Loading xifthen before biblatex eliminates the ifthen error.

Now there is still the footnote error, which comes from after line 154 in biblatex2.sty. Here the package is checking to see which classes are loaded, and redefining the footnote commands as needed for each. When the footnote command is successfully patched, it sets blx@tmpa to false. If, after all the test, blx@tmpa is still true, then it prints this error message about the footnotes.

  • Can you reproduce with current Biblatex (which no longer includes biblatex2.sty)? – cfr Apr 5 '16 at 1:51
  • I can now reproduce this without a custom class and get errors even without tex4ht. – cfr Apr 5 '16 at 2:04
1

As tex4ht patches some internal biblatex macros, it sometimes fails when these macros change in new biblatex versions. I reported this issue on tex4ht bug tracker and provided bugfix, which is now included in TeX distributions, so your sample compiles without errors with updated TeX Live, for example

enter image description here

  • It still doesn't work for me, after a TeXLive update. When was the bugfix added to TeXLive? – musarithmia Mar 30 '16 at 21:34
  • @AndrewCashner it worked for me, but probably because I modified your sample files. it fails again when I copy your current mwe – michal.h21 Mar 30 '16 at 22:04
  • How did you modify them? – musarithmia Mar 30 '16 at 22:07
  • I removed direct including of tex4ht in the document and probably used \usepackage[style=chicago-notes]{biblatex} – michal.h21 Mar 30 '16 at 22:19
  • This doesn't work for me. – musarithmia Apr 4 '16 at 15:32

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.