0

I am trying to convert a Latex document using tex4ht program, but various errors occur during conversion. To perform conversion, I inserted make4ht -l something.tex in the TeX Live command-line (something is the name of the document), while the minimal example is:

% !TeX program = lualatex
% !TeX encoding = UTF-8 Unicode

\documentclass[10pt,a4paper,twoside]{report}
\usepackage{fontspec}
\setmainfont{Arial}
%\usepackage{kotex} 

\usepackage{float}
\usepackage{graphicx,graphbox}
\usepackage{enumitem}
\setlist[itemize,2]{label={$\circ$}}
\usepackage{longtable}
\usepackage{arydshln}

\usepackage{tikz}
\usetikzlibrary{calc}
\newcommand{\textbox}[1]{node[black,fill=white, draw=black,line width=0.03cm,font=\small,text width = {#1}]}
\newcommand{\numbox}[1]{node[black,line width=0.028cm,fill=white,font=\small, draw={#1}]}
\newenvironment{tiks}[1]{%
    \begin{tikzpicture}
        \node [above right,inner sep=0] (image) at (0,0){#1};
        \begin{scope}[x={($0.1*(image.south east)$)},y={($0.1*(image.north west)$)}]
        }
        {
        \end{scope}
        \path ($(image.center)!-1!(current bounding box.west)$)% expand east border
        ($(image.center)!-1!(current bounding box.east)$);% expand west border
\end{tikzpicture}}

\begin{document}
    
    \begin{titlepage}   
        \vspace*{5cm}   
        \begin{tabular}{l l l}
            & & \bfseries H:\\
        \end{tabular}   
    \end{titlepage}
    
    \begin{itemize}
        \item Zufriedenheit
        \begin{itemize}
            \item something 1
        \end{itemize}
    \end{itemize}
    
    \noindent\begin{minipage}[t]{0.3\textwidth}
        \vspace{-3.75ex}
        \begin{figure}[H]
            \begin{tiks}{\includegraphics[width=\linewidth,height=7.6cm,trim={0cm 0cm 0cm 0cm},clip]{example-image}}
                \draw (1.7,7.15)
                \numbox{black}{1};
                \draw[latex-, line width = 0.03cm,red,align=center,left] 
                (8,8) -- (5,8)
                \textbox{2cm} {taste};
            \end{tiks}
        \end{figure}
    \end{minipage}
    
    \begin{tikzpicture}[remember picture,overlay,shift={(current page.north east)}]
        \node[anchor=north east,xshift=-7.9cm,yshift=-6.4cm]{\includegraphics[width=0.7cm,height=1cm]{example-image}};
    \end{tikzpicture}

%   \begin{longtable}{|p{2.8cm}|p{0.6cm}|}
%       \hline
%       Name & Year \\
%       \hline
%   \end{longtable}
    
\end{document}

The result I obtained when trying to perform the conversion is:

C:\Users\Me>make4ht -l something.tex
[STATUS]  make4ht: Conversion started
[STATUS]  make4ht: Input file: something.tex
This is LuaTeX, Version 1.13.2 (TeX Live 2021/W32TeX)
 restricted system commands enabled.
Unsupported font        cmsy10
[ERROR]   htlatex: Compilation errors in the htlatex run
[ERROR]   htlatex: Filename     Line    Message
[ERROR]   htlatex: \adl@colsL /\number \adl@... 37       Undefined control sequence.
[ERROR]   htlatex: \adl@colsL /\number \adl@... 37       Undefined control sequence.
[ERROR]   htlatex: \adl@colsR /\number \adl@... 37       Undefined control sequence.
[ERROR]   htlatex: \adl@colsR /\number \adl@... 37       LaTeX Error: File `"example-image.xbb"' not found.
[ERROR]   htlatex: \adl@colsR /\number \adl@... 50       LaTeX Error: Cannot determine size of graphic in "example-image.xbb" (no Boun
[ERROR]   htlatex: \adl@colsR /\number \adl@... 50       LaTeX Error: File `"example-image.xbb"' not found.
[ERROR]   htlatex: \adl@colsR /\number \adl@... 61       LaTeX Error: Cannot determine size of graphic in "example-image.xbb" (no Boun
[ERROR]   htlatex: ?    855      Undefined control sequence.
This is LuaTeX, Version 1.13.2 (TeX Live 2021/W32TeX)
 restricted system commands enabled.
Unsupported font        cmsy10
[ERROR]   htlatex: Compilation errors in the htlatex run
[ERROR]   htlatex: Filename     Line    Message
[ERROR]   htlatex: \adl@colsL /\number \adl@... 37       Undefined control sequence.
[ERROR]   htlatex: \adl@colsL /\number \adl@... 37       Undefined control sequence.
[ERROR]   htlatex: \adl@colsR /\number \adl@... 37       Undefined control sequence.
[ERROR]   htlatex: \adl@colsR /\number \adl@... 37       LaTeX Error: File `"example-image.xbb"' not found.
[ERROR]   htlatex: \adl@colsR /\number \adl@... 50       LaTeX Error: Cannot determine size of graphic in "example-image.xbb" (no Boun
[ERROR]   htlatex: \adl@colsR /\number \adl@... 50       LaTeX Error: File `"example-image.xbb"' not found.
[ERROR]   htlatex: \adl@colsR /\number \adl@... 61       LaTeX Error: Cannot determine size of graphic in "example-image.xbb" (no Boun
[ERROR]   htlatex: ?    855      Undefined control sequence.
This is LuaTeX, Version 1.13.2 (TeX Live 2021/W32TeX)
 restricted system commands enabled.
Unsupported font        cmsy10
[ERROR]   htlatex: Compilation errors in the htlatex run
[ERROR]   htlatex: Filename     Line    Message
[ERROR]   htlatex: \adl@colsL /\number \adl@... 37       Undefined control sequence.
[ERROR]   htlatex: \adl@colsL /\number \adl@... 37       Undefined control sequence.
[ERROR]   htlatex: \adl@colsR /\number \adl@... 37       Undefined control sequence.
[ERROR]   htlatex: \adl@colsR /\number \adl@... 37       LaTeX Error: File `"example-image.xbb"' not found.
[ERROR]   htlatex: \adl@colsR /\number \adl@... 50       LaTeX Error: Cannot determine size of graphic in "example-image.xbb" (no Boun
[ERROR]   htlatex: \adl@colsR /\number \adl@... 50       LaTeX Error: File `"example-image.xbb"' not found.
[ERROR]   htlatex: \adl@colsR /\number \adl@... 61       LaTeX Error: Cannot determine size of graphic in "example-image.xbb" (no Boun
[ERROR]   htlatex: ?    855      Undefined control sequence.
pre-processing DVI file (format version 2)
processing page 2
  graphic size: 133.83823pt x 44.064459pt (47.038758mm x 15.486886mm)
  output written to /
1 of 4 pages converted in 0.803 seconds
pre-processing DVI file (format version 2)
processing page 3
  page is empty
  graphic size: 0pt x 0pt (0mm x 0mm)
  output written to /
1 of 4 pages converted in 0.732 seconds
[STATUS]  make4ht: Conversion finished
C:\texlive\2021\bin\win32\runscript.tlu:915: command failed with exit code 1:
texlua c:\texlive\2021\texmf-dist\scripts\make4ht\make4ht -l something.tex

I made the following assessment of some obtained errors:

  1. Unsupported font cmsy 10 warning: This warning is a consequence of the nested itemize environment due to \setlist[itemize,2]{label={$\circ$}} line.

  2. htlatex: \adl@colsL /\number \adl@... 82 Undefined control sequence: Something related to or inside the titlepage environment. However, this error disappears when I comment the arydshln package.

  3. htlatex: \adl@colsR /\number \adl@... 82 LaTeX Error: File `"example-image.xbb"' not found: This error (and the error following it) is the consequence of Tikz pictures. While I can get rid of error by creating xbb file (with inserting ebb -x example-image.png in TeX Live command-line, see https://www.kodymirus.cz/tex4ht-doc/Howto.html#graphics, after moving example-image.png to C:\Users\Me), the created HTML still does not have the example-image.

Aside from the main question, I have two additional questions (which are not that relevant and will be not considered when accepting hypothetical answer):

  1. After uncommenting the longtable example, the conversion does not finish, unless I comment the arydshln package. How to fix this?
  2. When I uncomment the kotex package, various errors occur. Again, how to fix this?
2
  • 2
    A few observations: 1.) You can use example-image-a etc. as an image name in your MWE (it ships with all current distributions). You should also leave out the .png suffix. 2.) This is by no means a minimal example. Try to further reduce it to the part of your document that actually produces the error. 3.) Please restrict yourself to one issue at a time, simply post another question. Easier to keep track of useful answers that way.
    – Ingmar
    Mar 19 at 11:00
  • Sorry for that, I will try to further reduce the posted example. Regarding 1.), I mentioned the use of ebb -x Slika.png for which I am not sure if it can be performed for example images (I will check that).
    – t387
    Mar 19 at 11:10

1 Answer 1

2

There is a lot of non-related issues, but I found fixes to most of them:

  1. issues with tables. It seems that the arydshln patches a lot of internal LaTeX macros for dealing with tables. You can try this version of arydshln.4ht:

\def\:new:array{\adl@everyvbox\everyvbox
        \everyvbox{\adl@arrayinit \the\adl@everyvbox \everyvbox\adl@everyvbox}%
        \ifadl@inactive \adl@inactivate \else \adl@activate \fi
        \let\adl@noalign\noalign}
\ifcsname n:@array:\endcsname% if \@array was already patched
\let\orig:n@array\n:@array:
\def\n:@array:{\:new:array\orig:n@array}
\else
\pend:def\@array{\:new:array}
\fi
\Hinput{arydshln}
\endinput

It tries to insert code that initializes arydshln macros to TeX4ht versions of \@array. This should prevent compilation errors. It isn't enough for longtable though. As the features provided by this package aren't supported by TeX4ht anyway, you may want to just include it conditionally. Put into your preamble following condition:

\usepackage{longtable} 
\ifdefined\HCode\else                                                                                                                                                                 
\usepackage{arydshln}  
\fi                                                                                                                                                               
\usepackage{multirow}
  1. graphics issues. This one is more complex. The problem is that you have \includegraphics inside TikZ environments. TikZ is converted to pictures using the \Picture command internally. It then depends on DVI converters if they support image inclusion. As TikZ is converted to SVG with DVISGM, we need to use the dvisvgm driver for the Graphics package for correct support.

All of this is pretty complicated and it needs also some changes to your TeX document.

First of all, to get rid of the XBB errors, try this version of graphics.4ht :

% graphics.4ht (2022-03-21-12:05), generated from tex4ht-4ht.tex
% Copyright 1997-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-03-21-12:05}


   \expandafter\let\csname includegraphics \endcsname\includegraphics
\def\includegraphics{\expandafter\protect\csname includegraphics \endcsname}
\def\grf:removequote"#1"{#1}
\def\grf:thrashname#1\relax{}
\def\grf:fixquotes{%
    \@ifnextchar"{\edef\Gin@base{\expandafter\grf:removequote\Gin@base}\grf:thrashname}{\grf:thrashname}}
\def\grp:warning#1{\no:bound#1(no BoundingBox)//\:warning{#1}}
\def\no:bound#1(no BoundingBox)#2//{\gdef\noBoundingBox{#2}\ifx
   \noBoundingBox\empty \global\let\noBoundingBox\:UnDef\fi}
\let\:tempc\Gin@setfile
\pend:defIII\:tempc{\a:graphics
    \global\let\noBoundingBox\:UnDef
    \let\@latex@error\grp:warning \let\@ehc\empty}
\append:defIII\:tempc{\b:graphics\grf:gobble\leavevmode grf:gobble}
\HLet\Gin@setfile\:tempc
\NewConfigure{graphics*}[2]{%
   \expandafter\ifx \csname :.#1\endcsname\relax
      \pend:defIII\n:Gin@setfile:{\csname :.#1\endcsname}%
   \fi
   \def\:temp{#2}\ifx \:temp\empty
     \expandafter\let\csname :.#1\endcsname\:UnDef
   \else
     \expandafter\def\csname :.#1\endcsname{\edef\:temp{\detokenize{.#1}}%
        \ifx \:temp\Gin@ext  \let\a:graphics\relax
           \def\G:cnfg{#2}\expandafter\grf:gobble \fi}%
   \fi }
\NewConfigure{graphics}{2}
\def\grf:gobble#1\leavevmode#2grf:gobble{%
   \PictureOff\expandafter\grf:fixquotes\Gin@base\relax#1\PictureOn \G:cnfg \let\G:cnfg\relax}
\let\G:cnfg\relax

\let\old:GreadEps\Gread@eps
\def\Gread@eps#1{\old:GreadEps{"#1"}}
\def\if:boundingbox#1#2{\ifdim\Gin@req@width=\Gin@nat@width\ifx\noBoundingBox\UnDefined#1\else#2\fi\else#1\fi}
\def\Gin:defaultdriver{dvips.def}
\ifx\Gin@driver\Gin:defaultdriver%
\DeclareGraphicsRule{.png}{bmp}{.xbb}{}
\DeclareGraphicsRule{.jpg}{bmp}{.xbb}{}
\DeclareGraphicsRule{.gif}{bmp}{.xbb}{}
\DeclareGraphicsRule{.pdf}{bmp}{.xbb}{}
\DeclareGraphicsRule{.svg}{bmp}{.xbb}{}
\fi

\Hinput{graphics}
\endinput

The change is that it runs \DeclareGraphicsRule only when dvips driver is active. We don't want it with the dvisvgm driver. You still need to create .xbb files using

ebb -x *.png

Then, change the call to graphicx package:

\ifdefined\HCode
\usepackage[dvisvgm]{graphicx}
\else
\usepackage{graphicx}
\fi

It will use the dvisvgm driver with TeX4ht, but default with normal LaTeX, as dvisvgm wouldn't work in that case.

For some reason, TikZ changes the driver back to dvips. So you need to declare the correct driver again after TikZ was loaded. You can do that using this configuration file:

\makeatletter
\def\Gin@driver{dvisvgm.def}
\makeatother
\Preamble{xhtml}
\begin{document}
\EndPreamble

With these changes, the SVG file will contain your PNG file. But it seems that for some security reason, browsers will not display it. It seems that it is necessary to change <img> tag to <embed>. We can do that using the following build file:

local domfilter = require "make4ht-domfilter"

local process = domfilter {
  function(dom)
    for _,img in ipairs(dom:query_selector("img")) do
      -- change <img> tags to <embed> for SVG images
      if img:get_attribute("src"):match("svg$") then
        img._name = "embed"
      end
    end
    return dom
  end
}

Make:match("html$", process)

With all these changes, you can compile your file using:

make4ht -l -c config.cfg -e build.lua filename.tex

And this is the result:

enter image description here

The picture is still not correct. It seems that resizing don't work correctly in this case. In the end, I would create the picture as a separate PDF file, and include that, instead of this complicated setup.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.