# tex4ht produces corrupted output when using \Configure{$}{\PicMath}{\EndPicMath}{} In the tex4ht configuration file, I have these 2 lines: \Configure{$}{\PicMath}{\EndPicMath}{}
\Configure{PicMath}{}{}{}{class="math";align="absmiddle"}

These have been the .cfg for 5 years or more. No problem. These are used to tell tex4ht to convert inline math to images, else it will not. So these 2 lines are very basic and must be there all the time.

I just found out now, for some reason, when I use adjustbox, that the output is all corrupted on the HTML page. It turned out that removing the above 2 lines from the .cfg file, then the output becomes OK.

I have no idea why these 2 lines affect adjustbox or cause tex4ht to do this.

Here is MWE

\documentclass[12pt]{book}%
\usepackage{listings}
\begin{document}
\begin{lstlisting}[basicstyle=\ttfamily,columns=fullflexible,keepspaces=true]
This is just some text
which is verbatim using listing
\end{lstlisting}

\end{document}

Here is MWE nma.cfg file which should be in the same folder as the .tex file

\Preamble{ext=htm,charset="utf-8",p-width,pic-align}
\Configure{DOCTYPE}{\HCode{<!DOCTYPE html>\Hnewline}}
\Configure{HTML}{\HCode{<html>\Hnewline}}{\HCode{\Hnewline</html>}}
href="\expandafter\csname aa:CssFile\endcsname" />\Hnewline}}

\begin{document}
\Configure{\$}{\PicMath}{\EndPicMath}{}
\Configure{PicMath}{}{}{}{class="math";align="absmiddle"}
\EndPreamble

Compile with htlatex foo7_1.tex "nma.cfg,htm"

The HTML page is

When removing the .cfg file, and compiling using htlatex foo7_1.tex "htm" the output is

For somereason, tex4ht thought adjustbox content was math and tried to make it an image? Removing adjustbox and keeping the .cfg also solves the problem:

\documentclass[12pt]{book}%
\usepackage{listings}

\begin{document}
\begin{lstlisting}[basicstyle=\ttfamily,columns=fullflexible,keepspaces=true]
This is just some text
which is verbatim using listing
\end{lstlisting}
\end{document}

Compiling using htlatex foo7_1.tex "nma.cfg,htm" gives

So the question is: Can one use keep the .cfg as is, and using adjustbox with tex4ht?

This problem happens on TL 2015 and TL 2016.

tex4ht doesn't think that adjustbox uses math mode. adjustbox uses math mode internally, at least with your options. there is no configuration for adjustbox for tex4ht. some basic configuration, which just resets adjustbox environment and prints some basic HTML structure which can be styled using CSS, may look like this:

\endinput

the resulting HTML:

<div class="lstlisting" id="listing-1"><span class="label"><a
id="x1-2r1"></a></span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12">This</span><span
class="cmtt-12"> </span><span
class="cmtt-12">is</span><span
class="cmtt-12"> </span><span
class="cmtt-12">just</span><span
class="cmtt-12"> </span><span
class="cmtt-12">some</span><span
class="cmtt-12"> </span><span
class="cmtt-12">text</span><span
class="cmtt-12"> </span><br /><span class="label"><a
id="x1-3r2"></a></span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12"> </span><span
class="cmtt-12">which</span><span
class="cmtt-12"> </span><span
class="cmtt-12">is</span><span
class="cmtt-12"> </span><span
class="cmtt-12">verbatim</span><span
class="cmtt-12"> </span><span
class="cmtt-12">using</span><span
class="cmtt-12"> </span><span
class="cmtt-12">listing</span>
</div>
</div>