Tex4ht gives Dimension too large with @arstrutbox when using longtable

longtabletex4ht

I was getting the error

  Overfull \vbox (22903.01811pt too high) detected at line 2038
    ! Dimension too large.
    \n:LT@start: ...\ifdim \ht \@arstrutbox >\ht \tw@
                                                      \@arstrutbox \else \tw@ \f...

As part of compiling a very large Latex file using tex4ht and this happens inside a longtable

I worked long time to reduce it to the minimum possible example.

The MWE is still too large to post, as it happens on a long longtable. So at the end of this post, I have link to zip file on my page to download the latex file called KERNEL.tex and log files it generated.

Using tex4ht and compiling using the command

 make4ht -ulm default -a debug KERNEL.tex "htm"

Gives error

make4ht -ulm default -a debug KERNEL.tex "htm"
[INFO]    mkparams: Output dir:
[INFO]    mkparams: Compiler: dvilualatex
[INFO]    mkparams: Latex options: -jobname=KERNEL
[INFO]    mkparams: tex4ht.sty: xhtml,htm,charset=utf-8
[INFO]    mkparams: tex4ht:  -cmozhtf -utf8
[INFO]    mkparams: build_file: KERNEL.mk4
[INFO]    mkparams: Output format: html5
[STATUS]  make4ht: Conversion started
[STATUS]  make4ht: Input file: KERNEL.tex
[INFO]    mkutils: Load extension       common_domfilters
[INFO]    mkutils: Cannot open config file      KERNEL.mk4
[INFO]    make4ht-lib: setting param correct_exit
[INFO]    make4ht-lib: setting param correct_exit
[INFO]    make4ht-lib: setting param correct_exit
[INFO]    make4ht-lib: setting param ext
[INFO]    make4ht-lib: Adding:  ext     dvi
[INFO]    htlatex: LaTeX call: dvilualatex --interaction=errorstopmode -jobname=KERNEL   '\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,htm,charset=utf-8,html5.a.b.c.\input "\detokenize{KERNEL.tex}"'
This is LuaTeX, Version 1.13.2 (TeX Live 2021)
 restricted system commands enabled.
LaTeX2e <2021-06-01> patch level 1
L3 programming layer <2021-08-27> (./KERNEL.tex
(/usr/local/texlive/2021/texmf-dist/tex/latex/base/article.cls
.......
l.2019 --- TeX4ht warning --- \Link{subsubsection 199}? ---
l.2029 --- TeX4ht warning --- \Link{subsubsection 200}? ---

Overfull \vbox (22903.01811pt too high) detected at line 2038
! Dimension too large.
\n:LT@start: ...\ifdim \ht \@arstrutbox >\ht \tw@
                                                  \@arstrutbox \else \tw@ \f...

l.2038 \\\hline

? X
 971873 words of node memory still in use:
   14934 hlist, 458 vlist, 2076 rule, 2128 disc, 2418 local_par, 1 dir, 840 mat
h, 37921 glue, 5047 kern, 7775 penalty, 45259 glyph, 15325 attribute, 75 glue_s
pec, 15325 attribute_list, 1 if_stack, 413 write, 25686 special nodes
   avail lists: 1:1,2:6,3:17,4:11,5:1,6:1,7:17,8:52,9:7,10:10
No pages of output.
Transcript written on KERNEL.log.
[FATAL]   make4ht-lib: Fatal error. Command htlatex returned exit code 1

There is no problem compiling using lualatex KERNEL.tex

I also updated my TL installation now to make sure I have latest version on my Linux system.

The problem happens using tex4ht only. It happend when mathjax mode or the default mode (png) as the above command shows.

Why does this error happen and is there a workaround?

Please find the zip file here (safe link. it is my own page)

table_error.zip

Update

I just compiled the same file on a Linux box, using TL 2019 which I did not update for 2 years. On this TL, there is no error.

make4ht -ulm default -a debug KERNEL.tex "htm"
[INFO]    mkparams: Output dir: 
[INFO]    mkparams: Compiler: dvilualatex
[INFO]    mkparams: Latex options: -jobname=KERNEL  
[INFO]    mkparams: tex4ht.sty: xhtml,htm,charset=utf-8
[INFO]    mkparams: tex4ht:  -cmozhtf -utf8
[INFO]    mkparams: build_file: KERNEL.mk4
[INFO]    mkparams: Output format: html5
[STATUS]  make4ht: Conversion started
[STATUS]  make4ht: Input file: KERNEL.tex
[INFO]    mkutils: Load extension   common_domfilters
[INFO]    mkutils: Cannot open config file  KERNEL.mk4
[INFO]    make4ht-lib: setting param correct_exit
[INFO]    make4ht-lib: setting param correct_exit
[INFO]    make4ht-lib: setting param correct_exit
[INFO]    make4ht-lib: setting param ext
[INFO]    make4ht-lib: Adding:  ext dvi
[INFO]    htlatex: LaTeX call: dvilualatex --interaction=errorstopmode -jobname=KERNEL   '\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,htm,charset=utf-8,html5.a.b.c.\input "\detokenize{KERNEL.tex}"'
This is LuaTeX, Version 1.10.0 (TeX Live 2019) 
 restricted system commands enabled.
LaTeX2e <2020-02-02> patch level 5
L3 programming layer <2020-02-25> (./KERNEL.tex

...

   avail lists: 2:5756,3:3677,4:11,5:634,6:298,7:9571,8:52,9:2195,10:10,11:297
Output written on KERNEL.dvi (21 pages, 372860 bytes).
Transcript written on KERNEL.log.
[INFO]    make4ht-lib: executing: tex4ht  -cmozhtf -utf8 "KERNEL.dvi"
--- warning --- Too many rows (> 146) for map: `&'
----------------------------
tex4ht.c (2018-07-03-10:36 kpathsea)
tex4ht -cmozhtf 
  -utf8 
  KERNEL.dvi 
....
INFO]    make4ht-lib: parse_lg process file: KE65x.png
[INFO]    make4ht: outdir: 
[INFO]    make4ht-lib: parse_lg process file: KE66x.png
[INFO]    make4ht: outdir: 
[STATUS]  make4ht: Conversion finished
>

Compiles with no error. But noticed

--- warning --- Too many rows (> 146) for map: `&'

above. May be this gives a clue why it fails in latest TL 2021.

Reference: https://puszcza.gnu.org.ua/bugs/index.php?527

Best Answer

Edit:

It seems that the .cfg file is not enough, you need the updated longtable.4ht file:

% longtable.4ht (2021-09-27-10:15), generated from tex4ht-4ht.tex
% Copyright 1997-2009 Eitan M. Gurari
% Copyright 2009-2021 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 2021-09-27-10:15}

   \def\:tempc[#1]#2{%
  \gHAdvance\float:cnt  1
\gHAssign\capt:cnt0
\hbox{\def\flt:anchor{}\get:cptg}%
%
  \def\Clr{#2}\a:VBorder
\HAssign\ar:cnt0
\let\HAlign\empty
%
\def\aa:longtable{%
   \gdef\aa:longtable{\let\HRow\lt:sv
       \HAdvance\HRow by 1 \global\let\:MkHalign:\lt:MkHalign:}%
   \global\setbox\LT:box\vbox{\a:longtable}%
   \global\let\lt:MkHalign:\:MkHalign:}%
\def\bb:longtable{%
   \ifHCond \global\let\bb:longtable\empty
      \global\setbox\LT:ebox=\vbox{{\ht:everypar{}\leavevmode}\b:longtable}%
      \global\HCondfalse
   \fi}
%
  \refstepcounter{table}\stepcounter{LT@tables}%
  \if l#1%
    \LTleft\z@ \LTright\fill
  \else\if r#1%
    \LTleft\fill \LTright\z@
  \else\if c#1%
    \LTleft\fill \LTright\fill
  \fi\fi\fi
  \let\LT@mcol\multicolumn
  \let\LT@@tabarray\@tabarray
  \let\LT@@hl\hline
  \def\@tabarray{%
    \let\hline\LT@@hl
    \LT@@tabarray}%
  \let\\\LT@tabularcr\let\tabularnewline\\%
  \let\newpage\empty
\let\pagebreak\empty
\let\nopagebreak\empty
%
  \let\hline\LT@hline \let\kill\LT@kill\let\caption\LT@caption
  \@tempdima\ht\strutbox
  \let\@endpbox\LT@endpbox
  \ifx\extrarowheight\@undefined
    \let\@acol\@tabacol
    \let\@classz\@tabclassz \let\@classiv\@tabclassiv
    \def\@startpbox{\vtop\LT@startpbox}%
    \let\@@startpbox\@startpbox
    \let\@@endpbox\@endpbox
    \let\LT@LL@FM@cr\@tabularcr
  \else
    \advance\@tempdima\extrarowheight
    \col@sep\tabcolsep
    \let\@startpbox\LT@startpbox\let\LT@LL@FM@cr\@arraycr
  \fi
  \setbox\@arstrutbox\hbox{}%
  \let\@sharp##\let\protect\relax
   \begingroup
    \@mkpream{#2}%
    \xdef\LT@bchunk{%
       \global\advance\c@LT@chunks\@ne
       \global\LT@rows\z@\setbox\z@\vbox\bgroup
       \LT@setprevdepth
       \everycr{}\tabskip\LTleft\noexpand\MkHalign\noexpand\@sharp
   {\tabskip\z@ \@arstrut \@preamble \tabskip\LTright}%
}%
       \tmp:cnt=0
\global\let\:tempa\empty
\loop\ifnum \ar:cnt>\tmp:cnt
   \advance\tmp:cnt by 1
   \expandafter\ifx \csname @testpach \the\tmp:cnt\endcsname\relax
   \else
      \xdef\:tempa{%
          \:tempa
          \def \expandafter\noexpand
             \csname @testpach \the\tmp:cnt\endcsname{\csname @testpach
             \the\tmp:cnt\endcsname}}%
      \expandafter\let\csname @testpach \the\tmp:cnt\endcsname\relax
   \fi
\repeat
\aftergroup\:tempa
\xdef\:temp{%
   \def\noexpand\HAlign{\HAlign}%
   \def\noexpand\ar:cnt{\ar:cnt}}\aftergroup\:temp
%
  \endgroup
  \LT@cols\ar:cnt
%
  \LT@make@row
  \m@th\let\par\@empty
  \everycr{}\lineskip\z@\baselineskip\z@
  \ifx \EndPicture\:UnDef
     \SaveMkHalignConfig \ifx \recall:ar\:UnDef
   \edef\recall:ar{%
      \noexpand\ifx \noexpand\EndPicture\noexpand\:UnDef \noexpand\else
         \arrayrulewidth\the\arrayrulewidth
         \doublerulesep\the\doublerulesep
         \arraycolsep\the\arraycolsep
         \tabcolsep\the\tabcolsep
      \noexpand\fi }%
\fi
\arrayrulewidth\z@  \doublerulesep\z@
\arraycolsep\z@     \tabcolsep\z@
\Configure{MkHalign}
  \aa:longtable
  {\bb:longtable \ProperTrTrue}
  {\a:putHBorder\InitHBorder \ifProperTr{\c:longtable}}
  {\ifProperTr{\d:longtable}\a:putHBorder\InitHBorder}%
  {\ifProperTr{\e:longtable}\RecallMkHalignConfig\recall:ar}
  {\ifProperTr{\f:longtable}}
%
     \let\@sharp\relax
  \else \let\@sharp##\fi
  \LT@bchunk}
\HLet\LT@array\:tempc
\def\:tempc{%
  \crcr\LT@save@row\cr
  \ifx \EndPicture\:UnDef \EndMkHalign\else \egroup\fi
%
  \global\setbox\@ne\lastbox    \unskip
  \egroup}
\HLet\LT@echunk\:tempc
\let\:tempc\LT@startpbox
\append:defI\:tempc{\everypar{\HtmlPar}\a:longtableparbox}%
\HLet\LT@startpbox\:tempc
\NewConfigure{longtableparbox}{1}
\NewConfigure{longtable}{6}
\csname newbox\endcsname\LT:box
\csname newbox\endcsname\LT:ebox
\def\:tempc{%
  \ifvoid\LT@head\else
     \ifvoid\LT@firsthead
        \global\setbox\LT@firsthead=\hbox{\box\LT@head}%
     \else
        \global\setbox\tmp:bx=\hbox{\box\LT@head}%
  \fi\fi%
  \box\LT:box%
  \ifvoid\LT@firsthead\copy\LT@head\else\box\LT@firsthead\fi\nobreak
  \output{\LT@output}
}
\HLet\LT@start\:tempc
\let\:tempc\endlongtable
\append:def\:tempc{\box\LT:ebox}
\pend:def\:tempc{\global\HCondtrue}
\HLet\endlongtable\:tempc
\let\:tempc\LT@ntabularcr
\pend:def\:tempc{\global\let\lt:sv\HRow}
\HLet\LT@ntabularcr\:tempc
\let\:tempc\LT@end@hd@ft
\pend:defI\:tempc{\global\let\lt:sv\HRow}
\HLet\LT@end@hd@ft\:tempc
%\def\:tempc{\global\let\lt:sv\HRow}
%\HLet\LT@kill\:tempc
\def\LT@rebox#1\bgroup{%
  #1\bgroup
  \unskip
}
\let\:tempc\LT@kill
\pend:def\:tempc{\global\let\lt:sv\HRow}
\HLet\LT@kill\:tempc
\let\LT:argtabularcr\LT@argtabularcr
\def\:tempc{\global\let\lt:sv\HRow  \LT:argtabularcr}
\HLet\LT@argtabularcr\:tempc
\ifx \tmp:bx\:UnDef \csname newbox\endcsname \tmp:bx \fi
%\def\:tempc{\LT@end@hd@ft\tmp:bx}
%\HLet\endhead\:tempc
% \def\:tempc{\LT@end@hd@ft\tmp:bx}
% \HLet\endfoot\:tempc
\pend:def\LT@output{%
  \ifvoid\LT@foot\else
     \ifvoid\LT@lastfoot
        \global\setbox\LT@lastfoot=\hbox{\box\LT@foot}%
     \else
        \global\setbox\tmp:bx=\hbox{\box\LT@foot}%
  \fi\fi
}
\def\:tempc{\global\HCondtrue \LT@end@hd@ft\LT@lastfoot}
\HLet\endlastfoot\:tempc
\def\LT@tabularcr{%
  \relax\iffalse{\fi\ifnum0=`}\fi
  \@ifstar
    {\LT@t@bularcr}%
    {\LT@t@bularcr}}

   \def\:tempc{%
  \o:noalign:{\ifnum0=`}\fi
    \penalty\@M
    \futurelet\@let@token\LT@@hline}
\HLet\LT@hline\:tempc
\def\:tempc{%
  \ifx\@let@token\hline
    \global\let\@gtempa\@gobble
    \gdef\LT@sep{\penalty-\@medpenalty\vskip\doublerulesep}%
  \else
    \global\let\@gtempa\@empty
    \gdef\LT@sep{\penalty-\@lowpenalty\vskip-\arrayrulewidth}%
  \fi
  \ifnum0=`{\fi}%
  \a:hline
%
  \o:noalign:{\penalty\@M}%
  \@gtempa}
\HLet\LT@@hline\:tempc

   \def\:tempc{%
  \o:noalign:\bgroup  \gHAdvance\TitleCount  1
    \@ifnextchar[{\egroup\LT@c@ption\@firstofone}\LT@capti@n}
\HLet\LT@caption\:tempc
\def\:tempc#1#2#3{%
  \LT@mcol\LT@cols c{\hbox{\parbox[t]\LTcapwidth{%
    \cptA: #1{\cap:ref{#2}}\if\relax\detokenize{#1}\relax\else\cptB:\fi\cptC:#3\cptD:
    \endgraf\vskip\baselineskip}}}}
\HLet\LT@makecaption\:tempc
\def\:tempc#1[#2]#3{%
  \LT@makecaption#1\fnum@table{#3}%
  \cur:lbl{}%
  \def\@tempa{#2}%
  \ifx\@tempa\@empty\else%
  {\let\\\space%
  \protect:wrtoc%
  \edef\:temp{#2}%
  \edef\:temp{\the\:tokwrite{\string\doTocEntry%
  \string\toclot%
  {\thetable}{\string\csname\space a:TocLink\string\endcsname%
    {\FileNumber}{\cur:th \:currentlabel}{}{\ifx\:temp\empty\else \ignorespaces #2\fi}}%
      {}\relax}}\:temp%
  }%
  \fi%
}

\HLet\LT@c@ption\:tempc

\Hinput{longtable}
\endinput

It seems that your table is too high, which is probably caused by the fact that it is not broken into pages as in normal LaTeX run. As a work around, we can redefine the code that puts table rows to omit the dimension checking, as it doesn't seem to be useful with TeX4ht anyway.

Try this configuration file:

\def\LT@start{%
  \ifvoid\LT@firsthead\copy\LT@head\else\box\LT@firsthead\fi\nobreak
  \output{\LT@output}
}
\Preamble{xhtml}
\begin{document}
\EndPreamble

I had to put redefinition of \LT@start before the \Preamble command, because longtable.4ht patches this command too. If we put it after \Preamble, this patch would fail.

With this change, your file compiles without errors, except for failed DOM parsing. It turned out that your file produces invalid HTML code, due to the fact that you use the following code in the table:

 \ifdefined\HCode\hyperlink{subsubsection 1}\else \hyperlink{subsection 1}\fi{ODE 1} &

I would use a custom command, something like this:

  \newcommand\sectionlink[2]{\ifdefined\HCode\hyperlink{subsubsection #1}{#2}\else\hyperlink{subsection #1}{#2}\fi}

WIth this change, it works correctly.

Here is a smaller test:

\documentclass[11pt]{article}
\usepackage{amsmath} 
\usepackage{amssymb}
\usepackage{xcolor}% http://ctan.org/pkg/color
\usepackage[colorlinks,allcolors=blue,linktocpage,bookmarks,bookmarksdepth=3]{hyperref}
\usepackage{bookmark}%added may 26,2020 to get rid of 
\hypersetup{%
  colorlinks=false,% hyperlinks will be black  
  urlbordercolor=blue%  
}

\usepackage{pifont} %http : // ctan.org/pkg/pifont
\newcommand{\cmark}{\ding{51}} %
\newcommand{\xmark}{\ding{55}} %


\usepackage{longtable}
\usepackage{listings,lstautogobble}% added lstautogobble oct 30,2020


\newcommand\sectionlink[2]{\ifdefined\HCode\hyperlink{subsubsection #1}{#2}\else\hyperlink{subsection #1}{#2}\fi}
\begin{document}
%%%%%%%%%%%%%%%%
\section{Detailed lookup table and classification for each ODE}
\begin{center}
\begin{longtable}{|l|p{5 in}|}\hline
\caption{ODE classification and performance for each differential equation}\label{table:4} \\\hline 
%---------------------------------------
\#&result\\\hline
\endfirsthead
%------------------------------------
\multicolumn{2}{c}{\tablename\ \thetable{} -- continued from previous page} \\\hline 
\#&result\\\hline
\endhead\hline 

\multicolumn{2}{|r|}{Continued on next page} \\ \hline
\endfoot\hline
\endlastfoot

% \ifdefined\HCode\hyperlink{subsubsection 1}\else \hyperlink{subsection 1}\fi{ODE 1}&
\sectionlink{1}{ODE 1} &
$y'(x)=a f(x)$
\begin{lstlisting}
[_quadrature]
\end{lstlisting}

\underline{Solution method} Separable ODE, Dependent variable missing\newline

Maple \textcolor{blue}{\Large \cmark}\newline Mathematica \textcolor{blue}{\Large \cmark}
\\\hline
% \ifdefined\HCode\hyperlink{subsubsection 2}\else \hyperlink{subsection 2}\fi{ODE 2}&
\sectionlink{2}{ODE 2} &
$y'(x)=y(x)+x+\sin (x)$
\begin{lstlisting}
[[_linear, `class A`]]
\end{lstlisting}

\underline{Solution method} Linear ODE\newline

Maple \textcolor{blue}{\Large \cmark}\newline Mathematica \textcolor{blue}{\Large \cmark}
\\\hline
\end{longtable}
\end{center}

\end{document}

Ant this is the result:

enter image description here