Michal Hoftich michal.h21 at gmail.com
Sat Mar 6 12:53:15 CET 2021

Hello Lorenzo,

>I have a figure with a caption containing "\%", like in "this is 3\% of
>that". This breaks tex4ht (I run make4ht) because in filename.4tc the
>percent is not escaped anymore, so I find the line
>
>{2.6}{\ignorespaces this is 3% of that.\relax }}}{30}\relax
>
>and the %-sign is interpreted as a comment, so the command gets broken.
>
>Is this behaviour known to you and is there a way to fix it?

I've identified the issue, which is caused by the Caption package.  The
problem is that \% is expanded before it is written to the .4tc file,
which results in unescaped comment. Immediate solution is to use

\caption{This is 3\protect\% of that}

This will prevent \% from expansion when it is written.

More systematic solution is to use this .cfg file:

%%%%%%%%%%%%%%%%
\Preamble{xhtml}
\makeatletter
\makeatother
\begin{document}
\EndPreamble
%%%%%%%%%%%%%%%

It is a modified version of Caption's macro that adds stuff to the TOC.
It prevents text from expansion. The downside is that it prevents
expansion of macros that you may want to expand before they are written.