我已经make4ht
使用命令进行了安装tlmgr install make4ht
。
现在,当我输入命令时make4ht foo.tex
,出现此错误:
[STATUS] make4ht: Conversion started
[STATUS] make4ht: Input file: foo.tex
...texmf-dist/scripts/make4ht/filters/make4ht-domfilter.lua:2: module 'luaxml-domobject' not found:
no field package.preload['luaxml-domobject']
[kpse lua searcher] file not found: 'luaxml-domobject'
[kpse C searcher] file not found: 'luaxml-domobject'
我还需要安装什么才可以make4ht
成功使用?
答案1
在 Ubuntu(20.04)上,我make4ht
通过apt
标准包进行安装texlive-extra-utils
。
我也有类似的错误:
...texmf-dist/scripts/make4ht/filters/make4ht-domfilter.lua:2: module 'luaxml-domobject' not found:
no field package.preload['luaxml-domobject']
[kpse lua searcher] file not found: 'luaxml-domobject'
[kpse C searcher] file not found: 'luaxml-domobject'
为了解决错误,我刚刚安装了包 texlive-luatex
:
sudo apt install texlive-luatex
(似乎该包缺少依赖项texlive-extra-utils
)
答案2
让我回答一下我是如何解决这个问题的。@michal.h21 的评论很有帮助。
请注意,第 2 点至第 6 点表明错误的开始或尝试并未带来良好的结果。只有最后一点,即第 7 点带来了不错的结果。
创建一个文件
foo.tex
,我将用它来测试其make4ht
是否能成功运行:\documentclass{article} \usepackage{amsmath} \title{Demo} \begin{document} \begin{align} 1 + 0 & = 1, \label{eq1} \\ 1 + 1 & = 2, \label{eq2} \\ e^{i \pi} = -1. \label{eq3} \end{align} Equation \( \eqref{eq1} \), \( \eqref{eq2} \) and \( \eqref{eq3} \) describe eternal truths. The equation \( e^{i \pi} = -1 \) can also be rewritten as \( e^{i \pi} + 1 = 0 \) which is known as Euler's identity. \end{document}
安装
make4ht
并编译foo.tex
如下foo.html
:sudo tlmgr install make4ht make4ht foo
这导致了以下错误:
[STATUS] make4ht: Conversion started [STATUS] make4ht: Input file: foo ...texmf-dist/scripts/make4ht/filters/make4ht-domfilter.lua:2: module 'luaxml-domobject' not found: no field package.preload['luaxml-domobject'] [kpse lua searcher] file not found: 'luaxml-domobject' [kpse C searcher] file not found: 'luaxml-domobject'
安装
make4ht
并重luaxml
试:sudo tlmgr install make4ht luaxml make4ht foo
这导致了以下错误:
[STATUS] make4ht: Conversion started [STATUS] make4ht: Input file: foo [ERROR] htlatex: Compilation errors in the htlatex run [ERROR] htlatex: Filename Line Message [ERROR] htlatex: ? ? LaTeX Error: File `tex4ht.sty' not found. [ERROR] htlatex: ? 2 Emergency stop. [FATAL] make4ht-lib: Fatal error. Command htlatex returned exit code 1
安装
make4ht
、luaxml
和tex4ht
,然后重试:sudo tlmgr install make4ht luaxml tex4ht make4ht foo
这次转换成功了:
[STATUS] make4ht: Conversion started [STATUS] make4ht: Input file: foo sh: dvipng: command not found sh: dvipng: command not found sh: dvipng: command not found sh: dvipng: command not found sh: dvipng: command not found [STATUS] make4ht: Conversion finished
输出结果如下
foo.html
:<!DOCTYPE html> <html lang='en-US' xml:lang='en-US'> <head><title></title> <meta charset='utf-8' /> <meta content='TeX4ht (https://tug.org/tex4ht/)' name='generator' /> <meta content='width=device-width,initial-scale=1' name='viewport' /> <link href='foo.css' type='text/css' rel='stylesheet' /> <meta content='foo.tex' name='src' /> </head><body> <!-- l. 6 --><p class='noindent'> </p><table class='align'> <tr><td class='align-odd'>1 + 0</td> <td class='align-even'> = 1<span class='cmmi-10'>,</span></td> <td class='align-label'><a id='x1-2r1'></a>(1) </td></tr><tr><td class='align-odd'>1 + 1</td> <td class='align-even'> = 2<span class='cmmi-10'>,</span></td> <td class='align-label'><a id='x1-3r2'></a>(2) </td></tr><tr><td class='align-odd'><span class='cmmi-10'>e</span><sup><span class='cmmi-7'>iπ</span></sup> = <span class='cmsy-10'>−</span>1<span class='cmmi-10'>.</span></td> <td class='align-even'></td> <td class='align-label'><a id='x1-4r3'></a>(3) </td></tr></table> <!-- l. 12 --><p class='noindent'>Equation <img alt='(1) ' src='foo0x.png' class='math' />, <img alt='(2) ' src='foo1x.png' class='math' /> and <img alt='(3) ' src='foo2x.png' class='math' /> describe eternal truths. </p><!-- l. 15 --><p class='indent'> The equation <img alt='eiπ = − 1 ' src='foo3x.png' class='math' /> can also be rewritten as <img alt='eiπ + 1 = 0 ' src='foo4x.png' class='math' /> which is known as Euler’s identity. </p> </body> </html>
使用 HTML 和图像呈现的数学运算看起来不太好。
使用 MathJax 渲染数学:
make4ht foo mathjax
转换失败:
[STATUS] make4ht: Conversion started [STATUS] make4ht: Input file: foo [ERROR] htlatex: Compilation errors in the htlatex run [ERROR] htlatex: Filename Line Message [ERROR] htlatex: ? ? LaTeX Error: File `environ.sty' not found. [ERROR] htlatex: ? 22 Emergency stop. [FATAL] make4ht-lib: Fatal error. Command htlatex returned exit code 1
安装
make4ht
、luaxml
、tex4ht
和environ
然后重试:sudo tlmgr install make4ht luaxml tex4ht environ make4ht foo mathjax
再次失败:
[STATUS] make4ht: Conversion started [STATUS] make4ht: Input file: foo [ERROR] htlatex: Compilation errors in the htlatex run [ERROR] htlatex: Filename Line Message [ERROR] htlatex: ? ? LaTeX Error: File `trimspaces.sty' not found. [ERROR] htlatex: ? 17 Emergency stop. [FATAL] make4ht-lib: Fatal error. Command htlatex returned exit code 1
安装
make4ht
、luaxml
、tex4ht
、environ
和trimspaces
然后重试:sudo tlmgr install make4ht luaxml tex4ht environ trimspaces make4ht foo mathjax
转换成功:
[STATUS] make4ht: Conversion started [STATUS] make4ht: Input file: foo [STATUS] make4ht: Conversion finished
输出如下
foo.html
:<!DOCTYPE html> <html xml:lang='en-US' lang='en-US'> <head><title></title> <meta charset='utf-8' /> <meta name='generator' content='TeX4ht (https://tug.org/tex4ht/)' /> <meta name='viewport' content='width=device-width,initial-scale=1' /> <link href='foo.css' type='text/css' rel='stylesheet' /> <meta name='src' content='foo.tex' /> <script>window.MathJax = { tex: { tags: "ams", inlineMath: [ ["\\\(","\\\)"] ], displayMath: [ ['$$','$$'], ["\\[","\\]"] ], processEscapes: true, processEnvironments: true, packages: ['base', 'color', 'ams'] }, loader: { load: ['[tex]/color', '[tex]/ams'] } }; </script> <script id='MathJax-script' type='text/javascript' async='async' src='https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js'></script> </head><body> <!-- l. 10 --><p class='noindent'>\begin{align} 1 + 0 & = 1, \label{eq1} \\ 1 + 1 & = 2, \label{eq2} \\ e^{i \pi } = -1. \label{eq3} \end{align} </p><!-- l. 12 --><p class='noindent'>Equation \( \eqref{eq1} \), \( \eqref{eq2} \) and \( \eqref{eq3} \) describe eternal truths. </p><!-- l. 15 --><p class='indent'> The equation \( e^{i \pi } = -1 \) can also be rewritten as \( e^{i \pi } + 1 = 0 \) which is known as Euler’s identity. </p> </body> </html>
下面是显示输出的示例 JSFiddle:https://jsfiddle.net/9xubrm47/。