数学模式似乎依赖于 tikz,在 epub 上看起来很糟糕

数学模式似乎依赖于 tikz,在 epub 上看起来很糟糕

我有以下 mcve.tex

\documentclass{article} 


\begin{document}

Hello World! 

$Hello World!$

\[ Hello World \]
\end{document}

如果我通过 pdflatex 运行它,它会按照我的预期运行 - 以三种略有不同的风格显示“Hello world”:

[![在此处输入图片描述][1]][1]

但是,我正在制作一本电子书,因此我通过 tex4ebook 运行它并得到了以下结果:

[![在此处输入图片描述][2]][2]

...这很奇怪。但如果我碰巧使用 tikz(因此我在顶部有 \usepackage{tikz}),它确实会渲染,但看起来非常糟糕:[![在此处输入图像描述][3]][3] - 我在 bookworm 和 mupdf 上尝试过,但最重要的是在官方 kdp kindle 预览器和我自己的 kindle 上尝试过。

推测这种不良情况是因为 tikz 出于某种原因制作了低质量的 png(根据日志,实际上是一个叫做 mcve0x.png 的 png),而不是正确地制作。它不仅在这里看起来很糟糕,而且在任何实际的电子书上看起来都很糟糕,例如,它不响应字体大小的变化。

我的问题是:这里发生了什么,如何让 tex4ebook 生成在电子阅读器上完美显示的数学公式?另外,为什么要让 tikz 参与进来?

编辑-版本

  • 我的 TeX 版本是:pdfTeX 3.141592653-2.6-1.40.22(TeX Live 2022/dev/Debian)
  • 我的tex4ebook版本是:v0.3g

编辑-来自 tex4ebook 的完整调试日志

joe@joe-Amd-Am4-Home-Office:~/git/memorybook$ tex4ebook -a -debug -m draft mcve.tex
[INFO]    mkparams: Output dir: 
[INFO]    mkparams: Compiler: latex
[INFO]    mkparams: Latex options: -jobname=mcve  
[INFO]    mkparams: tex4ht.sty: xhtml,,charset=utf-8
[INFO]    mkparams: tex4ht:  -cmozhtf -utf8
[INFO]    mkparams: build_file: mcve.mk4
[INFO]    mkparams: Output format: epub
[STATUS]  tex4ebook: Conversion started
[STATUS]  tex4ebook: Input file: mcve.tex
[INFO]    mkutils: Load extension   common_domfilters
[INFO]    tex4ebook: No conffile
[INFO]    mkutils: Cannot open config file  mcve.mk4
[INFO]    exec_epub: dir    mcve-epub/META-INF
[INFO]    exec_epub: remove file    mcve-epub/META-INF/container.xml
[INFO]    exec_epub: remove dir mcve-epub/META-INF
[INFO]    exec_epub: remove file    mcve-epub/mimetype
[INFO]    exec_epub: remove file    mcve-epub/mcve.epub
[INFO]    exec_epub: dir    mcve-epub/OEBPS
[INFO]    exec_epub: remove file    mcve-epub/OEBPS/content.opf
[INFO]    exec_epub: remove file    mcve-epub/OEBPS/mcve.ncx
[INFO]    exec_epub: remove file    mcve-epub/OEBPS/mcve.css
[INFO]    exec_epub: remove file    mcve-epub/OEBPS/mcve.html
[INFO]    exec_epub: remove dir mcve-epub/OEBPS
[INFO]    exec_epub: remove dir mcve-epub
[INFO]    make4ht-lib: setting param correct_exit
[INFO]    make4ht-lib: setting param ext
[WARNING] tocid: char-def module not found
[WARNING] tocid: cannot fix section id's
[INFO]    exec_epub: Output file: mcve.epub
[INFO]    htlatex: LaTeX call: latex --interaction=batchmode -jobname=mcve   '\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.{\AddToHook{class/before}{\RequirePackage[#1,html]{tex4ht}\RequirePackage{tex4ebook}}\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 xhtml,,charset=utf-8,charset=utf-8,epub,uni-html4.a.b.c.\input "\detokenize{mcve.tex}"' > /dev/null 2>&1
[INFO]    mkutils:  xhtml,charset=utf-8,epub,uni-html4,html
[INFO]    mkutils: executing: tex4ht  -cmozhtf -utf8 -cmozhtf -utf8 "mcve.dvi"
----------------------------
tex4ht.c (2018-07-03-10:36 kpathsea)
tex4ht -cmozhtf 
  -utf8 
  -cmozhtf 
  -utf8 
  mcve.dvi 
(/usr/share/texlive/texmf-dist/tex4ht/base/unix/tex4ht.env)
(/usr/share/texlive/texmf-dist/tex4ht/ht-fonts/mozilla/charset/unicode.4hf)
(/usr/share/texlive/texmf-dist/fonts/tfm/public/cm/cmmi10.tfm)
(/usr/share/texlive/texmf-dist/tex4ht/ht-fonts/unicode/cm/cmmi.htf)
(/usr/share/texlive/texmf-dist/fonts/tfm/public/cm/cmr10.tfm)
(/usr/share/texlive/texmf-dist/tex4ht/ht-fonts/alias/lm/lm-rep-cmrm/cmr.htf)
Searching `lm-rep-cmrm.htf' for `cmr10.htf'
(/usr/share/texlive/texmf-dist/tex4ht/ht-fonts/unicode/lm/lm-rep-cmrm.htf)
[1 file mcve.html
 file mcve.css
 file mcve.tmp
 file mcve.ncx
 file content.opf
 file content-part2.opf
]
Execute script `mcve.lg'

[INFO]    make4ht-lib: executing: t4ht  "mcve.dvi"
sh: 1: dvipng: not found
----------------------------
t4ht.c (2018-07-04-14:25 kpathsea)
t4ht mcve.dvi 
(/usr/share/texlive/texmf-dist/tex4ht/base/unix/tex4ht.env)
Entering mcve.lg
System call: dvipng -T tight -D 144 -bg Transparent -pp 2:2 mcve.idv -o mcve0x.png
--- Warning --- System return: 32512
Entering mcve.css
Entering mcve.tmp

[INFO]    mkutils: Parse LG
[INFO]    make4ht-lib: parse_lg process file: mcve.html
[INFO]    make4ht-lib: parse_lg process file: mcve.tmp
[INFO]    mkutils: Copy: cp "mcve.html" "mcve-epub/OEBPS"
[INFO]    mkutils: Copy: cp "mcve.css" "mcve-epub/OEBPS"
[INFO]    exec_epub: Mimetype for tmp is not registered
[INFO]    mkutils: Copy: cp "mcve.ncx" "mcve-epub/OEBPS"
[INFO]    exec_epub: Mimetype for opf is not registered
[INFO]    exec_epub: Mimetype for opf is not registered
[INFO]    mkutils: Copy: cp "mcve0x.png" "mcve-epub/OEBPS"
[ERROR]   mkutils: File mcve0x.png doesn't exist
cp: cannot stat 'mcve0x.png': No such file or directory
[INFO]    mkutils: Copy: cp "content.opf" "mcve-epub/OEBPS"
HTML Tidy for Linux version 5.6.0
[INFO]    exec_epub: Tidy ncx 0
[INFO]    exec_epub: Tidy opf 0
[INFO]    exec_epub: Pack mimetype 0
[INFO]    exec_epub: Pack metadir 0
[INFO]    exec_epub: Pack outputdir 0
[INFO]    exec_epub: Copy generated epub 
[INFO]    mkutils: Copy: cp "mcve-epub/mcve.epub" "mcve.epub"
[STATUS]  tex4ebook: Conversion finished
joe@joe-Amd-Am4-Home-Office:~/git/memorybook$ 

相关内容