michal-h21 / tex4ebook

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

Hangs when generating Part page with \renewcommand{\thepart}{\Numberstring{part}} #105

Open buttonsrtoys opened 1 year ago

buttonsrtoys commented 1 year ago

Hi Michal,

My MWE below creates a simple Parts page. When I attempt to convert to EPub using tex4ebook main.tex, the process hangs. It runs fine when when I don't convert thepart to string.

\documentclass[ebook,12pt,oneside,openany]{memoir}

\usepackage{fmtcount}
\renewcommand{\thepart}{\Numberstring{part}}

\begin{document}
    \part{The Theory}
\end{document}
image
michal-h21 commented 1 year ago

The redefined version of \thepart seems to cause issues with the auxiliary files. Try this configuration file:

\Preamble{xhtml}
\renewcommand\thepart{\arabic{part}}
\makeatletter
\Configure{part}{}{}
   {\IgnorePar \EndP\HCode{<h1 class="partHead"\csname a:LRdir\endcsname>}%
       \HCode{<span class="titlemark">}\partname \space\Numberstring{part}
       \HCode{<br /></span>}}
   {\HCode{</h1>}\IgnoreIndent\par}

\makeatother
\begin{document}
\EndPreamble

It redefines \thepart back to it's original meaning for the auxiliary files, and in \Configure{part}, we use your version with \Numberstring to print the number as a word.

buttonsrtoys commented 1 year ago

Thanks Michal! Your solution worked great. I'm curious, what is meant by the "auxiliary files"?

michal-h21 commented 1 year ago

In addition to the .aux file used by LaTeX, TeX4ht uses some additional files. .xref for links, and .4tc for tables of contents. In this case, the error happened in the .xref file.