1

I would like to create an HTML file from a LaTeX document. The probably most convenient approach using TeXStudio's Tools | Convert to Html... | Launch results in an error:

Error : a process has failed
Fatal error : LaTeX errors detected.

Well, very meaningful... However, PdfLaTeX works fine on this document.

So, instead, I tried to use the command line and htlatex

htlatex myFile.tex

It works all fine, the HTML is generated, but the images are missing. Well, they are in the directory but just have 1 kB in size and are empty.

During compilation I get messages for all images, like:

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

The images are mostly PNG and are included, e.g. via:

\begin{figure}[htbp]%
    \centering
    \includegraphics[width=0.8\columnwidth]{Images/myPicture.png}%
    \caption{This is a picture}%
    \label{fig:myPicture}%
\end{figure}

What am I doing wrong here? Am I missing any command line option or configuration file?

I'm using Win10, pdfTeX, Version 3.14159265-2.6-1.40.20 (MiKTeX 2.9.7050 64-bit). Any further information needed to make a suggestion?

Update:

According to @michal.h21's suggestion, I updated using the MiKTeX package manager mpm. It updated 97 packages. There was/is a package tex4ht from 2020-10-05, a package miktex-tex4ht from 2020-01-26, and a package miktex-tex4ht-x64-2.9 from 2020-10-31. Pretty confusing. Any other packages need to look at? When I ran htlatex afterwards it was installing two additional styles: I guess hosub-?something?.sty and iftex.sty. But the result is the same: no images in the HTML document. Maybe it's worth mentioning, I have a portable installation, might this cause problems?

Installed packages containing tex4 in the name:

enter image description here

Update 2: Third approach using make4ht

Result is the same as above. No error message, HTML is generated, pictures have 1 kB empty. Output:

[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

Update 3: (minimal non-working example)

LaTeX file: 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}

Image in the subfolder Images\myPicture.png

enter image description here

Result:

  • HTML is generated
  • one image in the main directory called LaTeX2Html0x.png, but size 1 kB and empty.

Output:

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

However, pdflatex to generate a PDF works fine.

Update 5: During the compilation I found a message, maybe this will give a hint?!

....
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) ---
...

What is the extension .xbb? If I rename the .png to .xbb, only the message no bounding box will remain. Do I need to have .eps files instead?

Update 6: (the output when running 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' forcmr10.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

theozh
  • 125
  • The dvipng message you got seems strange. Could you please post a complete sample document? The most important part are the used packages, maybe some of them changes the image handling. – michal.h21 Dec 08 '20 at 16:49
  • Try to update your Miktex installation, especially all tex4ht related packages. – michal.h21 Dec 08 '20 at 18:27
  • Thank you @michal.h21 for your response. I don't know what this \special{em: graph ...} should be, I don't use such a command (myself). Is something wrong with the subdirectory Images/? I read once that hyperref could be problematic. Tomorrow, I will update MiKTeX and try to create a complete minimal example. – theozh Dec 08 '20 at 18:37
  • There shouldn't be any issue with images in subdirectories. I now recall that there was similar issue after some LaTeX update earlier this year, so the update should help, as it is fixed in the current TeX4ht version. – michal.h21 Dec 08 '20 at 18:48
  • Try without extension, i.e. \includegraphics[width=0.8\columnwidth]{Images/myPicture} – vaettchen Dec 08 '20 at 19:30
  • @vaettchen no, it doesn't solve the issue. In case I had myPicture.png and myPicture.pdf or another format in the directory which one would it have taken? – theozh Dec 09 '20 at 06:56
  • yes, there are multiple TeX4ht packages in Miktex. The dates seems correct, there were some updates since then, but the fixes for the \includegraphics issues are much older, so they should be included. I think we will need to see the full MWE in this case, it can be really caused by some package. – michal.h21 Dec 09 '20 at 08:59
  • I see. Your example works fine with TeX Live. I found a similar issue from year ago: https://tex.stackexchange.com/a/517901/2891. Maybe the graphics.4ht from that answer can fix this issue. – michal.h21 Dec 09 '20 at 09:34
  • @michal.h21 I put the content of your link into graphics.4ht into the same directory as LaTeX2Html.tex. Same result, same output, no images. Actually, how will this file be called? Do I have to somehow include it into LaTeX2Html.tex? – theozh Dec 09 '20 at 09:41
  • Actually, is it \usepackage{graphicx} or \usepackage{graphics} ? The latter will lead to an error when compling with pdflatex: Paragraph ended before \Gin@iii was complete. This is getting pretty painful and annoying. – theozh Dec 09 '20 at 09:45
  • No, the .4ht file will be called automatically by TeX4ht, you don't need to include it in your TeX file. This issue is indeed strange. Can you run make4ht -m draft -a debug LaTeX2Html.tex and post the full terminal outut? Or at least the log file? – michal.h21 Dec 09 '20 at 10:03
  • The .xbb file can be created using the ebb -x Images/myPicture.png command. It contains the image dimensions. It probably won't help with the underlying issue, but it may help with the image appearance when the conversion works. – michal.h21 Dec 09 '20 at 10:04
  • your article.cls is outdated. You have article 2018/09/03 v1.4i, while the current version is article 2020/04/10 v1.4m. This clearly indicates that your system is not up-to-date. – Ulrike Fischer Dec 09 '20 at 10:16
  • @UlrikeFischer well, I was trusting the MiKTeX installation and its update. So, I need to find out how to update article.cls and try again. – theozh Dec 09 '20 at 10:19
  • The older article.cls is not the cause of your problem, it is only a clue that you didn't update your system correctly. – Ulrike Fischer Dec 09 '20 at 10:21
  • @UlrikeFischer so, MiKTeX mpm is not the right tool for updating? Can I somehow use it wrongly? It said it did 97 updates. What else then? Manual update of all packages and files? – theozh Dec 09 '20 at 10:25
  • Normally the console is quite reliable. I have no problems with it. I can't tell you what did go wrong in your case. There could be two users involved, but you anonymized the pathes, so one can't check if the updates were put in the right place. Try also to select a specific repo which is known to be up-to-date, and not a random one. – Ulrike Fischer Dec 09 '20 at 10:31
  • @UlrikeFischer there is only one user involved (just replaced username by xxx). I chose ftp.rrze.uni.erlangen.de for updating. Checking for updates results in no available updates. I think I should have the newest files, but you are saying I haven't. I don't know what else to do. – theozh Dec 09 '20 at 10:40
  • Look your terminal output says LaTeX2e <2018-12-01>. And that is old. I have latex 2020-10-01. So accept that something is wrong and try to find a clue what. You are using a portable miktex and so it is e.g. quite possible that you actually have two miktex installations around. Install for example a random package and look where it goes. – Ulrike Fischer Dec 09 '20 at 10:50

1 Answers1

1

Thank you @Ulrike Fischer and @michal.h21 for your suggestions and patience.

Rule number 1: Make sure you have an up-to-date installation!

However, I was trusting the MiKTeX package manager (mpm) , but apparently something else was messed up with the MiKTeX installation. I can't really tell what and why. Hence, I used mpm to deinstall MiKTeX and installed it from scratch and again as portable version. Maybe, as @Ulrike Fischer, says there was another installation, which I couldn't locate on the system. Apparently, this solved the problem with outdated files and the missing images. Now, all images are included in the HTML file, but some are distorted (probably, because of some default size settings), but this is again another issue. Addition: A solution to this can be found in an answer from @michal.h21.

theozh
  • 125