13 个数字 OK,14 个数字给出 ! LaTeX 错误:计数器太大。仅使用 tex4ht 和子图

13 个数字 OK,14 个数字给出 ! LaTeX 错误:计数器太大。仅使用 tex4ht 和子图

我改为使用subfigure内部图形。现在,当我在一个文档中包含超过 13 个图形时,tex4ht 给出

! LaTeX Error: Counter too large.

同一文档使用 lualatex 编译成功。我在下面制作了 MWE 来展示这一点。我使用的是 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}
                

使用的命令是

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

给出

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 }
    
? 

由于我需要包含 1,000 个图形,因此此限制对我不起作用。我认为问题始于我改用时\begin{subfigure}。似乎一个文档中的 tex4ht 中的子图数量有限制?我需要看看是否能找到解决方法。

问题是:为什么上述操作在 tex4ht 中失败而在 lualatex/pdf 中却成功?

附言:我使用的设置与htlatex 和子图以便有并排的子图。这是 2015 年的。它现在可以在 TL 2022 中正常工作,但当加载超过 13 个图时会失败。

链接到tex4ht 错误追踪

答案1

似乎subfigure计数器不会在每个图形的开头重置。每个subfigure环境都会更新它并打印为字母标签。一旦字母表中的字母用完,就会出现此错误,这就是为什么一旦使用超过 26 个子图就会出现此错误的原因。

您可以使用此配置文件自动重置它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

重要的代码是这样的:

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

它会重置每个图形和表格的计数器,因为table可能会出现与相同的问题figure

结果如下:

在此处输入图片描述

答案2

重置子图计数器的命令是\setcounter{subfigure}{0}。将其放在 之后\begin{figure}即可进行编译。

\caption另一个修复方法是,如果在子图外部添加,但在图内添加,则似乎不会发生该错误。

相关内容