2

I am using htlatex to convert a TeX files to XML file.

I am using mathml options to convert a inline and display equations.

But I need three alternatives in one compilation.

  1. Inline-graphics format (.jpg format)
  2. mathml coding
  3. tex-math coding - CDATA as per mentioned required output

But my current output is only mathml coding.

MWE:

\documentclass{article}

%\usepackage{mycommands}
\usepackage[utf8]{inputenc}
\usepackage{fixltx2e}
\usepackage[numbers,compress]{natbib}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{upgreek}
\usepackage{subscript}
\usepackage{hyperref}
\usepackage{graphics}


\begin{document}

Using the relation in, radiative heat flux \textit{q}\textsubscript{r} gas near equilibrium is given by
\begin{equation} \label{GrindEQ__7_} 
\frac{\partial q_{r} }{\partial y^{*} } =4(T_{1} -T^{*} ) I^{\prime},  I^{\prime} =\int k_{\lambda _{1} w  } \frac{     \partial e_{b\lambda _{1 } } }{\partial T}  d\lambda_{1}  
\end{equation} 
Here \textit{q}\textsubscript{r} is the radiative heat flux, \(k_{{\lambda}_1w}\) is the radiation absorption coefficient at the wall and \(e_{b{\lambda }_{1}}\) is Plank's \hbox{constant.} 

\end{document}

My Current output:

<p>Using the relation in, radiative heat flux <italic>q</italic><sub>r</sub> gas near equilibrium is given by </p> 
<table class="equation"><tr><td>
<a 
 id="x1-2r1"></a>
<!--l. 19--><mml:math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="block" mml:class="equation">
               <mml:mfrac><mml:mrow 
><mml:mi>&#x2202;</mml:mi><mml:msub><mml:mrow 
><mml:mi>q</mml:mi></mml:mrow><mml:mrow 
><mml:mi>r</mml:mi></mml:mrow></mml:msub 
></mml:mrow>
<mml:mrow 
><mml:mi>&#x2202;</mml:mi><mml:msup><mml:mrow 
><mml:mi>y</mml:mi></mml:mrow><mml:mrow 
><mml:mo mmlclass="MathClass-bin">*</mml:mo></mml:mrow></mml:msup 
></mml:mrow></mml:mfrac> <mml:mo mmlclass="MathClass-rel">=</mml:mo> <mml:mn>4</mml:mn><mml:mrow><mml:mo mmlclass="MathClass-open">(</mml:mo><mml:mrow><mml:msub><mml:mrow 
><mml:mi>T</mml:mi></mml:mrow><mml:mrow 
><mml:mn>1</mml:mn></mml:mrow></mml:msub 
> <mml:mo mmlclass="MathClass-bin">-</mml:mo> <mml:msup><mml:mrow 
><mml:mi>T</mml:mi></mml:mrow><mml:mrow 
><mml:mo mmlclass="MathClass-bin">*</mml:mo></mml:mrow></mml:msup 
></mml:mrow><mml:mo mmlclass="MathClass-close">)</mml:mo></mml:mrow><mml:msup><mml:mrow 
><mml:mi>I</mml:mi></mml:mrow><mml:mrow 
><mml:mi>&#x2032;</mml:mi></mml:mrow></mml:msup 
><mml:mo mmlclass="MathClass-punc">,</mml:mo><mml:msup><mml:mrow 
><mml:mi>I</mml:mi></mml:mrow><mml:mrow 
><mml:mi>&#x2032;</mml:mi></mml:mrow></mml:msup 
> <mml:mo mmlclass="MathClass-rel">=</mml:mo><mml:mo mmlclass="MathClass-op"> &#x222B;
 <!--nolimits--></mml:mo><!--nolimits--><mml:msub><mml:mrow 
><mml:mi>k</mml:mi></mml:mrow><mml:mrow 
><mml:msub><mml:mrow 
><mml:mi>&#x03BB;</mml:mi></mml:mrow><mml:mrow 
><mml:mn>1</mml:mn></mml:mrow></mml:msub 
><mml:mi>w</mml:mi></mml:mrow></mml:msub 
><mml:mfrac><mml:mrow 
><mml:mi>&#x2202;</mml:mi><mml:msub><mml:mrow 
><mml:mi>e</mml:mi></mml:mrow><mml:mrow 
><mml:mi>b</mml:mi><mml:msub><mml:mrow 
><mml:mi>&#x03BB;</mml:mi></mml:mrow><mml:mrow 
><mml:mn>1</mml:mn></mml:mrow></mml:msub 
></mml:mrow></mml:msub 
></mml:mrow> 
  <mml:mrow 
><mml:mi>&#x2202;</mml:mi><mml:mi>T</mml:mi></mml:mrow></mml:mfrac>  <mml:mi>d</mml:mi><mml:msub><mml:mrow 
><mml:mi>&#x03BB;</mml:mi></mml:mrow><mml:mrow 
><mml:mn>1</mml:mn></mml:mrow></mml:msub 
>
</mml:math></td><td class="eq-no">(1)</td></tr></table>
<p>   Here <italic>q</italic><sub>r</sub> is the radiative heat flux, <!--l. 22--><mml:math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="inline" ><mml:mrow 
><mml:msub><mml:mrow 
><mml:mi>k</mml:mi></mml:mrow><mml:mrow 
><mml:msub><mml:mrow 
><mml:mi>&#x03BB;</mml:mi></mml:mrow><mml:mrow 
><mml:mn>1</mml:mn></mml:mrow></mml:msub 
><mml:mi>w</mml:mi></mml:mrow></mml:msub 
></mml:mrow></mml:math>
is the radiation absorption coefficient at the wall and
<!--l. 22--><mml:math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="inline" ><mml:mrow 
><mml:msub><mml:mrow 
><mml:mi>e</mml:mi></mml:mrow><mml:mrow 
><mml:mi>b</mml:mi><mml:msub><mml:mrow 
><mml:mi>&#x03BB;</mml:mi></mml:mrow><mml:mrow 
><mml:mn>1</mml:mn></mml:mrow></mml:msub 
></mml:mrow></mml:msub 
></mml:mrow></mml:math> is
Plank&#8217;s constant.
   </p>

My required output:

<p>Using the relation in [14], radiative heat flux <italic>q</italic><sub><italic>r</italic></sub> gas near equilibrium is given by</p>
<p><disp-formula>
<label>(7)</label>
<alternatives>
<inline-graphic xlink:href="graphic/j_zna-2014-0260_fx_007.jpg"/>
<mml:math display='block'><mml:mrow><mml:mfrac><mml:mrow><mml:mo>&#x2202;</mml:mo><mml:msub><mml:mi>q</mml:mi><mml:mi>r</mml:mi></mml:msub></mml:mrow><mml:mrow><mml:mo>&#x2202;</mml:mo><mml:msup><mml:mi>y</mml:mi><mml:mo>*</mml:mo></mml:msup></mml:mrow></mml:mfrac><mml:mtext>&#x2009;</mml:mtext><mml:mo>=</mml:mo><mml:mtext>&#x2009;</mml:mtext><mml:mn>4</mml:mn><mml:mn>(</mml:mn><mml:msub><mml:mi>T</mml:mi><mml:mn>1</mml:mn></mml:msub><mml:mtext>&#x2009;</mml:mtext><mml:mo>&#x2212;</mml:mo><mml:mtext>&#x2009;</mml:mtext><mml:msup><mml:mi>T</mml:mi><mml:mo>*</mml:mo></mml:msup><mml:mn>)</mml:mn><mml:mo>&#x2009;</mml:mo><mml:msup><mml:mi>I</mml:mi><mml:mo>&#x2032;</mml:mo></mml:msup><mml:mo>,</mml:mo><mml:mo>&#x2009;</mml:mo><mml:mo>&#x2009;</mml:mo><mml:mo>&#x2009;</mml:mo><mml:msup><mml:mi>I</mml:mi><mml:mo>&#x2032;</mml:mo></mml:msup><mml:mtext>&#x2009;</mml:mtext><mml:mo>=</mml:mo><mml:mtext>&#x2009;</mml:mtext><mml:msup><mml:mstyle mathsize='140%' displaystyle='true'><mml:mo>&#x222B;</mml:mo></mml:mstyle><mml:mtext>&#x200B;</mml:mtext></mml:msup><mml:msub><mml:mi>k</mml:mi><mml:mrow><mml:msub><mml:mi>&#x03BB;</mml:mi><mml:mn>1</mml:mn></mml:msub><mml:mi>w</mml:mi><mml:mo>&#x2009;</mml:mo><mml:mo>&#x2009;</mml:mo></mml:mrow></mml:msub><mml:mfrac><mml:mrow><mml:mo>&#x2009;</mml:mo><mml:mo>&#x2009;</mml:mo><mml:mo>&#x2009;</mml:mo><mml:mo>&#x2009;</mml:mo><mml:mo>&#x2009;</mml:mo><mml:mo>&#x2202;</mml:mo><mml:msub><mml:mi>e</mml:mi><mml:mrow><mml:mi>b</mml:mi><mml:msub><mml:mi>&#x03BB;</mml:mi><mml:mrow><mml:mn>1</mml:mn><mml:mo>&#x2009;</mml:mo></mml:mrow></mml:msub></mml:mrow></mml:msub></mml:mrow><mml:mrow><mml:mo>&#x2202;</mml:mo><mml:mi>T</mml:mi></mml:mrow></mml:mfrac><mml:mo>&#x2009;</mml:mo><mml:mtext>d</mml:mtext><mml:msub><mml:mi>&#x03BB;</mml:mi><mml:mn>1</mml:mn></mml:msub><mml:mo>.</mml:mo></mml:mrow><mml:mtd><mml:mtext>&#x2003;(7)</mml:mtext></mml:mtd></mml:math>
<tex-math><![CDATA[$${{\partial {q_r}} \over {\partial {y^*}}}\; = \;4({T_1}\; - \;{T^*})I',I'\; = \;\mathop \smallint \nolimits^ {k_{{\lambda _1}w}}{{\partial {e_{b{\lambda _{1}}}}} \over {\partial T}}{\rm{d}}{\lambda _1}.\,\,\,\,(7)$$]]></tex-math></alternatives>
</disp-formula></p>
<p>Here, <italic>q</italic><sub><italic>r</italic></sub> is the radiative heat flux,<inline-formula>
<alternatives>
<inline-graphic xlink:href="graphic/j_zna-2014-0260_fx_008.jpg"/>
<mml:math display='block'><mml:mrow><mml:msub><mml:mi>k</mml:mi><mml:mrow><mml:msub><mml:mi>&#x03BB;</mml:mi><mml:mn>1</mml:mn></mml:msub><mml:mi>w</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:math>
<tex-math><![CDATA[${k_{{\lambda _1}w}}$]]></tex-math></alternatives>
</inline-formula>is the radiation absorption coefficient at the wall, and <inline-formula>
<alternatives>
<inline-graphic xlink:href="graphic/j_zna-2014-0260_fx_009.jpg"/>
<mml:math display='block'><mml:mrow><mml:msub><mml:mi>e</mml:mi><mml:mrow><mml:mi>b</mml:mi><mml:msub><mml:mi>&#x03BB;</mml:mi><mml:mn>1</mml:mn></mml:msub></mml:mrow></mml:msub></mml:mrow></mml:math>
<tex-math><![CDATA[${e_{b{\lambda _1}}}$]]></tex-math></alternatives>
</inline-formula> is Plank&#x2019;s constant.</p>

My sample1.cfg file is:

\Preamble{xhtml,mathml,NLM,-xtpipes,NoFonts,refcaption,DocBook}

\Configure{VERSION}
     {\HCode{<?xml version="1.0" encoding="UTF-8"?>\Hnewline<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD with OASIS Tables v1.0 20120330//EN" "JATS-journalpublishing-oasis-article1.dtd">\Hnewline}}

\Configure{DOCTYPE}{}

\Configure{HTML}{\HCode{<article article-type="research-article" xml:lang="en" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:mml="http://www.w3.org/1998/Math/MathML">\Hnewline}}
{\HCode{\Hnewline</article>}}

% remove html structure
\Configure{@HEAD}{}
\Configure{HEAD}{}{}
%\Configure{TITLE}{}{}{}

\Configure{mathml}{mml:}
\Configure{MathClass}{0}{*}{<mml:mi>}{</mml:mi>}{}
\Configure{MathClass}{1}{*}{<mml:mo mmlclass="MathClass-op">}{</mml:mo>}{}
\Configure{MathClass}{2}{*}{<mml:mo mmlclass="MathClass-bin">}{</mml:mo>}{}
\Configure{MathClass}{3}{*}{<mml:mo mmlclass="MathClass-rel">}{</mml:mo>}{}
\Configure{MathClass}{4}{*}{<mml:mrow><mml:mo mmlclass="MathClass-open">}
                           {</mml:mo><mml:mrow>}{}
   \Configure{MathClass}{5}{*}{</mml:mrow><mml:mo mmlclass="MathClass-close">}
                           {</mml:mo></mml:mrow>}{}
\Configure{MathClass}{6}{*}{<mml:mo mmlclass="MathClass-punc">}{</mml:mo>}{}
\Configure{MathClass}{7}{*}{<mml:mn>}{</mml:mn>}
                           {0123456789}     
% \Configure{MathClass}{2}{*}{<mml:mo>}{</mml:mo>}{}
% \Configure{MathClass}{3}{*}{<mml:mn>}{</mml:mn>}{}

%\ConfigureMark{section}{\thesection}

\def\gobbleone#1#2{}
\Configure{toTocLink}{\gobbleone}{}

%\setcounter{secnumdepth}{5}

\Configure{section}
   {\EndP\IgnorePar\Tg<sec id="j_\jobname_s_\thesection">}
   {\EndP\Tg</sec>}
   {\Tg<title>\TitleMark}
   {\Tg</title>}



\ConfigureMark{section}{\thesection\space}

\Configure{subsection}
   {\EndP\IgnorePar\Tg<sec id="j_\jobname_s_\thesubsection">}
   {\EndP\Tg</sec>}
   {\Tg<title>\TitleMark}
   {\Tg</title>\ShowPar}

\ConfigureMark{subsection}{\thesubsection\space}

\Configure{subsubsection}
   {\EndP\IgnorePar\Tg<sec id="j_\jobname_s_\thesubsubsection">}
   {\EndP\Tg</sec>}{\Tg<title>\TitleMark}   {\Tg</title>\ShowPar}

\ConfigureMark{subsubsection}{\thesubsubsection\space}
\Configure{paragraph}
   {\EndP\IgnorePar\Tg<sec id="j_\jobname_s_\theparagraph">}
   {\EndP\Tg</sec>}
   {\Tg<title>\TitleMark}
   {\Tg</title>\ShowPar}

\ConfigureMark{paragraph}{\theparagraph\space}

\Configure{subparagraph}
   {\EndP\IgnorePar\Tg<sec id="j_\jobname_s_\thesubparagraph">}
   {\EndP\Tg</sec>}
   {\Tg<title>\TitleMark}
   {\Tg</title>\ShowPar}


\ConfigureMark{subparagraph}{\thesubparagraph\space}
\Configure{textit}{\HCode{<italic>}\NoFonts}{\HCode{</italic>}\EndNoFonts}
\Configure{textbf}{\HCode{<bold>}\NoFonts}{\HCode{</bold>}\EndNoFonts}
\Css{.textsuperscript{font-size:.7rem;}}
\Css{.textsubscript{font-size:.7rem;}}
\Configure{HtmlPar}
{\EndP\HCode{<p>}}
{\EndP\HCode{<p>}}
{\HCode{</p>\Hnewline}} {\HCode{</p>\Hnewline}}

\ConfigureList{enumerate} 
{\EndP\HCode{<def-list>}\let\endItem=\empty} 
{\ifvmode \IgnorePar\fi \EndP\HCode{</def></def-list>}\ShowPar} 
{\endItem \def\endItem{\EndP\Tg</def>}\HCode{<def-item>}} 
{\HCode{</def-item><def>}} 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Figure Configuration
\ConfigureEnv{figure}
   {\ifvmode\IgnorePar\fi\EndP\HCode{<fig id="j_\jobname_fig_">}%
    \bgroup \Configure{float}{\ShowPar}{}{}%
    \renewcommand{\Link}[3][]{}%
    \renewcommand{\EndLink}{}%
   }
   {\egroup
    \ifvmode\IgnorePar\fi\EndP\HCode{</fig>}\ShowPar
\par}
{}{}

\ConfigureEnv{figure*}
   {\ifvmode\IgnorePar\fi\EndP\HCode{<fig id="J_\jobname_fig_">}%
    \bgroup \Configure{float}{\ShowPar}{}{}%
    \renewcommand{\Link}[3][]{}%
    \renewcommand{\EndLink}{}%
   }
   {\egroup
    \ifvmode\IgnorePar\fi\EndP\HCode{</fig>}\ShowPar
\par}
{}{}

\ConfigureEnv{sidewaysfigure}
   {\ifvmode\IgnorePar\fi\EndP\HCode{<fig id="J_\jobname_fig_">}%
    \bgroup \Configure{float}{\ShowPar}{}{}%
    \renewcommand{\Link}[3][]{}%
    \renewcommand{\EndLink}{}%
   }
   {\egroup
    \ifvmode\IgnorePar\fi\EndP\HCode{</fig>}\ShowPar
\par}
{}{}

\ConfigureEnv{sidewaysfigure*}
   {\ifvmode\IgnorePar\fi\EndP\HCode{<fig id="J_\jobname_fig_">}%
    \bgroup \Configure{float}{\ShowPar}{}{}%
    \renewcommand{\Link}[3][]{}%
    \renewcommand{\EndLink}{}%
   }
   {\egroup
    \ifvmode\IgnorePar\fi\EndP\HCode{</fig>}\ShowPar
\par}
{}{}

%Graphics Configuration
\Configure{graphics}
     {\bgroup
         \IgnorePar\Configure{IMG}
            {\HCode{<graphics xlink:href="}}
            {\HCode{"}}
            {}
            {}
            {}%
      \Picture+[]{}}
     {\EndPicture
       \HCode{/>}%
      \egroup} 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Caption Configuration 
\Configure{caption}{\HCode{<label>}} 
    {:} {\HCode{</label>\Hnewline<caption><p>}} 
    {\HCode{</p></caption>}} 

%\ConfigureEnv{tabular*} 
%      {\IgnorePar\EndP\Tg<table>} 
%     {\Tg</table>}{}{} 


%Table Configuration
\ConfigureEnv{table} 
    {\ifvmode \IgnorePar\fi \EndP \HCode{<table-wrap id="j_\jobname_tab_">}} 
    {\ifvmode \IgnorePar\fi \EndP \HCode{</table-wrap>}\par\ShowPar} 
    {}{}

\ConfigureEnv{table*} 
    {\ifvmode \IgnorePar\fi \EndP \HCode{<table-wrap id="j_\jobname_tab_">}} 
    {\ifvmode \IgnorePar\fi \EndP \HCode{</table-wrap>}\par\ShowPar} 
    {}{}

\ConfigureEnv{sidewaystable} 
    {\ifvmode \IgnorePar\fi \EndP \HCode{<table-wrap id="j_\jobname_tab_">}} 
    {\ifvmode \IgnorePar\fi \EndP \HCode{</table-wrap>}\par\ShowPar} 
    {}{}

\ConfigureEnv{sidewaystable*} 
    {\ifvmode \IgnorePar\fi \EndP \HCode{<table-wrap id="j_\jobname_tab_">}} 
    {\ifvmode \IgnorePar\fi \EndP \HCode{</table-wrap>}\par\ShowPar} 
    {}{}

%\Configure{Link}{xref}{id=}{}{}

%\newtoks\eqtoks 
%\def\AltMath#1${\eqtoks{$#1$}% 
%   \HCode{\the\eqtoks}$}
%\Configure{$}{}{}{\expandafter\AltMath}


\begin{document}
\EndPreamble

I am using the following compilation command htlatex filename.tex sample1

My current html output is equations, labels are captured table format below mentioned.

<table class="equation"><tr><td>
<a id="x1-2r1"></a>
<!--l. 19--> mathml coding here</td><td class="eq-no">(1)</td></tr></table>

How to change the table format to required output format? How to get the above mentioned three alternatives? Please advice.

CS Kumar
  • 1,253

0 Answers0