5

This question is similar to many others posted on these forums, but the answers I have seen have not solved my problem (e.g. at Converting Latex to MsWord .doc or .rtf). Please forgive me if this is repetitive, and point me in the direction of its solution. I will be deeply indebted to anyone who has ideas.

In brief, I wrote my dissertation in XeLaTeX largely because of the flexibility of biblatex. I work in a field wherein I have to cite a lot of East Asian source materials, and getting other reference managers to output these sorts of references correctly has been difficult. Biblatex works beautifully, and I'd be sorry to give it up.

However, now that I am on the other side of my dissertation, I need to submit papers (and manuscripts) for publication. In my backwards field, such papers very often need to be submitted as a Word document.

I need now to consider whether I can keep Xelatex, biblatex, and the large bibliography file I created during my dissertation as part of my workflow--even if the end product sometimes has to be a Word-readable and Word-editable document. I know of several programs that can convert an uncompiled Xelatex document to other formats (pandoc, etc.). And I know that tex4ht can convert some LaTeX documents to html or odt after running biber. But for reasons I can't understand (that may have to do with incompatibilities between Tex4ht and xelatex?), it does not seem to work on my stuff. (I am working on Windows 10 with MikTex.)

The documents I need to be able to produce are fairly simple (although cjk bibliography requires some definitions to be able to work). I don't have graphs, charts, or images to include: just Chinese and Japanese texts.

Here is an extremely minimal example that I cannot get to work. This is the latex file:

\documentclass{article}
\usepackage{xeCJK}
\setmainfont[Ligatures={Common, TeX}]{Times New Roman}
\setCJKmainfont[Scale=1]{SimSun}

\begin{document}

    Zhupo shihua 竹坡詩話

\end{document}

Of course, this extremely minimal code compiles perfectly into a pdf with Xelatex. When I then go to run htlatex on it (i.e. in the command prompt, I type: htlatex test.tex), I get the following error message:

C:\Users\lbxxx>latex  \makeatletter\def\HCode{\futurelet\HCode\HChar}\def\HChar{\ifx"\HCode\def\HCode"##1"{\Link##1}\expandafter\HCode\else\expandafter\Link\fi}\def\Link#1.a.b.c.{\g@addto@macro\@documentclasshook{\RequirePackage[#1,html]{tex4ht}}\let\HCode\documentstyle\def\documentstyle{\let\documentstyle\HCode\expandafter\def\csname tex4ht\endcsname{#1,html}\def\HCode####1{\documentstyle[tex4ht,}\@ifnextchar[{\HCode}{\documentstyle[tex4ht]}}}\makeatother\HCode .a.b.c.\input  "C:\Users\lbxxx\Desktop\Tex Testing\onlinetest.tex"
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (MiKTeX 2.9.6300 64-bit)
entering extended mode
LaTeX2e <2017-04-15>
Babel <3.9r> and hyphenation patterns for 72 language(s) loaded.
! Undefined control sequence.
<*> ...}\makeatother\HCode .a.b.c.\input  C:\Users
                                                  \lbxxx\Desktop\Tex Testing...

?

I can hit r several times and nothing at all comes out. Same basic thing for htxelatex.

Of course, the actual files I would like to be able to convert this way are much more complicated. Here would be a minimal example, this time including footnotes and bibliography (many thanks to moewe for much of this code):

\documentclass{article}
\usepackage{xltxtra}
\usepackage[fallback]{xeCJK}
\usepackage{xunicode-addon}
\setmainfont[Ligatures={Common, TeX}]{Times New Roman}
\setCJKmainfont[Scale=1]{SimSun}

\makeatletter
\newcommand\blx@unitmark{23sp} 
\makeatother

\usepackage{filecontents}
\begin{filecontents*}{chicago-notes.dbx}
\ProvidesFile{chicago-notes.dbx}[2016/07/24 extended name format for biblatex]
\DeclareDatamodelConstant[type=list]{nameparts}{prefix,family,suffix,given,cjk}
\end{filecontents*}
\begin{filecontents*}{\jobname.bib}
@book{zhaos,
  title={A Nation-State by Construction: Dynamics of Modern Chinese Nationalism},
  author={given=Suisheng, family=Zhao, cjk=趙歲升},
  isbn={9780804750011},
  year={2011},
  address = {Stanford},
  publisher={Stanford University Press}}
@book{ZhupoShihua,
    author = {family=Zhou, cjk=周紫芝, given=Zizhi},
    title = {Zhupo shihua},
    titleaddon = {竹坡詩話},
    series = {Yinying Wenyuange Siku quanshu edition},
    year = {1985},
    address = {Taibei},
    publisher = {Taiwan shangwu yinshu guan}
}
@book{jim,
  title={Lorem},
  author={Smith, Junior, Jim},
  year={2009},
  address = {Stanford},
  publisher={Stanford University Press}}
\end{filecontents*}

\usepackage[notes,strict,annotation,cmsdate=both,isbn=false, backend=biber]{biblatex-chicago}
\addbibresource{\jobname.bib}

% Based on definitions from biblatex.def

\newbibmacro*{name:cjk}[3]{%
    \usebibmacro{name:delim}{#2#3#1}%
    \usebibmacro{name:hook}{#2#3#1}%
    \mkbibnamefamily{#1}%
    \ifdefvoid{#2}{}{\bibnamedelimd\mkbibnamegiven{#2}}%
    \ifdefvoid{#3}{}{\bibnamedelimd\mkbibnamecjk{#3}}}

\DeclareNameFormat{given-family}{%
  \ifdefvoid{\namepartcjk}
    {\iffirstinits
        {\usebibmacro{name:given-family}
           {\namepartfamily}
           {\namepartgiveni}
           {\namepartprefix}
           {\namepartsuffix}}
        {\usebibmacro{name:given-family}
           {\namepartfamily}
           {\namepartgiven}
           {\namepartprefix}
           {\namepartsuffix}}}
    {\usebibmacro{name:cjk}{\namepartfamily}{\namepartgiven}{\namepartcjk}}%
  \usebibmacro{name:andothers}}

\DeclareNameFormat{family-given}{%
  \ifdefvoid{\namepartcjk}
    {\iffirstinits
        {\usebibmacro{name:family-given}
           {\namepartfamily}
           {\namepartgiveni}
           {\namepartprefix}
           {\namepartsuffix}}
        {\usebibmacro{name:family-given}
           {\namepartfamily}
           {\namepartgiven}
           {\namepartprefix}
           {\namepartsuffix}}}
    {\usebibmacro{name:cjk}{\namepartfamily}{\namepartgiven}{\namepartcjk}}%
  \usebibmacro{name:andothers}}

\DeclareNameFormat{family-given/given-family}{%
  \ifdefvoid{\namepartcjk}
    {\ifnumequal{\value{listcount}}{1}
        {\iffirstinits
           {\usebibmacro{name:family-given}
             {\namepartfamily}
             {\namepartgiveni}
             {\namepartprefix}
             {\namepartsuffix}}
          {\usebibmacro{name:family-given}
             {\namepartfamily}
             {\namepartgiven}
             {\namepartprefix}
             {\namepartsuffix}}
         \ifboolexpe{%
                     test {\ifdefvoid\namepartgiven}
                     and
                     test {\ifdefvoid\namepartprefix}}
           {}
           {\usebibmacro{name:revsdelim}}}
        {\iffirstinits
          {\usebibmacro{name:given-family}
             {\namepartfamily}
             {\namepartgiveni}
             {\namepartprefix}
             {\namepartsuffix}}
          {\usebibmacro{name:given-family}
             {\namepartfamily}
             {\namepartgiven}
             {\namepartprefix}
             {\namepartsuffix}}}}
    {\usebibmacro{name:cjk}{\namepartfamily}{\namepartgiven}{\namepartcjk}}%
  \usebibmacro{name:andothers}}

\DeclareFieldFormat[book]{title}{%
    \mkbibemph{#1}%
    \iffieldundef{titleaddon}{\isdot}{\nopunct}}

\DeclareFieldFormat{booktitle}{%
    \mkbibemph{#1}%
    \iffieldundef{booktitleaddon}{}{\nopunct}}

\DeclareFieldFormat{maintitle}{%
    \mkbibemph{#1}%
    \iffieldundef{maintitleaddon}{}{\nopunct}}

\DeclareFieldFormat[article]{title}{%
    \iffieldundef{title}{}{\mkbibquote{#1}}%
    \iffieldundef{titleaddon}{\isdot}{\nopunct}}

\DeclareFieldFormat{usere}{\mkbibparens{#1}}


\begin{document}
    \cite{zhaos,jim,ZhupoShihua}

    \cite{zhaos,jim,ZhupoShihua}\footnote{\cite{zhaos,jim,ZhupoShihua}}

    \printbibliography
\end{document}

So, in short, is there any way to be able to continue to use biblatex with my cjk-materials but output to .html, .odt, .rtf, or .doc? I am not particular about the formatting of the final document, except that the text needs to be there and footnotes need to be footnotes. Please do not suggest converting the final pdf to word--I'd rather type in all my bibliographic material by hand than have to deal with all the headaches that causes.

Anyone who can solve this will have my eternal gratitude.

  • 1
    htlatex is certainly the wrong application for a xelatex file. Also avoid spaces in folder and file names, and don't pass absolute pathes. Call it as htlatex ... file.tex. I get errors at the cjk-font but I don't know if this is a bug or due to wrong use. We will have to wait for @michal-h21 to show the current state-of-the-art-call. – Ulrike Fischer May 3 '17 at 8:47
  • @UlrikeFischer yes, htlatex processes file with latex, so it certainly can't work. One should use make4ht -x to compile XeLaTeX file. The issue with path in Windows is strange, I don't remember if I ever seen that. This might be some htlatex in Miktex issue, I guess it shouldn't happen with make4ht. Other than that, the file almost works, it needs only some fixes for xeCJK and biblatex-chicago. I am working on that. – michal.h21 May 3 '17 at 9:57
  • @michal.h21: I don't get the issue with the path but it is perhaps due to the spaces. But when I compile make4ht -x test-utf8 on miktex I get an ! I can't find file ${tex_file}'. error. With texlive 17 it compiles but stops at the first cjk char with a missing endcsname. – Ulrike Fischer May 3 '17 at 10:16
  • @UlrikeFischer it seems that make4ht in Miktex is broken. I've updated in on CTAN last week, is it possible that Miktex uses this version? What does make4ht -v print? – michal.h21 May 3 '17 at 10:41
  • @michal.h21: It shows that it finds some local version of make4ht but I don't know yet why (and how to avoid it). Will have to debug in the evening ... – Ulrike Fischer May 3 '17 at 11:17
6

Your main issue is that you can't include the TeX file in the compilation. I can't reproduce this issue, I guess that it is some issue with spaces in your file path.

Anyway, once you manage to actually compile your document, you will face some issues. There are some minor issues with biblatex package and big issue with xeCJK package, which causes tex4ht to fail. Both of these issues can be fixed easily with some custom configurations.

Save the following files to your document's directory:

`usepackage.4ht`

% usepackage.4ht (2017-01-31-15:40), generated from tex4ht-4ht.tex
% Copyright 2003-2009 Eitan M. Gurari
% Copyright 2009-2017 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.
   \def\:temp{tex4ht}\ifx \:temp\@currname
   \:warning{\string\usepackage{tex4ht} again?}
   \def\:temp#1htex4ht.def,tex4ht.sty#2!*?: {\def\:temp{#2}}
\expandafter\:temp \@filelist htex4ht.def,tex4ht.sty!*?: %
\ifx \:temp\empty  \else
   \:warning{if
    \string\RequirePackage[tex4ht]{hyperref} or
    \string\usepackage[tex4ht]{hyperref} was
    used try instead, repectively,
    \string\RequirePackage{hyperref} or
    \string\usepackage{hyperref}}
\fi

\fi
\gdef\a:usepackage{\use:package xr,xr-hyper,savetrees,fontspec,xeCJK,biblatex,,!*?: }
\gdef\use:package#1,{%
   \if :#1:\def\:temp##1!*?: {}\else
      \def\:temp{#1}\ifx \@currname\:temp
             \def\:temp##1!*?: {\input usepackage.4ht  }%
      \else \let\:temp=\use:package \fi
   \fi \:temp}
\def\:temp{xr}\ifx \@currname\:temp
   \AtEndOfPackage{\let\XR:\XR@
   \def\XR@[#1]#2{%
    \Configure{AtBeginDocument}{\XR:[#1]{#2}}{}}%
}

\fi
\def\:temp{xr-hyper}\ifx \@currname\:temp
   \def\eat:optional[#1]{}
\AtEndOfPackage{\let\XR:\XR@
   \def\XR@[#1]#2{%
     \Configure{AtBeginDocument}{\XR:[#1]{#2}}{}\@ifnextchar[\eat:optional{}}%
}

\fi
\def\:temp{savetrees}\ifx \@currname\:temp
\:dontusepackage{savetrees}
\fi
\def\:temp{fontspec}\ifx \@currname\:temp
  \ifdefined\fontspec
    \:dontusepackage{fontspec}
  \else
    \input usepackage-fontspec.4ht
  \fi
\fi

\def\:temp{xeCJK}\ifx \@currname\:temp
\AtEndOfPackage{%
  \RequirePackage{fontspec}
}
\:dontusepackage{xeCJK}
\newcommand\setCJKmainfont[2][]{}
%\def\Hinput#1{}
%\input tuenc-xetex.4ht

\AtBeginDocument{%
\xeuniuseblock{CJK}
}
\fi

\def\:temp{biblatex}\ifx \@currname\:temp
\AtEndOfPackage{
  \def\blx@mknoautolang{%
    \blx@lbxinput{\blx@languagename}
    {}
    {}
}
}
\fi

\endinput

and configuration file for biblatex, biblatex.4ht:

% biblatex.4ht (2016-03-16-10:08), generated from tex4ht-4ht.tex
% Copyright 2007-2009 Eitan M. Gurari
% Copyright 2009-2016 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 2016-03-16-10:08}

   \ifdim\abx@version pt< 3pt \xdef\blx:ver:no{2}\else\xdef\blx:ver:no{3}\fi
\ifx\a:printshorthands\Undef\let\blx@shorthands\@empty\fi
\ifx\blx@startbib\:UnDef
 \pend:def\blx@shorthands{%
   \pend:def\blx@bibinit{%
       \HAssign\shorthands:cnt=0
       \NewConfigure{printfield-shorthand}{2}%
       \Configure{printfield-shorthand}%
         {\gHAdvance\shorthands:cnt by 1\relax
          \ifnum \shorthands:cnt=1 \a:printshorthands
          \else                    \c:printshorthands \fi
         }
         {\d:printshorthands}%
   \append:def\endtheshorthands{\b:printshorthands}%
   \csname a:@shorthands\endcsname}
}
\ifx\b:printshorthands\Undef\let\endtheshorthands\@empty\fi
\def\a:entryhead{CVR}
\def\a:entryhead:full{CV Radhakrishnan}
\ifx\bib@macro@entryhead:name\UnDef
  \let\bib@macro@entryhead:name\@empty\fi
\ifx\bib@macro@entryhead:full\UnDef
  \let\bib@macro@entryhead:full\@empty\fi
  \gdef\BibFileName[#1]#2{\expandafter\xdef\csname
       BibFileName#1\endcsname{#2}}
\newcount\sv:sec:cnt
\def\bibSecConfigure{%
  \let\save:section\section
  \global\sv:sec:cnt=\c@secnumdepth
  \def\section{\@ifstar
      {\c@secnumdepth=0\relax\save:section}%
      {\c@secnumdepth=\sv:sec:cnt\save:section}}%
}
\gHAssign\bibN=0
  \:CheckOption{ooffice}\if:Option
   \def\bibConfigure{\ConfigureList{thebibliography}%
      {\IgnorePar\EndP \gHAdvance\bib:N by 1
       \HCode{<text:bibliography text:name="bib-\bib:N" >
              <text:bibliography-source>\Hnewline
             <text:index-title-template>}
           \NoFonts\ref:name\EndNoFonts
       \HCode{</text:index-title-template>\Hnewline
%
           <text:bibliography-entry-template\Hnewline
            text:bibliography-type="custom1"
            text:style-name="Bibliography11">\Hnewline
%
            <text:index-entry-bibliography
             text:bibliography-data-field="identifier"/>\Hnewline
%
           <text:index-entry-span>: </text:index-entry-span>\Hnewline
           <text:index-entry-bibliography
            text:bibliography-data-field="author" />\Hnewline
           <text:index-entry-span>, </text:index-entry-span>\Hnewline
%
           <text:index-entry-bibliography
            text:bibliography-data-field="title" />\Hnewline
           <text:index-entry-span>, </text:index-entry-span>\Hnewline
%
           <text:index-entry-bibliography
            text:bibliography-data-field="year" />\Hnewline
           </text:bibliography-entry-template>\Hnewline\Hnewline
           </text:bibliography-source>\Hnewline
           <text:index-body>\Hnewline}%
         \let\en:bib=\empty
      }%
      {\en:bib\HCode{</text:index-body></text:bibliography>}}
      {\en:bib\gdef\en:bib{\HCode{</text:p>\Hnewline}}%
        \HCode{<text:p text:style-name="p-bibitem">}%
        \gHAdvance\bibN by 1
        \HCode{<text:reference-mark
          text:name="X0-\csname BIB-\bibN\endcsname">%
          </text:reference-mark>}%
      }%
      {}{}
  }

  \else
    \def\bibConfigure{%
  \ConfigureList{thebibliography}
  {\ifvmode \IgnorePar \fi \EndP \EndP
    \HCode {<dl class="thebibliography">}%
%
% This is for linking citations with biblist items which
% are in a different file when output is split into different
% chunks. [CVR 2012-09-27]
%
%
% <biblatex-2.2>
%
  \immediate\write\@auxout{%
      \string\BibFileName[\therefsection]{\FileName}}%
%
% </biblatex-2.2>
%
    \PushMacro \end:itm \global \let \end:itm =\empty}%
  {\ifvmode \IgnorePar \fi \EndP
    \PopMacro \end:itm \global \let \end:itm \end:itm \EndP
    \HCode {</dd></dl>}\ShowPar}%
  {\ifvmode \IgnorePar \fi \EndP \gHAdvance \bibN by 1
    \end:itm \global \def \end:itm {\EndP \Tg </dd>}%
    \HCode {<dt id="X\therefsection-\abx@field@entrykey"
      class="thebibliography">}\bgroup \bf}%
  {\ifvmode \IgnorePar \fi \EndP
    \egroup
    \HCode {</dt><dd\Hnewline id="bib-\bibN"
      class="thebibliography">}%
    \par \ShowPar}%
 }

 \fi
\NewConfigure{printshorthands}{4}
\NewConfigure{@shorthands}[1]{\concat:config\a:@shorthands{#1}}
\let\a:@shorthands\empty
\def\nolinkurl{\o:url:}
% \def\blx@checksum{\ifx \blx@checksum@old \blx@checksum@new \else
%   \blx@warning@noline {Page references have changed.\MessageBreak
%     Rerun to get references right}\@tempswatrue \blx@reruntrue \fi
%   \@nameuse {blx@rerun}}
\def\blx@checksum#1#2#3{%
  \begingroup
  \blx@tempcnta\the\numexpr0#2*0#3\relax
  \blx@tempcntb\blx@tempcnta
  \divide\blx@tempcntb10
  \multiply\blx@tempcntb10
  \advance\blx@tempcnta-\blx@tempcntb
  \xdef#1{#1\the\blx@tempcnta}%
  \endgroup}
\pend:def\blx@bibliography{\bibSecConfigure%
  \pend:def\blx@bibinit{%
    \bibConfigure
     \csname onthebibliography:list\endcsname
  }%
}
\let\en:bib\@empty
\newcounter{bib}
\ifnum\blx:ver:no < 3
 \protected\def\blx@bbl@entry#1#2#3{%
  \begingroup
  \def\texht@bibkey{#1}
  \edef\abx@field@entrykey{\detokenize{#1}}%
  \global\advance\c@bib 1
  \immediate\write\@auxout{\string\expandafter\string\gdef
    \string\csname\space BIB-\thebib\string\endcsname
     {\expandafter\strip@prefix\meaning\texht@bibkey}}%
  \Tag{)QX\therefsection-#1}{\thebib}%
  \blx@setoptions@type{#2}%
  \blx@bbl@options{#3}%
  \blx@setoptions@entry
  \edef\blx@bbl@data{blx@data@\the\c@refsection @\abx@field@entrykey}%
  \csuse\blx@bbl@data
  \cslet\blx@bbl@data\@empty
  \blx@bbl@addfield{entrykey}{\abx@field@entrykey}%
  \blx@bbl@addfield{entrytype}{#2}%
  \blx@imc@iffieldundef{options}
    {}
    {\blx@bbl@fieldedef{options}{\expandonce\abx@field@options}}}
%
 \protected\def\blx@finentry{%
  \unspace
  \a:finentry
      \finentrypunct
      \blx@postpunct
  \b:finentry
  \blx@initunit
 }
%
\else
% Biblatex 3.0
%
% Hacks for biblatex
% MakeUppercase is redefined by tex4ht, biblatex tries to redefine it as well, but it relies on original
% LaTeX version:
\DeclareRobustCommand{\MakeUppercase}[1]{{%
    \def\i{I}\def\j{J}%
    \def\reserved@a##1##2{\let##1##2\reserved@a}%
    \expandafter\reserved@a\@uclclist\reserved@b{\reserved@b\@gobble}%
    \protected@edef\reserved@a{\uppercase{#1}}%
    \reserved@a
}}
% Same applies also for \MakeLowercase
\DeclareRobustCommand{\MakeLowercase}[1]{{%
    \def\reserved@a##1##2{\let##2##1\reserved@a}%
    \expandafter\reserved@a\@uclclist\reserved@b{\reserved@b\@gobble}%
    \protected@edef\reserved@a{\lowercase{#1}}%
    \reserved@a
}}

% I don't really understand this, but language processing is broken by default
% with biblatex. It loads language file, but it executes code which should be
% executed only in the case if the language file fails, it displays an error message
% and language handling doesn't work. When we execute following code, the language
% files are loaded before checking of the success and it seems to work.

\@ifpackageloaded{babel}
      {% This is required for languages which are never explicitly selected
        \def\do#1{\blx@lbxinput{#1}{}{}}%
       \ifdefined\bbl@loaded%
       \expandafter\docsvlist\expandafter{\bbl@loaded}%
      \fi}{}%



% Following macros doesn't seem to work with biblatex 3.4. We should make another test for
% biblatex > 3.0 and < 3.3
\ifdim\abx@version pt < 3.3pt
 \protected\def\blx@bbl@entry#1#2#3{%
  \begingroup
  \edef\abx@field@entrykey{\detokenize{#1}}%
  \blx@setoptions@type{#2}%
  \blx@bbl@options{#3}%
  \blx@setoptions@entry
  \edef\blx@bbl@data{blx@data@\the\c@refsection @\blx@slist@scheme
    @\abx@field@entrykey}%
  \csuse\blx@bbl@data
  \blx@bbl@addfield{entrykey}{\abx@field@entrykey}%
  \blx@bbl@addfield{entrytype}{#2}%
  \blx@imc@iffieldundef{options}
    {}
    {\blx@bbl@fieldedef{options}{\expandonce\abx@field@options}}}
%
 \protected\def\blx@bbl@endentry{%
  \csuse\blx@bbl@data
  \ifcsundef{blx@pref@\the\c@refsection @\abx@field@entrykey}
    {}
    {\blx@addpageref{\abx@field@entrykey}}%
  \nottoggle{blx@setonly}
    {\listcsxadd{blx@slists@\the\c@refsection @entry@\blx@slist@scheme}%
      {\abx@field@entrykey}}
    {\global\toggletrue{blx@addset}%
     \toggletrue{blx@skipbib}%
     \toggletrue{blx@skipbiblist}%
     \toggletrue{blx@skiplab}}%
  \nottoggle{blx@skipbib}
    {\listcsxadd{blx@slistsbib@\the\c@refsection @entry@\blx@slist@scheme}%
      {\abx@field@entrykey}%
     \listcsxadd{blx@type@\the\c@refsection @\abx@field@entrytype}%
       {\abx@field@entrykey}%
     \ifdef\abx@field@entrysubtype
       {\listcsxadd{blx@subt@\the\c@refsection
           @\abx@field@entrysubtype}%
         {\abx@field@entrykey}}
       {}}
    {}%
  \nottoggle{blx@skipbiblist}
    {\blx@bbl@labelfields}
    {}%
  \nottoggle{blx@skiplab}
    {\iftoggle{blx@labelnumber}
      {\blx@bbl@labelnumber}
      {}%
    \iftoggle{blx@labelalpha}
      {\blx@bbl@labelalpha}
      {}%
    \iftoggle{blx@labeltitle}
      {\blx@bbl@labeltitle}
      {}%
    \iftoggle{blx@labeltitleyear}
      {\blx@bbl@labeltitleyear}
      {}%
    \iftoggle{blx@labeldate}
      {\blx@bbl@labeldate}
      {}%
    \blx@bbl@prefixnumber}
    {}%
  \blx@bbl@titles
  \blx@bbl@hooks
  \endgroup}
  \fi
\fi % end of version boolean
\NewConfigure{finentry}{2}
\def\:tempc[#1]#2{%
   \expandafter\ifx \csname a:printfield-#2\endcsname\relax
      \NewConfigure{printfield-#2}{2}%
      \a:printfield{printfield-#2}%
   \fi
   \Configure{blx@unit}%
       {\csname a:printfield-#2\endcsname}%
       {\csname b:printfield-#2\endcsname}%
   \csname o:\string\blx@printfield:\endcsname[#1]{#2}%
}
\expandafter\HLet\csname\string\blx@printfield\endcsname\:tempc
\NewConfigure{printfield}[1]{\def\a:printfield##1{#1}}
\Configure{printfield}{%
    \Configure{#1}%
       {\HCode{<!--#1-->}}%
       {\HCode{<!--/#1-->}}%
}
\def\:tempc[#1]#2{%
   \expandafter\ifx \csname a:bibstring-#2\endcsname\relax
      \NewConfigure{bibstring-#2}{2}%
      \a:printfield{bibstring-#2}%
   \fi
   \Configure{blx@unit}%
       {\csname a:bibstring-#2\endcsname}%
       {\csname b:bibstring-#2\endcsname}%
   \csname o:\string\blx@bibstring:\endcsname[#1]{#2}%
}
\expandafter\HLet\csname\string\blx@bibstring\endcsname\:tempc
\def\:tempc[#1]#2{%
   \expandafter\ifx \csname a:bibcpstring-#2\endcsname\relax
      \NewConfigure{bibcpstring-#2}{2}%
      \a:printfield{bibcpstring-#2}%
   \fi
   \Configure{blx@unit}%
       {\csname a:bibcpstring-#2\endcsname}%
       {\csname b:bibcpstring-#2\endcsname}%
   \csname o:\string\blx@bibcpstring:\endcsname[#1]{#2}%
}
\expandafter\HLet\csname\string\blx@bibcpstring\endcsname\:tempc
\def\:tempc[#1]#2{%
   \expandafter\ifx \csname a:biblcstring-#2\endcsname\relax
      \NewConfigure{biblcstring-#2}{2}%
      \a:printfield{biblcstring-#2}%
   \fi
   \Configure{blx@unit}%
       {\csname a:biblcstring-#2\endcsname}%
       {\csname b:biblcstring-#2\endcsname}%
   \csname o:\string\blx@biblcstring:\endcsname[#1]{#2}%
}
\expandafter\HLet\csname\string\blx@biblcstring\endcsname\:tempc
\def\:tempc[#1]#2{%
   \expandafter\ifx \csname a:bibucstring-#2\endcsname\relax
      \NewConfigure{bibucstring-#2}{2}%
      \a:printfield{bibucstring-#2}%
   \fi
   \Configure{blx@unit}%
       {\csname a:bibucstring-#2\endcsname}%
       {\csname b:bibucstring-#2\endcsname}%
   \csname o:\string\blx@bibucstring:\endcsname[#1]{#2}%
}
\expandafter\HLet\csname\string\blx@bibucstring\endcsname\:tempc
\NewConfigure{biblatex-style}[2]{%
   \def\:temp{#1}%
   \ifx \:temp\blx@cbxfile
      #2%
      \global\let\biblatex:style\def
   \fi
}

\def\biblatex:style{}
\Configure{biblatex-style}{}{}

\pend:def\at:docend{%
   \ifx \UnDef\biblatex:style
      \:warning{\string\Configure{biblatex-style}{\blx@cbxfile}{...}
         not available}%
   \fi
}
\let\blx:item\@item
\def\@item[#1]{%
  \blx:item[#1]%
  \ifhmode \spacefactor\blx@sf@par\fi
}
\let\blx@resetpuncthook\@empty
\let\blx@csq@ifkernmark\@empty
\newskip\blx@unitmark
\blx@unitmark=10pt plus 1pt minus 1pt
\let\abx@aux@page\@gobbletwo
\let\abx@aux@fnpage\@gobbletwo
\let\abx@aux@refsection\@gobbletwo
%
% <Kristian.Debrabant@cs.kuleuven.be> reported that After updating
% biblatex and biblatex.ht to versions 2.2 respectively
% 2012-09-28-17:49 (using MiKTeX 2.9 64 bit), tex4ht seemed no longer
% respected the defernumbers option in biblatex.sty: When applied to
% the attached file tex4hterror.tex.
%
% The problem was due to nullifying \abx@aux@number which in fact
% should have been redefined to \blx@aux@number when defernumbers
% option is true.
%
% This is done now and as per Kristian, the fix works fine now.
%
\ifnum\blx:ver:no < 3
%
 \protected\def\blx@aux@number#1#2#3#4{%
  \blx@bbl@addentryfield{\detokenize{#2}}{#3}{localnumber}{#4}%
  \ifblank{#4}%
    {}%
    {\csgdef{blx@labelnumber@#3}{#4}%
     %\blx@addchecksum{#1}{#4} % this can cause a nodocument error!
     }}
%
 \iftoggle{blx@defernumbers}%
    {\setkeys{blx@opt@pre}{labelnumber}%
     \let\blx@thelabelnumber\blx@addlabelnumber
     \let\abx@aux@number\blx@aux@number}%
    {\let\blx@thelabelnumber\relax
     \let\abx@aux@number\@gobblefour}
%
\else
  \def\@gobblefive#1#2#3#4#5{}%
 \protected\def\blx@aux@number#1#2#3#4#5{%
   \blx@bbl@addentryfield{\detokenize{#2}}{#3}{localnumber}{#4}{#5}%
   \blx@bbl@addentryfield{\detokenize{#2}}{#3}{labelnumber}{#4}{#5}%
   \global\toggletrue{blx@localnumber}%
   \ifblank{#5}
    {}
    {\csgdef{blx@labelnumber@#3@#4}{#5}}}

 \iftoggle{blx@defernumbers}%
    {\setkeys{blx@opt@pre}{labelnumber}%
     \let\blx@thelabelnumber\blx@addlabelnumber
     \let\abx@aux@number\blx@aux@number}%
    {\let\blx@thelabelnumber\relax
     \let\abx@aux@number\@gobblefive}
\fi % end of version boolean
%
\AtEndDocument{%
  \def\abx@aux@page#1#2{\blx@addpagesum{#1}{#2}}%
  \def\abx@aux@fnpage#1#2{\blx@addpagesum{#1}{#2}}%
}
%
\def\blx@begunit{%
  \toggletrue{blx@tempa}%
  \iftoggle{blx@insert}%
    {\iftoggle{blx@unit}%
       {\begingroup
          \let\blx@begunit\@empty
          \let\blx@endunit\@empty
          \let\blx@endnounit\@empty
          \blx@unitpunct\blx@postpunct
        \endgroup
        \global\togglefalse{blx@unit}%
        \togglefalse{blx@tempa}}
       {\blx@postpunct}%
     \iftoggle{blx@block}%
       {\begingroup
          \let\blx@begunit\@empty
          \let\blx@endunit\@empty
          \let\blx@endnounit\@empty
          \newblockpunct
        \endgroup
        \global\togglefalse{blx@block}%
        \togglefalse{blx@tempa}}%
       {}}%
    {}%
  \blx@postpunct
  \blx@resetpuncthook
  \iftoggle{blx@tempa}%
    {}%
    {\global\togglefalse{blx@insert}}%
  \csname a:blx@unit\endcsname
  \blx@leavevmode
  \blx@csq@ifkernmark
    {}%
    {\penalty\@M
    \hskip-\blx@unitmark\relax
    \hskip\blx@unitmark\relax
    }%
  \begingroup
    \Configure{blx@unit}{}{}%
}
\def\blx@endunit{%
  \endgroup
  \csname b:blx@unit\endcsname
  \Configure{blx@unit}{}{}%
  \ifdim\lastskip=\blx@unitmark
    \unskip\unskip\unpenalty
    \global\togglefalse{blx@lastins}%
  \else
   \global\toggletrue{blx@insert}%
   \global\toggletrue{blx@lastins}%
 \fi
}
\NewConfigure{blx@unit}{2}
%
   \else
\fi


   \NewConfigure{thebibliography}{4}
\append:def\blx@bibinit{\a:bibinit}%
\NewConfigure{bibinit}{1}%

   \let\blx@anchors\@empty
\let\bib@field@entrykey\@empty

\protected\def\blx@anchor{%
  \xifinlist{X\the\c@refsection -%@
    \bib@field@entrykey}{\blx@anchors}%
    {}%
    {\listxadd\blx@anchors{X\the\c@refsection -%@
      \bib@field@entrykey}%
     \hyper:natanchorstart{X\the\c@refsection -%@
      \bib@field@entrykey}%
     \hyper:natanchorend}}

\protected\def\blx@bibhyperref{%
   \@ifnextchar[%]
     {\blx@bibhyperref@i}%
     {\blx@bibhyperref@i[\bib@field@entrykey]}}%

\long\def\blx@bibhyperref@i[#1]#2{%
   \hyper:natlinkstart{X\the\c@refsection -%@
     #1}%
     #2\hyper:natlinkend}%

\protected\long\def\blx@bibhyperlink#1#2{%
   \hyper:natlinkstart{X\the\c@refsection -%:
     #1}%
     #2\hyper:natlinkend}%

\protected\long\def\blx@bibhypertarget#1#2{%
   \@bsphack
   \hyper:natanchorstart{X\the\c@refsection -%:
     #1}%
   \@esphack
     #2\hyper:natanchorend}%

\let\blx@ifhyperref\@firstoftwo

% Oleg Domanov odomanov@yandex.ru reports:
% tex4ht ends with an error when compiles biblatex files. I'm on
% Windows, texlive 2012. I put here a minimal example and files
% generated with the command latexmk test && mk4ht oolatex test
%
% https://www.dropbox.com/s/hn1zm40htqs13mf/t4htlink.zip
%
% There is a superfluous \relax in the file test.tmp, line 65 which
% seems to cause the error.
%
% Changes to cope with biblatex upgrade caused this problem. It is now
% fixed. --CVR 2012/10/26
%
\:CheckOption{ooffice}\if:Option
 \def\hyper:natanchorstart#1{\Link{}{#1}\EndLink}%
 \def\hyper:natlinkstart#1{\Link{#1}{}}%
\else
 \def\hyper:natanchorstart#1{%
      \expandafter\ifx\csname QXpage.\thepage\endcsname\relax%
        \Tag{)Qpage.\thepage}{\file:id}%
        \HCode{<a id="page.\thepage"></a>}%
        \expandafter\xdef\csname QXpage.\thepage\endcsname{0}%
       \fi
      \Link[\csname BibFileName\therefsection\endcsname]{}{#1}\EndLink}
 \def\hyper:natlinkstart#1{%
      \expandafter\ifx\csname QXpage.\thepage\endcsname\relax%
        \Tag{)Qpage.\thepage}{\file:id}%
        \HCode{<a id="page.\thepage"></a>}%
        \expandafter\xdef\csname QXpage.\thepage\endcsname{0}%
       \fi
      \Link[\csname BibFileName\therefsection\endcsname]{#1}{}}
\fi
\def\hyper:natanchorend{}
\def\hyper:natlinkend{\EndLink}
\def\writeCiteLink#1{\immediate\write\@mainaux{%
    \string\@namedef{#1.\thepage}{\FileName}}}
\let\blx@addpagesum\@gobbletwo
\let\nolinkurl\relax

\ifx\blx:ver:no < 3
%
% biblatex 2.9a
%
% Newly added to process {keylist} environment (CVR)
%
\let\keylist\description
\let\endkeylist\enddescription
\def\keyitem#1{\item[#1]}%
%
%
\else
%
% biblatex 3.0
%
\let\keylist\Un:def
\let\endkeylist\Un:def
\newenvironment*{keylist}
  {\list{}{%
     \setlength{\labelwidth}{1.25in}%
     \setlength{\labelsep}{10pt}%
     \setlength{\leftmargin}{0pt}%
     \setlength{\itemsep}{0pt}%
     \raggedright%
     \renewcommand*{\makelabel}[1]{\hss\bfseries##1}}}
  {\endlist}
%
\def\keyitem#1{%
  \item[#1]
  \begingroup
    \keyitemhook%
    \blx@bibinit%
    \midsentence\ifbibstring{#1}{}{\latintext}\biblstring{#1}%
    \expandafter\lbx@initnamehook\lsmartoftext%
    \par\nobreak
    \midsentence\ifbibstring{#1}{}{\latintext}\bibsstring{#1}%
    \expandafter\lbx@initnamehook\ssmartoftext%
  \endgroup
  \par\nobreak}
\fi  % End of version boolean

\ConfigureList{keylist}%
   {\EndP\HCode{<dl \a:LRdir class="description">}%
      \PushMacro\end:itm
\global\let\end:itm=\empty}%
   {\PopMacro\end:itm \global\let\end:itm \end:itm
\EndP\HCode{</dd></dl>}\ShowPar}%
   {\end:itm \global\def\end:itm{\EndP\Tg</dd>}\HCode{<dt
        class="description">}\bgroup \bf}%
   {\egroup\EndP\HCode{</dt><dd\Hnewline class="description">}}

   \let\:temp\do
  \def\do#1{%
    \patchcmd#1%
      {\color@begingroup}%
      {\color@begingroup\toggletrue{blx@footnote}}%
      {\togglefalse{blx@tempa}\listbreak}%
      {}}%
  \docsvlist{%
    \@footnotetext,%          latex
    \H@@footnotetext,%        hyperref
    \scr@saved@footnotetext,% koma-script 3.x
    \l@dold@footnotetext,%    ledmac
    \l@doldold@footnotetext,% ledmac
    \@fntORI}%                frenchle
\let\do\:temp

\Hinput{biblatex}
\endinput

Now, instead of htxelatex, I would use make4ht. It is much more flexible. You will need a build file to enable biber compilation and to enable both odt and html output. Save the following file as mybuild.mk4:

Make:add("biber", "biber ${input}")

if mode:match "odt" then
  settings.tex4ht_sty_par = settings.tex4ht_sty_par .. ",ooffice" 
  settings.t4ht_par = settings.t4ht_par  .. " -coo -cooxtpipes"
end

if mode:match "draft" then
  Make:htlatex {}
else
  Make:htlatex {}
  Make:biber {}
  Make:htlatex {}
end

With make4ht, you can use --mode or -m command line option. This selects which compiling sequence will be used. You will also need to use -u for Unicode output and -x for XeLaTeX. Basic compilation would be thus:

make4ht -ux -e mybuild.mk4 filename.tex

This will compile the document as HTML and it will run biber after first LaTeX compilation. On subsequent compilations, when the bibliography doesn't change and it is thus unnecessary to run biber, you can use draft mode:

make4ht -uxm draft -e mybuild.mk4 filename.tex

To get an ODT document, you can add odt to the draft option:

make4ht -uxm odt-draft -e mybuild.mk4 filename.tex

This is the resulting HTML:

enter image description here

Edit:

It seems that your distribution is missing some files distributed with tex4ht, so you may also need this one, usepackage-fontspec.4ht. It seems that there is a limit on how many characters post can contain, so I had to upload it to Gist.

  • thank you so much for looking into this. Unfortunately, I'm still unable to make it work on my machine--make4ht is returning all sorts of errors trying to find the files. I'm guessing you probably aren't on Windows 10 yourself, but do you have any advice as to where I should put usepackage.4ht, biblatex.4ht, mybuild.mk4, and the tex file I want to compile? Also, I got rid of the space in my folder name, but this doesn't solve the input problem. And a further input problem comes up when mk4ht tries to find biblatex\lbx\english. On Windows, MikTex path is \MikTex 2.9\--with space – LukeB May 3 '17 at 15:05
  • @LukeB I would create some temporary directory directly in the root dir, like c:\mytexfiles and put all the files here. – michal.h21 May 3 '17 at 15:11
  • That's actually what I am doing. C:\textesting; everything is in there. So I open cmd, type prompt C:\WINDOWS\system32>make4ht -ux -e C:\textesting\mybuild.mk4 C:\textesting\onlinetest.tex . It says "using build file C/textesting/mybuild.mk4" but then gives me "undefined control sequence charset=utf-8.a.b.c.\input C:\textesting \onlinetest.tex – LukeB May 3 '17 at 15:18
  • I can actually get it to input the file if I don't have it find it the first time, e.g. "C\WINDOWS\system32>make4ht -ux -e C:\textesting\mybuild.mk4 onlinetest.tex. That returns "cannot find file `online test.tex' and asks for another input file name. If I then type C:\textesting\onlinetest.tex, I can get it to run, but it says "Package biblatex Error: Language 'english' not found" even though it is looking in the right place and english.lbx is there when I navigate to the folder. These seem to be Windows specific problems, right? – LukeB May 3 '17 at 15:25
  • @LukeB you don't need to use full paths for filename and the build file. so use just make4ht -ux -e mybuild.mk4 onlinetest.tex. But you should go to the directory with your files using cd command, because LaTeX can't find supporting files if you execute it from another directory (C\WINDOWS\system32 in your case) – michal.h21 May 3 '17 at 16:26

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.