I installed today March 27 2022 new version of texlive. I made MWE which works well with pdfLatex. It works well with "tex4ebook -l myfile.tex". But, if I include minimal config file (from Michal's guide), I get

htlatex: ? 855 TeX capacity exceeded, sorry [input stack size=5000]

I have done during the last two years more than 50 e-books without major problems.

Now htlatex works well and dvi seems to be OK.

Why does TeX capacity overflow?

  • If you made a MWE, why not share it?
    – frabjous
    Mar 27, 2022 at 16:13
  • Don't put the code in the comments. Edit the question and use code blocks.
    – frabjous
    Mar 27, 2022 at 16:21
  • I can confirm that this happens with one of config files that I provided for you. It seems to be caused by the \CutAt command. The error goes away when you remove it.
    – michal.h21
    Mar 27, 2022 at 17:56
  • Removing \CutAt corrects that particular problem but creates many others. In Windows environment \CutAt normally produces several html-files. If it does not exist - only one. It means that whole book is in one html-file. On screen Adobe Digital Editions makes random page breaks. Is there any possibility to load earlier tex4ebook related files only? Mar 28, 2022 at 4:53

1 Answer 1


I've found some of the older configurations files I send you in the past. It is this one:

\renewcommand\breakhtml{\section[page break]{}}

I've compiled the following MWE using this config file:



Compile using:

 tex4ebook -c config.cfg -a debug sample.tex

And it indeed fails:

! TeX capacity exceeded, sorry [input stack size=5000].
\ltx:like ->\ltx:like 
                      \expandafter \let \csname likepart\endcsname \empty \e...
l.7 \CutAt{section,likesection,part}
No pages of output.
Transcript written on sample.log.
[FATAL]   make4ht-lib: Fatal error. Command htlatex returned exit code 1

The culprit seems to be the \CutAt command. It splits the generated document to separate pages on \section commands. tex4ebook now uses this command internally to split pages on \chapter for the book class, and \section for article. If you want to use custom splits, it now needs the no-cut option to be used.

I think that the correct config file should look like this:

% \renewcommand\breakhtml{\section[page break]{}}
\CutAt{part,appendix} % split on \part
\CutAt{chapter,likechapter,appendix,part} % split on \chapter
\CutAt{likechapter,appendix,part}  % split on \chapter*
\CutAt{appendix,chapter,likechapter,part}  % split on \appendix
\CutAt{likesection,chapter,likechapter,appendix,part} % split on \section*
\CutAt{section,likesection,chapter,likechapter,appendix,part} % split on \section


In addition to the original \CutAt command, it also splits on \chapter and similar commands. Feel free to remove these new additions if you don't want this effect.

  • Your answer corrected my problem. Excellent! I noticed, however, one strange thing in my Windows 10 environment. If tex file's name is "MyFile.EPUB.tex", in resulting MyFile.EPUB.epub" the whole content exists twice - double number of pages. If I remove EPUB and use file name "MyFile.tex" the result is OK. Mar 29, 2022 at 7:20
  • @TimoKuronen thanks for the report, I can confirm that. I've fixed it in tex4ebook sources.
    – michal.h21
    Mar 29, 2022 at 13:32

You must log in to answer this question.

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