tex4ht 和日文字体

tex4ht 和日文字体

类似的问题和答案可以在 如何将 Unicode 字符放入 HTML 输出中但我发布了一个新问题,因为那里针对我的问题的建议对我没有用。

如果运行make4ht -ul mwe-htjap此文件时包含以下行

    \documentclass{article}
    %%
    \usepackage{luatexja-fontspec}
    %% \usepackage{fontspec}
    \usepackage{polyglossia}
    \setmainlanguage{english}
    %%
    \begin{document}

    The flight was 4½ hours with a 3 hour change.  
    We landed in Honolulu.  It was 85° and after 
    rearranging the luggage which took a little time, 
    ナンシースエンソン quickly got heated up.

    And now we are playing 囲碁
    \end{document}

我收到很多错误消息,例如

    [STATUS]  make4ht: Conversion started
    [STATUS]  make4ht: Input file: mwe-htjap
    [ERROR]   htlatex: Compilation errors in the htlatex run
    [ERROR]   htlatex: Filename Line    Message
    [ERROR]   htlatex: /usr/local/texlive/2022/texmf-dist/tex/luatex/luatexja/luatexja-core.sty 180  Package luatexja Error: DVI output is not supported in LuaTeX-ja.
    [ERROR]   htlatex: Compilation errors in the htlatex run
    [ERROR]   htlatex: Filename Line    Message
    [ERROR]   htlatex: /usr/local/texlive/2022/texmf-dist/tex/luatex/luatexja/luatexja-core.sty 180  Package luatexja Error: DVI output is not supported in LuaTeX-ja.
    [ERROR]   htlatex: Compilation errors in the htlatex run
    [ERROR]   htlatex: Filename Line    Message
    [ERROR]   htlatex: /usr/local/texlive/2022/texmf-dist/tex/luatex/luatexja/luatexja-core.sty 180  Package luatexja Error: DVI output is not supported in LuaTeX-ja.

    ----------------------------------------------------

    (a lot more)...

    ----------------------------------------------------
    --- error --- Can't find/open file  `[/usr/local/texlive/2022/texmf-dist/fonts/opentype/public/haranoaji/   HaranoAjiMincho-Regular.otf].tfm'
    [FATAL]   make4ht-lib: Fatal error. Command tex4ht returned exit code 1

我对最后一条消息感到疑惑,因为运行该文件lualatex没有出现错误,而是一个正确的PDF文件。

我需要一个htf文件吗?

答案1

LuaTeX-ja 与 TeX4ht 配合得不好,因为我们不支持 OTF 字体(这就是导致致命错误的原因--- error --- Can't find/open file `[/usr/local/texlive/2022/texmf-dist/fonts/opentype/public/haranoaji/ HaranoAjiMincho-Regular.otf].tfm')。所以我们需要抑制试图加载 OTF 字体的软件包。我已经在 TeX4ht 源中修复了这个问题,但在 TeX Live 中获取更新之前,您可以使用以下.4ht文件。

首先是usepackage.4ht

% usepackage.4ht (2022-09-14-19:39), generated from tex4ht-4ht.tex
% Copyright 2003-2009 Eitan M. Gurari
% Copyright 2009-2022 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 2022-09-14-19:39}

   \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 ,!*?: }
\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}
\Configure{PackageHooks}{titlesec.sty}{titlesec-hooks.4ht}
\Configure{PackageHooks}{biblatex-chicago.sty}{biblatex-chicago-hooks.4ht}
\Configure{PackageHooks}{cleveref.sty}{cleveref-hooks.4ht}
\Configure{PackageHooks}{xr.sty}{xr-hooks.4ht}
\Configure{PackageHooks}{xr-hyper.sty}{xrhyper-hooks.4ht}
\Configure{PackageHooks}{eso-pic.sty}{esopic-hooks.4ht}
\Configure{PackageHooks}{showframe.sty}{showframe-hooks.4ht}
\Configure{PackageHooks}{expl3.sty}{expl3-hooks.4ht}
\Configure{PackageHooks}{savetrees.sty}{savetrees-hooks.4ht}
\Configure{PackageHooks}{newcomputermodern.sty}{newcomputermodern-hooks.4ht}
\Configure{PackageHooks}{newcomputermodern.sty}{newcomputermodern-hooks.4ht}
\Configure{PackageHooks}{fontawesome5-utex-helper.sty}%
{fontawesome5-utex-helper-hooks.4ht}
\Configure{PackageHooks}{fontawesome5.sty}{fontawesome5-hooks.4ht}
\Configure{PackageHooks}{biblatex.sty}{biblatex-hooks.4ht}
\Configure{PackageHooks}{xeCJK.sty}{xecjk-hooks.4ht}
\Configure{PackageHooks}{unicode-math.sty}{unicode-math-hooks.4ht}
\Configure{PackageHooks}{ctex.sty}{ctex-hooks.4ht}
\AddToHook{class/ctexart/before}{\input{ctexart-hooks.4ht}}
\Configure{PackageHooks}{luatexja.sty}{luatexja-hooks.4ht}
\Configure{PackageHooks}{luatexja-fontspec.sty}{luatexja-hooks.4ht}
\Configure{PackageHooks}{polyglossia.sty}{polyglossia-hooks.4ht}
\Configure{PackageHooks}{fontspec.sty}{fontspec-hooks.4ht}
\Configure{PackageHooks}{tikz.sty}{tikz-hooks.4ht}
\Configure{PackageHooks}{pdfbase.sty}{pdfbase-hooks.4ht}
\Configure{PackageHooks}{pdfx.sty}{pdfx-hooks.4ht}
\Configure{PackageHooks}{breakurl.sty}{breakurl-hooks.4ht}
\Configure{PackageHooks}{hyperref.sty}{hyperref-hooks.4ht}
\Configure{PackageHooks}{bookmark.sty}{bookmark-hooks.4ht}
\Configure{PackageHooks}{caption.sty}{caption-hooks.4ht}
\Configure{PackageHooks}{babel.sty}{babel-sty-hooks.4ht}
\Configure{PackageHooks}{minted.sty}{minted-sty-hooks.4ht}
\Configure{PackageHooks}{graphics.sty}{graphics-hooks.4ht}
\Configure{PackageHooks}{graphbox.sty}{graphbox-hooks.4ht}
\Configure{PackageHooks}{xcolor.sty}{xcolor-hooks.4ht}
\Configure{PackageHooks}{imakeidx.sty}{imakeidx-hooks.4ht}
\Configure{PackageHooks}{fancyhdr.sty}{fancyhdr-hooks.4ht}
\Configure{PackageHooks}{exerquiz.sty}{exerquiz-hooks.4ht}
\Configure{PackageHooks}{hyperxmp.sty}{hyperxmp-hooks.4ht}
\Configure{PackageHooks}{datetime2.sty}{datetime2-hooks.4ht}


\endinput

它包含需要特殊处理的包的说明,特别是如果它们需要在加载时进行处理。该\Configure{PackageHooks}{luatexja-fontspec.sty}{luatexja-hooks.4ht}命令将luatexja-hooks.4ht在使用包之前加载该文件。我们可以借助此文件阻止对包进行进一步处理。如下所示luatexja-hooks.4ht

% luatexja-hooks.4ht (2022-09-14-19:39), generated from tex4ht-4ht.tex
% Copyright 2022 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 2022-09-14-19:39}

\:dontusepackage{luatexja}
\:dontusepackage{luatexja-fontspec}
\endinput

阻止\:dontusepackage加载给定的包。我们在这里阻止和luatexjaluatexja-fontspec因为它们都会导致 TeX4ht 出现致命错误。

经过这种改变,你应该会得到正确的结果:

在此处输入图片描述

相关内容