1

Problem

Tex4ht seems to omit a necessary space in between a book series title and the following number in biblatex-chicago output. Xelatex has the correct output.

MWE

main.tex:

%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode

% Normal:
\documentclass[12pt,letterpaper,oldfontcommands,article]{memoir}
\usepackage{import}

\usepackage[notes,
        alldates=       long,
        backend=        biber,
        bibwarn=        false,
        cmsdate=        both, % reprints: print `origdate` as well as `year`
        compresspages=  true,
        doi=            false,
        eprint=         false,
        giveninits=     true,   % abbreviate author first name(s)
        ibidtracker=    true,
        inheritshorthand,       % feature added for me by D.Fussner
        isbn=           false,
        mincrossrefs =  2,
        numbermonth =   false, % don't print journal issue month even if supplied, when an issue number is also supplied
        useibid,
        shorthandibid,
        strict=         true,
        url=            true,
        usetranslator=  true,
        uniquename= init
    ]{biblatex-chicago}
\addbibresource{test.bib}

\begin{document}
\cite{kahn.matton1995alchimie} 
\end{document}

test.bib:

@book{kahn.matton1995alchimie,
    address = {Paris and Milan},
    editor = {Didier Kahn and Sylvain Matton},
    number = {1},
    series = {Textes et Travaux de Chrysopœia},
    title = {Alchimie: Art, histoire et mythes},
    year = {1995}
}

myconfig.cfg:

\Preamble{xhtml,ooffice}
\ConfigureOO{Footnote}{
<style:style
    style:name="Footnote"
    style:family="paragraph"
    style:parent-style-name="Standard"
    style:class="extra">\Hnewline
  <style:paragraph-properties
             fo:margin-left="0in"
             fo:margin-right="0in"
             fo:text-indent="0.1in"
              style:auto-text-indent="false"/>
  <style:text-properties fo:font-size="83.3333333333333333333333\%"
      style:font-size-asian="83.3333333333333333333333\%"
      style:font-size-complex="83.3333333333333333333333\%" />
</style:style>\Hnewline
<text:notes-configuration text:note-class="footnote"
    text:citation-style-name="Footnote_20_Symbol"
    text:citation-body-style-name="Footnote_20_anchor"
    style:num-format="1" text:start-value="0"
    text:footnotes-position="page"
    text:start-numbering-at="document" />\Hnewline
<style:style style:name="Footnote_20_Symbol"
style:display-name="Footnote Symbol" style:family="text" >\Hnewline
  <style:text-properties style:text-position="super 58\%" />\Hnewline
</style:style>
<style:style style:name="Footnote_20_anchor"
style:display-name="Footnote anchor" style:family="text">
  <style:text-properties style:text-position="super 58\%" />\Hnewline
</style:style>\Hnewline
}

\ConfigureOO{verse}{\Hnewline
<style:style style:name="verse"
             style:family="paragraph"
             style:parent-style-name="Text-body"
             style:next-style-name="Text-body">
<style:paragraph-properties  fo:margin-left="1.499cm"
             fo:margin-right="1cm"
             fo:margin-top="0cm"
             fo:margin-bottom="0cm"
             fo:text-indent="-0.499cm"
             style:auto-text-indent="false">
   <style:tab-stops/>
</style:paragraph-properties >
</style:style>
\Hnewline}

\def\loopoverdigits#1{\ifx\relax#1\else%
% Unicode block for Arabic numerals starts at U+0660
% the following special command inserts the XML entity
% for the number, which will be converted to Unicode char
% by tex4ht
\special{t4ht@+&{35}x066#1{59}}x%
\expandafter\loopoverdigits\fi}

\def\arabicdigits#1{\NoFonts\loopoverdigits#1\relax\EndNoFonts}
\ifdefined\xeuniuseblock
\xeuniuseblock{Greek}
\xeuniuseblock{Arabic}
\fi
\makeatletter
\ConfigureEnv{arab}{\@rltrue}{\@rlfalse}{}{}
\Configure{ref}{\Link}{\EndLink}{}
\makeatother
\begin{document}
\EndPreamble

Command used to produce .odt output:

make4ht -ux -a debug -f odt -c myconfig.cfg main.tex

tex4ht output (incorrect):

enter image description here

xelatex output (correct):

enter image description here

(The desired space is after the word "Chrysopœia".)

Question

How can I get tex4ht to add the required space?

1 Answer 1

2

It seems that \addspace and \addnbspace commands used in field formats don't have an effect. This is the definition of the field format used for printing of the number in biblatex-chicago:

\DeclareFieldFormat{sernum}{%
  \ifnumeral{#1}%
  {\addnbspace\addspace #1}% 
  {\addcomma\addspace #1}}

These commands work in other instances, but not when used in the field format,which means that spaces are ignored in this context.

One issue I found is that \addnbspace command don't use \nobreakspace, but \nobreak\space instead. TeX4ht cannot insert the non-breaking space character, but just ordinary space. This explains why the non-breaking space disappeared. We can redefine this command to insert correct character:

\renewrobustcmd*{\addnbspace}{%
  \unspace\blx@postpunct%
  % insert real nonbraking space character
  \nobreakspace\blx@imc@resetpunctfont}

This fixes this particular issue, but it doesn't fix the underlying problem, that spaces are ignored. I've found that it is caused by TeX4ht's redefinition of the \blx@begunit command, which removes some horizontal spaces. Here is a version which doesn't do that:

\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@imc@resetpunctfont
  \iftoggle{blx@tempa}%
    {}%
    {\global\togglefalse{blx@insert}}%
  \csname a:blx@unit\endcsname%
  \blx@leavevmode%
  \begingroup%
    \Configure{blx@unit}{}{}%
}

With this change, \addspace works correctly, but here is yet another issue: as we saw, the sernum field format adds non-breaking space, and then ordinary space. This results in possible line break before the number. I think correct version of the format is just this:

\DeclareFieldFormat{sernum}{%
  \ifnumeral{#1}%
  {\addnbspace #1}% originally there was additional \addspace, which caused line break
  {\addcomma\addspace #1}}

This is the resulting ODT file with these changes:

enter image description here

And here is the full .cfg file:

\Preamble{xhtml,ooffice}
\ConfigureOO{Footnote}{
<style:style
    style:name="Footnote"
    style:family="paragraph"
    style:parent-style-name="Standard"
    style:class="extra">\Hnewline
  <style:paragraph-properties
             fo:margin-left="0in"
             fo:margin-right="0in"
             fo:text-indent="0.1in"
              style:auto-text-indent="false"/>
  <style:text-properties fo:font-size="83.3333333333333333333333\%"
      style:font-size-asian="83.3333333333333333333333\%"
      style:font-size-complex="83.3333333333333333333333\%" />
</style:style>\Hnewline
<text:notes-configuration text:note-class="footnote"
    text:citation-style-name="Footnote_20_Symbol"
    text:citation-body-style-name="Footnote_20_anchor"
    style:num-format="1" text:start-value="0"
    text:footnotes-position="page"
    text:start-numbering-at="document" />\Hnewline
<style:style style:name="Footnote_20_Symbol"
style:display-name="Footnote Symbol" style:family="text" >\Hnewline
  <style:text-properties style:text-position="super 58\%" />\Hnewline
</style:style>
<style:style style:name="Footnote_20_anchor"
style:display-name="Footnote anchor" style:family="text">
  <style:text-properties style:text-position="super 58\%" />\Hnewline
</style:style>\Hnewline
}

\ConfigureOO{verse}{\Hnewline
<style:style style:name="verse"
             style:family="paragraph"
             style:parent-style-name="Text-body"
             style:next-style-name="Text-body">
<style:paragraph-properties  fo:margin-left="1.499cm"
             fo:margin-right="1cm"
             fo:margin-top="0cm"
             fo:margin-bottom="0cm"
             fo:text-indent="-0.499cm"
             style:auto-text-indent="false">
   <style:tab-stops/>
</style:paragraph-properties >
</style:style>
\Hnewline}

\def\loopoverdigits#1{\ifx\relax#1\else%
% Unicode block for Arabic numerals starts at U+0660
% the following special command inserts the XML entity
% for the number, which will be converted to Unicode char
% by tex4ht
\special{t4ht@+&{35}x066#1{59}}x%
\expandafter\loopoverdigits\fi}

\def\arabicdigits#1{\NoFonts\loopoverdigits#1\relax\EndNoFonts}
\ifdefined\xeuniuseblock
\xeuniuseblock{Greek}
\xeuniuseblock{Arabic}
\fi
\makeatletter
\ConfigureEnv{arab}{\@rltrue}{\@rlfalse}{}{}
\Configure{ref}{\Link}{\EndLink}{}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Fixes for non-breaking space
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\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@imc@resetpunctfont
  \iftoggle{blx@tempa}%
    {}%
    {\global\togglefalse{blx@insert}}%
  \csname a:blx@unit\endcsname%
  \blx@leavevmode%
  \begingroup%
    \Configure{blx@unit}{}{}%
}

\renewrobustcmd*{\addnbspace}{%
  \unspace\blx@postpunct%
  % insert real nonbraking space character
  \nobreakspace\blx@imc@resetpunctfont}

\DeclareFieldFormat{sernum}{%
  \ifnumeral{#1}%
  {\addnbspace #1}% originally there was additional \addspace, which caused line break
  {\addcomma\addspace #1}}
\makeatother

\begin{document}
\EndPreamble

You must log in to answer this question.

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