7

I changed to using subfigure inside figure. Now when I include more than 13 figures in one document, tex4ht gives

! LaTeX Error: Counter too large.

Same document compiles OK with lualatex. I made MWE below to show this. I am using TL 2022

\documentclass[12pt,titlepage]{article}
\errorcontextlines=500
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{forloop}

\newcommand{\R}{\begin{figure}
\centering
\begin{subfigure}{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{example-image-a}
\caption{Solution plot}
\end{subfigure}%
\begin{subfigure}{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{example-image-b}
\caption{Phase plot}
\end{subfigure}%
\end{figure}}

\begin{document}      

%13 figures OK. 14 figure fails
\newcounter{x}
\forloop{x}{1}{\value{x} < 15}{%change this to 14 it works
    \R
                  
}
\end{document}
                

Command used is

make4ht -ulm default -a debug index.tex "mathjax,htm"

gives

make4ht -ulm default -a debug index.tex "mathjax,htm"
[INFO]    mkparams: Output dir: 
[INFO]    mkparams: Compiler: dvilualatex
[INFO]    mkparams: Latex options: -jobname='index'  
[INFO]    mkparams: tex4ht.sty: xhtml,mathjax,htm,charset=utf-8
[INFO]    mkparams: tex4ht:  -cmozhtf -utf8
[INFO]    mkparams: build_file: index.mk4
[INFO]    mkparams: Output format: html5
[STATUS]  make4ht: Conversion started
[STATUS]  make4ht: Input file: index.tex
[INFO]    make4ht: Using configuration file: /home/me/.config/make4ht/config.lua
[INFO]    mkutils: Using build file /home/me/.config/make4ht/config.lua
[INFO]    mkutils: Load extension   common_domfilters
[INFO]    mkutils: Cannot open config file  index.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='index'   '\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}}\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,mathjax,htm,charset=utf-8,html5.a.b.c.\input "\detokenize{index.tex}"'
This is LuaTeX, Version 1.15.1 (TeX Live 2023/dev) 
 restricted system commands enabled.
LaTeX2e <2022-11-01> patch level 1
L3 programming layer <2023-01-24> (./index.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/tex4ht.sty)
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/article.cls
Document Class: article 2022/07/02 v1.4n Standard LaTeX document class
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/size12.clo))
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/usepackage.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/graphics-hooks.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/local/texlive/2022/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)
(/usr/local/texlive/2022/texmf-dist/tex/latex/graphics-def/dvips.def)))
(/usr/local/texlive/2022/texmf-dist/tex/latex/caption/subcaption.sty
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/caption-hooks.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/latex/caption/caption.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/caption/caption3.sty)))
(/usr/local/texlive/2022/texmf-dist/tex/latex/forloop/forloop.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/ifthen.sty))
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/tex4ht.4ht
::::::::::::::::::::::::::::::::::::::::::
 TeX4ht info is available in the log file 
::::::::::::::::::::::::::::::::::::::::::
) (/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/tex4ht.sty
l.864 --- TeX4ht warning --- nonprimitive \everypar ---
--- needs --- tex4ht index ---
(./index.tmp) (./index.xref)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/unicode.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html4-math.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html5.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/unicode.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html4-math.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html5.4ht) (index.4tc)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/latex.4ht
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/fontenc.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/lm/t1lmr.fd))
(/usr/local/texlive/2022/texmf-dist/tex/generic/kastrup/binhex.tex)
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/tuenc.def)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/tuenc-luatex.4ht
(/usr/local/texlive/2022/texmf-dist/tex/luatex/luatexbase/luatexbase.sty
(/usr/local/texlive/2022/texmf-dist/tex/luatex/ctablestack/ctablestack.sty))
(/usr/local/texlive/2022/texmf-dist/tex/lualatex/luacode/luacode.sty
(/usr/local/texlive/2022/texmf-dist/tex/generic/iftex/ifluatex.sty
(/usr/local/texlive/2022/texmf-dist/tex/generic/iftex/iftex.sty)))
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/unicode.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html4-math.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html5.4ht))
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/unicode.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html4-math.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html5.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/unicode.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html4-math.4ht
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/mathjax-latex-4ht.4ht))
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html5.4ht))
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/fontmath.4ht
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/unicode.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html4-math.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html5.4ht))
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/article.4ht
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/unicode.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html4-math.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html5.4ht))
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/graphicx.4ht
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/unicode.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html4-math.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html5.4ht))
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/graphics.4ht
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/unicode.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html4-math.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html5.4ht))
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/dvips.4ht
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/unicode.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html4-math.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html5.4ht))
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/subcaption.4ht
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/unicode.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html4-math.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html5.4ht))
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/caption.4ht
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/unicode.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html4-math.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html5.4ht))
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/ifthen.4ht
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/unicode.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html4-math.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html5.4ht))
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/unicode.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html4-math.4ht)
(/usr/local/texlive/2022/texmf-dist/tex/generic/tex4ht/html5.4ht))
(/usr/local/texlive/2022/texmf-dist/tex/latex/l3backend/l3backend-dvips.def)
(./index.aux) (/usr/local/texlive/2022/texmf-dist/tex/latex/base/ts1cmr.fd)17   nil

[1] [2]
l.30 --- TeX4ht warning --- File `"example-image-a.xbb"' not found ---
l.30 --- TeX4ht warning --- Cannot determine size of graphic in "example-image-
a.xbb" (no BoundingBox) ---
l.30 --- TeX4ht warning --- File `"example-image-b.xbb"' not found ---
l.30 --- TeX4ht warning --- Cannot determine size of graphic in "example-image-
b.xbb" (no BoundingBox) ---
18  nil
[3] [4] [5]
l.30 --- TeX4ht warning --- File `"example-image-a.xbb"' not found ---
l.30 --- TeX4ht warning --- Cannot determine size of graphic in "example-image-
a.xbb" (no BoundingBox) ---
l.30 --- TeX4ht warning --- File `"example-image-b.xbb"' not found ---
l.30 --- TeX4ht warning --- Cannot determine size of graphic in "example-image-
b.xbb" (no BoundingBox) ---
[6] [7] [8]
l.30 --- TeX4ht warning --- File `"example-image-a.xbb"' not found ---
l.30 --- TeX4ht warning --- Cannot determine size of graphic in "example-image-
a.xbb" (no BoundingBox) ---
l.30 --- TeX4ht warning --- File `"example-image-b.xbb"' not found ---
l.30 --- TeX4ht warning --- Cannot determine size of graphic in "example-image-
b.xbb" (no BoundingBox) ---
[9] [10] [11]
l.30 --- TeX4ht warning --- File `"example-image-a.xbb"' not found ---
l.30 --- TeX4ht warning --- Cannot determine size of graphic in "example-image-
a.xbb" (no BoundingBox) ---
l.30 --- TeX4ht warning --- File `"example-image-b.xbb"' not found ---
l.30 --- TeX4ht warning --- Cannot determine size of graphic in "example-image-
b.xbb" (no BoundingBox) ---
[12] [13] [14]
l.30 --- TeX4ht warning --- File `"example-image-a.xbb"' not found ---
l.30 --- TeX4ht warning --- Cannot determine size of graphic in "example-image-
a.xbb" (no BoundingBox) ---
l.30 --- TeX4ht warning --- File `"example-image-b.xbb"' not found ---
l.30 --- TeX4ht warning --- Cannot determine size of graphic in "example-image-
b.xbb" (no BoundingBox) ---
[15] [16] [17]
l.30 --- TeX4ht warning --- File `"example-image-a.xbb"' not found ---
l.30 --- TeX4ht warning --- Cannot determine size of graphic in "example-image-
a.xbb" (no BoundingBox) ---
l.30 --- TeX4ht warning --- File `"example-image-b.xbb"' not found ---
l.30 --- TeX4ht warning --- Cannot determine size of graphic in "example-image-
b.xbb" (no BoundingBox) ---
[18] [19] [20]
l.30 --- TeX4ht warning --- File `"example-image-a.xbb"' not found ---
l.30 --- TeX4ht warning --- Cannot determine size of graphic in "example-image-
a.xbb" (no BoundingBox) ---
l.30 --- TeX4ht warning --- File `"example-image-b.xbb"' not found ---
l.30 --- TeX4ht warning --- Cannot determine size of graphic in "example-image-
b.xbb" (no BoundingBox) ---
[21] [22] [23]
l.30 --- TeX4ht warning --- File `"example-image-a.xbb"' not found ---
l.30 --- TeX4ht warning --- Cannot determine size of graphic in "example-image-
a.xbb" (no BoundingBox) ---
l.30 --- TeX4ht warning --- File `"example-image-b.xbb"' not found ---
l.30 --- TeX4ht warning --- Cannot determine size of graphic in "example-image-
b.xbb" (no BoundingBox) ---
[24] [25] [26]
l.30 --- TeX4ht warning --- File `"example-image-a.xbb"' not found ---
l.30 --- TeX4ht warning --- Cannot determine size of graphic in "example-image-
a.xbb" (no BoundingBox) ---
l.30 --- TeX4ht warning --- File `"example-image-b.xbb"' not found ---
l.30 --- TeX4ht warning --- Cannot determine size of graphic in "example-image-
b.xbb" (no BoundingBox) ---
[27] [28] [29]
l.30 --- TeX4ht warning --- File `"example-image-a.xbb"' not found ---
l.30 --- TeX4ht warning --- Cannot determine size of graphic in "example-image-
a.xbb" (no BoundingBox) ---
l.30 --- TeX4ht warning --- File `"example-image-b.xbb"' not found ---
l.30 --- TeX4ht warning --- Cannot determine size of graphic in "example-image-
b.xbb" (no BoundingBox) ---
[30] [31] [32]
l.30 --- TeX4ht warning --- File `"example-image-a.xbb"' not found ---
l.30 --- TeX4ht warning --- Cannot determine size of graphic in "example-image-
a.xbb" (no BoundingBox) ---
l.30 --- TeX4ht warning --- File `"example-image-b.xbb"' not found ---
l.30 --- TeX4ht warning --- Cannot determine size of graphic in "example-image-
b.xbb" (no BoundingBox) ---
[33] [34] [35]
l.30 --- TeX4ht warning --- File `"example-image-a.xbb"' not found ---
l.30 --- TeX4ht warning --- Cannot determine size of graphic in "example-image-
a.xbb" (no BoundingBox) ---
l.30 --- TeX4ht warning --- File `"example-image-b.xbb"' not found ---
l.30 --- TeX4ht warning --- Cannot determine size of graphic in "example-image-
b.xbb" (no BoundingBox) ---
[36] [37] [38]
l.30 --- TeX4ht warning --- File `"example-image-a.xbb"' not found ---
l.30 --- TeX4ht warning --- Cannot determine size of graphic in "example-image-
a.xbb" (no BoundingBox) ---
l.30 --- TeX4ht warning --- File `"example-image-b.xbb"' not found ---
l.30 --- TeX4ht warning --- Cannot determine size of graphic in "example-image-
b.xbb" (no BoundingBox) ---
[39] [40] [41]
l.30 --- TeX4ht warning --- File `"example-image-a.xbb"' not found ---
l.30 --- TeX4ht warning --- Cannot determine size of graphic in "example-image-
a.xbb" (no BoundingBox) ---

! LaTeX Error: Counter too large.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
\GenericError  ...                                
                                                  \endgroup 
\@alph ...\or v\or w\or x\or y\or z\else \@ctrerr 
                                                  \fi 
\caption@labelformat@parens ...{\nobreakspace }(#2
                                                  )
\cap:ref #1->\cur:lbl {}#1
                          \Tag {\float:cnt cAp\capt:cnt }{\cur:th \:currentl...

<argument> ...cap:ref {\csname fnum@\@subcaptype \endcsname }
                                                  {\global \let \caption@tem...

\sbox  #1#2->\setbox #1\hbox {\color@setgroup #2
                                                \color@endgroup }
\caption@@@make ...tempa {gobble\caption@tempb }}}
                                                  \ifdim \wd \@tempboxa =\z@...

<argument> ...norespaces \caption@makeanchor {Solution plot}}
                                                  }
\sbox  #1#2->\setbox #1\hbox {\color@setgroup #2
                                                \color@endgroup }
\caption@slc ...empboxa {\caption@@@make {#1}{#2}}
                                                  \ifdim \wd \@tempboxa >\ca...

<argument> ...eline \caption@multiline }{\caption@multiline }
                                                  \caption@calcmargin \capti...

\caption@box@none #1#2->#2
                          
\caption@@make@ ...#2}}\caption@make@rightmargin }
                                                  \caption@endhook 
\caption@@make ...ingroup \caption@@make@ {#1}{#2}
                                                  \endgroup \caption@@make@e...

\@makecaption ...@@make {\cap:ref {#1}}{\cptC: #2}
                                                  \cptD: \caption@make@below 
<argument> ...norespaces \caption@makeanchor {Solution plot}}
                                                  \par \caption@nobreak \cap...

\caption@setfloatcapt #1->#1
                            
\@caption ...page \@minipagetrue \@minipagefalse }
                                                  \caption@end 
\R ...h ]{example-image-a}\caption {Solution plot}
                                                   \end {subfigure}\begin {s...

<argument>  \R 
    \par \addtocounter {x}{1}\forloop [1]{x}{\value {x}}{\value {x} < 15}{ \R \

\@firstoftwo #1#2->#1
                     
l.30 }
    
? 

Since I need to include 1,000's of figures, this limitation will not work for me. I think the problem started when I changed to using \begin{subfigure}. It seems there is limitation of number of subfigures in tex4ht in one document? I need to see if I can find a workaround.

The question is: Why does the above fail in tex4ht and not in lualatex/pdf?

ps. I am using the same setup as shown in htlatex-and-subfigures in order to have side-by-side subfigures. This was from 2015. It works OK now in TL 2022 as is, but it fails when more than 13 figures are loaded.

Link to tex4ht bug tracking

3
  • 1
    13 is half of 26 so presumably you (or tex4ht) is not resetting the subfigure counter and running out of letters Commented Jun 7, 2023 at 14:23
  • @DavidCarlisle yes, the subfigure counter doesn't reset. I am not sure why.
    – michal.h21
    Commented Jun 7, 2023 at 14:32
  • @michal.h21 is it possible to reset this subfigure counter from latex level via a command? If so, I could for now, add in the code, a call to rest the counter each and every time right after making a new figure.
    – Nasser
    Commented Jun 7, 2023 at 19:34

2 Answers 2

7

It seems that the subfigure counter doesn't reset at the beginning of each figure. Each subfigure environment updates it and prints as an alphabetic label. Once you run out of the letters in alphabet, you get this error, which is why you get this error once you use more than 26 subfigures.

You can reset it automatically using this configuration file subcaption.4ht:

% subcaption.4ht (2021-07-04-09:13), generated from tex4ht-4ht.tex
% Copyright 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-07-04-09:13}

\NewConfigure{subfigure}{2}
\ConfigureEnv{subfigure}{\a:subfigure}{\b:subfigure}{}{}
\ConfigureEnv{subtable}{\a:subfigure}{\b:subfigure}{}{}
\AddToHook{env/figure/begin}{\setcounter{subfigure}{0}}
\AddToHook{env/table/begin}{\setcounter{subtable}{0}}
\Hinput{subcaption}
\endinput

The important code is this:

\AddToHook{env/figure/begin}{\setcounter{subfigure}{0}}
\AddToHook{env/table/begin}{\setcounter{subtable}{0}}

It resets the counters for each figure and table, because table can have the same issue as figure.

This is the result:

enter image description here

2

The command to reset the subfigure counter would be \setcounter{subfigure}{0}. Placing it just after the \begin{figure} allows this to compile.

Another fix is that it appears the bug doesn't happen if you add a \caption outside of the subfigure, but within the figure.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .