我想从文档创建 HTML 文件。使用的LaTeX
最方便的方法可能导致错误:TeXStudio
Tools | Convert to Html... | Launch
Error : a process has failed
Fatal error : LaTeX errors detected.
嗯,非常有意义...不过,PdfLaTeX
在这个文档上运行良好。
因此,我尝试使用命令行htlatex
htlatex myFile.tex
一切正常,HTML 生成了,但图像丢失了。好吧,它们在目录中,但只有 1 kB 大小并且是空的。
在编译过程中,我收到所有图像的消息,例如:
...
System call: dvipng -T tight -D 144 -bg Transparent -pp 19:19 myFile.idv -o myFile9x.png
This is dvipng 1.16 Copyright 2002-2015, 2019 Jan-Ake Larsson
[19dvipng warning: at (-143,1) unimplemented \special{em: graph Images/myPicture.png,72bp,72bp} ]
System return: 0
....
这些图像大多是 PNG 格式,例如通过以下方式包含:
\begin{figure}[htbp]%
\centering
\includegraphics[width=0.8\columnwidth]{Images/myPicture.png}%
\caption{This is a picture}%
\label{fig:myPicture}%
\end{figure}
我在这里做错了什么?我是否缺少任何命令行选项或配置文件?
我使用的是 Win10、pdfTeX、版本 3.14159265-2.6-1.40.20(MiKTeX 2.9.7050 64 位)。需要更多信息来提出建议吗?
更新:
根据@michal.h21的建议,我使用 MiKTeX 包管理器进行了更新mpm
。它更新了 97 个包。有一个tex4ht
来自 2020-10-05 的包,一个来自 2020-01-26 的包miktex-tex4ht
,以及一个miktex-tex4ht-x64-2.9
来自 2020-10-31 的包。相当混乱。还有其他包需要查看吗?当我htlatex
随后运行时,它安装了另外两种样式:我猜是hosub-?something?.sty
和iftex.sty
。但结果是一样的:HTML 文档中没有图像。也许值得一提的是,我有一个便携式安装,这会导致问题吗?
已安装的软件包tex4
名称包含以下内容:
更新 2: 第三种方法使用make4ht
结果与上面相同。没有错误消息,生成了 HTML,图片有 1 kB 为空。输出:
[STATUS] make4ht: Conversion started
[STATUS] make4ht: Input file: myFile.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (MiKTeX 20.11 Portable)
entering extended mode
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (MiKTeX 20.11 Portable)
entering extended mode
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (MiKTeX 20.11 Portable)
entering extended mode
[STATUS] make4ht: Conversion finished
更新 3: (最小非工作示例)
LaTeX 文件:LaTeX2Html.tex
\documentclass[a4paper]{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}[htbp]%
\centering
\includegraphics[width=0.8\columnwidth]{Images/myPicture.png}%
\caption{}%
\label{}%
\end{figure}
\end{document}
子文件夹中的图像Images\myPicture.png
结果:
- 生成 HTML
- 主目录中有一个名为 的图像
LaTeX2Html0x.png
,但大小为 1 kB 且为空。
输出:
...
System call: dvipng -T tight -D 144 -bg Transparent -pp 2:2 LaTeX2Html.idv -o LaTeX2Html0x.png
This is dvipng 1.16 Copyright 2002-2015, 2019 Jan-Ake Larsson
[2dvipng warning: at (1,109) unimplemented \special{em: graph Images/myPicture.png,72bp,72bp} ]
System return: 0
...
但是,pdflatex
生成 PDF 可以正常工作。
更新 5: 在编译过程中我发现了一条消息,也许这会给出一个提示?!
....
l.10 --- TeX4ht warning --- File `"Images/myPicture.xbb"' not found ---
l.10 --- TeX4ht warning --- Cannot determine size of graphic in "Images/myPictu
re.xbb" (no BoundingBox) ---
...
扩展名是什么.xbb
?如果我将 重命名.png
为.xbb
,则只保留消息no bounding box
。我需要用.eps
文件来代替吗?
更新 6:(运行时的输出make4ht -m draft -a debug LaTeX2Html.tex
)
[INFO] mkparams: Output dir:
[INFO] mkparams: Compiler: latex
[INFO] mkparams: Latex options: -jobname=LaTeX2Html
[INFO] mkparams: tex4ht.sty: xhtml,,charset=utf-8
[INFO] mkparams: tex4ht: -cmozhtf -utf8
[INFO] mkparams: build_file: LaTeX2Html.mk4
[INFO] mkparams: Output format: html5
[STATUS] make4ht: Conversion started
[STATUS] make4ht: Input file: LaTeX2Html.tex
[INFO] mkutils: Load extension common_domfilters
[INFO] mkutils: Cannot open config file LaTeX2Html.mk4
[INFO] make4ht-lib: setting param correct_exit
[INFO] make4ht-lib: setting param ext
[INFO] make4ht-lib: Adding: ext dvi
[INFO] htlatex: LaTeX call: latex --interaction=errorstopmode -jobname=LaTeX2Html \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.{\g@addto@macro\@documentclasshook{\RequirePackage[#1,html]{tex4ht}}\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,html5.a.b.c.\input "\detokenize{LaTeX2Html.tex}"
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (MiKTeX 20.11 Portable)
entering extended mode
LaTeX2e <2018-12-01>
(LaTeX2Html.tex
(C:\Users\xxx\Programs\texmfs\install\tex/latex/base\article.cls
Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
(C:\Users\xxx\Programs\texmfs\install\tex/latex/base\size10.clo))
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\tex4ht.sty)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\usepackage.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/latex/graphics\graphicx.sty
(C:\Users\xxx\Programs\texmfs\install\tex/latex/graphics\keyval.sty)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\usepackage.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/latex/graphics\graphics.sty
(C:\Users\xxx\Programs\texmfs\install\tex/latex/graphics\trig.sty)
(C:\Users\xxx\Programs\texmfs\install\tex/latex/graphics-cfg\graphics.cfg)
(C:\Users\xxx\Programs\texmfs\install\tex/latex/graphics-def\dvips.def)))
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\tex4ht.4ht
::::::::::::::::::::::::::::::::::::::::::
TeX4ht info is available in the log file
::::::::::::::::::::::::::::::::::::::::::
) (C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\tex4ht.sty
--- needs --- tex4ht LaTeX2Html ---
(LaTeX2Html.tmp) (LaTeX2Html.xref)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\html4.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\unicode.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\html4-math.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\html5.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\html4.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\unicode.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\html4-math.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\html5.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\html4.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\unicode.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\html4-math.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\html5.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\latex.4ht
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\html4.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\unicode.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\html4-math.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\html5.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\html4.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\unicode.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\html4-math.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\html5.4ht))
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\fontmath.4ht
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\html4.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\unicode.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\html4-math.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\html5.4ht))
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\article.4ht
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\html4.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\unicode.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\html4-math.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\html5.4ht))
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\graphicx.4ht
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\html4.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\unicode.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\html4-math.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\html5.4ht))
(graphics.4ht
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\html4.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\unicode.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\html4-math.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\html5.4ht))
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\dvips.4ht
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\html4.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\unicode.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\html4-math.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\html5.4ht))
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\html4.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\unicode.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\html4-math.4ht)
(C:\Users\xxx\Programs\texmfs\install\tex/generic/tex4ht\html5.4ht))
(LaTeX2Html.aux) [1] [2]
l.10 --- TeX4ht warning --- File `"Images/myPicture.xbb"' not found ---
l.10 --- TeX4ht warning --- Cannot determine size of graphic in "Images/myPictu
re.xbb" (no BoundingBox) ---
<Images/myPicture.png> [3] [4] (LaTeX2Html.aux) )
(\end occurred inside a group at level 1)
### semi simple group (level 1) entered at line 6 (\begingroup)
### bottom level
Output written on LaTeX2Html.dvi (4 pages, 10840 bytes).
Transcript written on LaTeX2Html.log.
[INFO] make4ht-lib: executing: tex4ht -cmozhtf -utf8 "LaTeX2Html.dvi"
----------------------------
tex4ht.c (2018-07-03-10:36 Windows MiKTeX)
tex4ht -cmozhtf
-utf8
LaTeX2Html.dvi
(C:/Users/xxx/Programs/texmfs/install/tex4ht/base/win32/tex4ht.env)
(C:/Users/xxx/Programs/texmfs/install/tex4ht/ht-fonts/mozilla/charset/unicode.4hf)
(C:/Users/xxx/Programs/texmfs/install/fonts/tfm/public/cm/cmr10.tfm)
(C:/Users/xxx/Programs/texmfs/install/tex4ht/ht-fonts/alias/lm/lm-rep-cmrm/cmr.htf)
Searching `lm-rep-cmrm.htf' for `cmr10.htf'
(C:/Users/xxx/Programs/texmfs/install/tex4ht/ht-fonts/unicode/lm/lm-rep-cmrm.htf)
[1 file LaTeX2Html.html
file LaTeX2Html.css
file LaTeX2Html.tmp
] [2] [3 file LaTeX2Html.tmp
] [4]
Execute script `LaTeX2Html.lg'
[INFO] make4ht-lib: executing: t4ht "LaTeX2Html.dvi"
This is dvipng 1.16 Copyright 2002-2015, 2019 Jan-Ake Larsson
[2dvipng warning: at (1,109) unimplemented \special{em: graph Images/myPicture.png,72bp,72bp} ]
----------------------------
t4ht.c (2018-07-04-14:25 MiKTeX)
t4ht LaTeX2Html.dvi
(C:/Users/xxx/Programs/texmfs/install/tex4ht/base/win32/tex4ht.env)
Entering LaTeX2Html.lg
System call: dvipng -T tight -D 144 -bg Transparent -pp 2:2 LaTeX2Html.idv -o LaTeX2Html0x.png
System return: 0
Entering LaTeX2Html.css
Entering LaTeX2Html.tmp
[INFO] mkutils: Parse LG
[INFO] make4ht-lib: parse_lg process file: LaTeX2Html.html
[INFO] make4ht-lib: parse_lg process file: LaTeX2Html.html
[INFO] make4ht: outdir:
[INFO] make4ht-lib: parse_lg process file: LaTeX2Html.css
[INFO] make4ht: outdir:
[INFO] make4ht-lib: parse_lg process file: LaTeX2Html.tmp
[INFO] make4ht-lib: tmp file
[INFO] make4ht-lib: parse_lg process file: LaTeX2Html0x.png
[INFO] make4ht: outdir:
[STATUS] make4ht: Conversion finished
答案1
感谢@Ulrike Fischer 和@michal.h21 的建议和耐心。
规则一:确保您拥有最新的安装!
但是,我信任MiKTeX
包管理器 ( mpm
) ,但显然安装过程中出现了其他问题MiKTeX
。我真的不知道是什么问题,也不知道为什么。因此,我经常mpm
卸载MiKTeX
并从头开始安装,然后再次安装便携版。也许正如 @Ulrike Fischer 所说,还有另一个安装,但我在系统上找不到它。显然,这解决了文件过时和图像丢失的问题。现在,所有图像都包含在 HTML 文件中,但有些图像被扭曲了(可能是由于某些默认大小设置),但这又是另一个问题。添加:解决方案可以在来自@michal.h21 的回答。