michal-h21 / tex4ebook

Converter from LaTeX to ebook formats (epub, mobi). Using tex4ht and texlua scripts.
311 stars 32 forks source link

Problem with Komascript and include #110

Closed cedounet closed 1 year ago

cedounet commented 1 year ago

Hello,

I am having a weird issue with the following

`❯ cat book.tex \documentclass{scrbook} \begin{document} \chapter{Preface} \end{document}

❯ cat ko.tex \input{book.tex`

Both compile fine with pdflatex, but only book.tex works with tex4ebook/make4ht

`tex4ht/unicode.4ht)) (/usr/local/texlive/2023/texmf-dist/tex/latex/l3backend/l3backend-dvips.def) (./ko.aux) [1] [2] ! TeX capacity exceeded, sorry [grouping levels=255]. \adv:c #1->\bgroup \def \:temp {#1}\tmp:cnt #1\afterassignment \:gplus \mth:... l.3 \chapter{Preface}

Output written on ko.dvi (2 pages, 14552 bytes). Transcript written on ko.log. [FATAL] make4ht-lib: Fatal error. Command htlatex returned exit code 1`

Not using komascript is fine, removing the \chapter{} also is ok.

❯ make4ht -version make4ht version v0.3m

❯ tex4ebook -version tex4ebook v0.3i

michal-h21 commented 1 year ago

I think the problem in this case is with \input{book}. When you include any file, not even with \usepackage, but also with input, TeX4ht looks if a configuration file exists. In this case, it finds book.4ht and loads it before scrbook.4ht, which is requested later. These two configuration files clash each other, as both of them are meant for classes.

I was able to fix this particular issue with the following configuration file:

\Preamble{xhtml}
\makeatletter
\renewcommand\no@chapter{\scr@@startchapter{chapter}}
\makeatother
\begin{document}
\EndPreamble

But problems appear as soon as you use other commands that both scrbook.4ht and book.4ht modifies, for example \section. So, it is probably better to rename the book.tex file to something what wouldn't lead to the name clash, like xbook.tex.

cedounet commented 1 year ago

Thanks @michal-h21 , I used a symlink and it worked... as you say a lot clashed, tabelofcontents etc...

cedounet commented 1 year ago

I am happy to close it, although I naively think it should compile with htlatex if it compiles with pdf/lualtatex. Probably not realistic 😄

Thanks for all your work.

michal-h21 commented 1 year ago

Ideally it should compile, but clashes like this are hard to resolve automatically. Or maybe even impossible :/