2

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}
\usepackage{adjustbox}
\begin{document}
\begin{adjustbox}{max width=0.8\textwidth,fbox=0.1pt,margin=2pt}
\begin{lstlisting}[basicstyle=\ttfamily,columns=fullflexible,keepspaces=true]
  This is just some text
     which is verbatim using listing
\end{lstlisting} 
\end{adjustbox}

\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>}}
\Configure{@HEAD}{}
\Configure{@HEAD}{\HCode{<meta charset="utf-8"/>\Hnewline}}
\Configure{@HEAD}{\HCode{<link rel="stylesheet" type="text/css" 
   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

Mathematica graphics

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

Mathematica graphics

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

Mathematica graphics

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.

2

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:

% adjustbox.4ht
\renewenvironment{adjustbox}[1]{}{}
\ConfigureEnv{adjustbox}{\ifvmode\IgnorePar\fi\EndP\HCode{<div class="adjustbox">}}{\ifvmode\IgnorePar\fi\EndP\HCode{</div>}}{}{}
\endinput

the resulting HTML:

  <div class="adjustbox"> <!--l. 6-->
   <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>

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.