1

A memory error occurs when using the package polyglossia, setting french as default language and compiling with make4ht.

Here is a simple code to reproduce the error:

\documentclass{article}
\usepackage{polyglossia}
\setdefaultlanguage{french}
\title{Test: 123}
\begin{document}
\maketitle
\end{document}

The error message is:

[ERROR]   htlatex: ?    14   TeX capacity exceeded, sorry [main memory size=5000000].
[FATAL]   make4ht-lib: Fatal error. Command htlatex returned exit code 1

I'm compiling with

make4ht -u -x test
1

TeX4ht uses some tricks to support Unicode input. In XeLaTeX, it makes most of characters active. The active characters are then used to insert \special commands with instructions for Unicode. It seems to clash with Polyglossia in this case, as you can see from the full error message:

! TeX capacity exceeded, sorry [main memory size=5000000].
\nobreakspace ...l {t4ht@+\string &{35}x00A0{59}}x

The problem is that Polyglossia with XeTeX makes some characters active as well. Somehow it results in memory overflow. In your case the problem is with colon in your title \title{Test: 123}.

To fix that, we must redefine \nobreakspace at the moment when Polyglossia defines active characters, which is done by the \french@punctuation command.

Save the following code as gloss-french.4ht:

\pend:def\french@punctuation{\bgroup\let\nobreakspace\space}
\append:def\french@punctuation{\egroup}
\endinput

This file is loaded automatically by TeX4ht when you use Polyglossia with French. The \pend:def command executes code before the redefined command, \append:def executes it after command ends.

Your example then compiles without errors:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.