问题

问题

问题

Tex4ht 似乎在 biblatex-chicago 输出中省略了书籍系列标题和后面的数字之间的必要空格。Xelatex 的输出是正确的。

平均能量损失

主要.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}

测试.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}
}

我的配置.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

用于产生.odt输出的命令:

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

tex4ht 输出(不正确):

在此处输入图片描述

xelatex 输出(正确):

在此处输入图片描述

(所需空格位于单词“Chrysopœia”之后。)

问题

我怎样才能让 tex4ht 添加所需的空间?

答案1

看起来字段格式中使用的\addspace\addnbspace命令不起作用。这是用于打印数字的字段格式的定义biblatex-chicago

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

这些命令在其他情况下有效,但在字段格式中使用时无效,这意味着在这种情况下空格会被忽略。

我发现的一个问题是,该\addnbspace命令不使用\nobreakspace,而是\nobreak\space使用 。TeX4ht 无法插入不间断空格字符,而只能插入普通空格。这解释了为什么不间断空格会消失。我们可以重新定义此命令以插入正确的字符:

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

这解决了这个特定问题,但并没有解决根本问题,即空格被忽略。我发现这是由 TeX4ht 重新定义命令引起的\blx@begunit,这会删除一些水平空格。这是一个不会这样做的版本:

\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}{}{}%
}

经过此更改,\addspace可以正常工作,但这里还有另一个问题:正如我们所见,sernum字段格式添加了不间断空格,然后是普通空格。这可能导致数字前出现换行符。我认为格式的正确版本就是这样:

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

这是经过以下更改后生成的 ODT 文件:

在此处输入图片描述

完整文件如下.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}{}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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

相关内容