2

I am using the tex4ht and try to convert tex to html document.

Mathml coding is used to convert the equations. But i need to customize the mathml coding. I would like to separate the simple, complex and display math equations.

  1. Simple $$ - $\upkappa$\textsuperscript{3} if the normal greek letters and simple mathematics consider as a simple math. (For eg: One superscript or subscript and normal greek letters). My Requirement Simple math should be converted as normal entity.

  2. Complex () - (\frac{1}{2}\sum^{3}_{2} + \Pi^3) More than one superscript and subscripts fractions any other special symbols consider as a complex math equations. My requirement Inline complex math should be converted as inline mathml coding.

  3. Display Math - \begin{equation} \end{equation},align,aligned should be consider as a display mathml coding.

  4. Accents is not converted the proper entity. For ex: \c{c} - ç, \'{a} - á

  5. All the \textsuperscript{} and \textsubscript{} command should be converted as <sup> </sup> and <sub> </sub>. But I can't get this one.

MWE:

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage{fixltx2e}
\usepackage{textcomp}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{upgreek}
\usepackage{subscript}

\begin{document}

\title{Crystal structure of chlorido-(2-ethoxy-6-(((quinolin-8-yl)methyl)-phenolato-$\upkappa$\textsuperscript{3}\textit{N},\textit{N}${\prime}$,\textit{O})-copper(II), C\textsubscript{18}H\textsubscript{15}ClCuN\textsubscript{2}O\textsubscript{2}} 
\author{Shengli Li}
\maketitle

\begin{abstract}
C\textsubscript{18}H\textsubscript{15}ClCuN\textsubscript{2}O\textsubscript{2}, monoclinic, P2\textsubscript{1}/\textit{c} (no. 14), \textit{a}\,$=$\,8.949(2)~{\AA}, \textit{b}\,$=$\,22.198(5)~{\AA}, \textit{c}\,$=$\,8.279(2)~{\AA}, $\beta$\,$=$\,106.646(3){\textdegree}, \textit{V}\,$=$\,1575.6~{\AA}\textsuperscript{3}, \textit{Z}\,$=$\,4, \textit{R}\textsubscript{gt}\textit{(F)}\,$=$\,0.0293, \textit{wR}\textsubscript{ref}\textit{(F}\textsuperscript{2}\textit{)}\,$=$\,0.0778, \textit{T}\,$=$\,293~K.
\end{abstract} 

The \textit{s\c{c}hiff} b\'{a}se ligand $\upalpha$\textsuperscript{3} (2-ethoxy-6-(((quinolin-8-yl)methyl)-phenolato $\alpha$\textsuperscript{3} \textit{L} was synthesized according \(\frac{1}{2}\sum^{3}_{2} + \Pi^3\) to the literature method [1]. The synthesis of the title complex was carried out by reacting CuCl\textsubscript{2}$\cdot$2H\textsubscript{2}O and the schiff base ligand (molar ratio of 1:1) in methanol under the stirring condition at room temperature. The filtrated solution was left to slowly evaporate in air to obtain single crystal suitable for X-ray diffraction with the yield about 60\%.
\begin{equation}
\frac{\partial C^{*}}{\partial t^{*}} =D\frac{\partial ^{2} C^{*} }{\partial y{^{*}}^{2}} -k_{R} \left(C^{*} -C_{1} \right).  
\end{equation}


\end{document}

My CFG file is:

\Preamble{xhtml,mathml,NLM}
\Configure{section}{\HCode{<span>\Hnewline}}{\HCode{</span>\Hnewline}}
{\HCode{<sect>\Hnewline}}    {\HCode{</sect>\Hnewline}} 
\Configure{textit}{\HCode{<italic>}\NoFonts}{\HCode{</italic>}\EndNoFonts}
\Configure{textbf}{\HCode{<bold>}\NoFonts}{\HCode{</bold>}\EndNoFonts}
   \newtoks\eqtoks
    \def\AltlMath#1\){\eqtoks{\(#1\)}% 
        \HCode{\the\eqtoks}}
    \Configure{()}{\AltlMath}{}
    \def\AltlDisplay#1\]{\eqtoks{\[#1\]}%
        \HCode{\the\eqtoks}}
    \Configure{[]}{\AltlDisplay}{}
\begin{document}
\EndPreamble

My html output is:

<?xml version="1.0" encoding="iso-8859-1" ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN" 
"http://www.w3.org/Math/DTD/mathml2/xhtml-math11-f.dtd" > 
<html xmlns="http://www.w3.org/1999/xhtml"  
> 
<head> <title>Crystal structure of chlorido-(2-ethoxy-6-(((quinolin-8-yl)methyl)-phenolato-&#x03BA;3N,N&#x2032;,O)-copper(II),
C18H15ClCuN2O2</title> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
<meta name="generator" content="TeX4ht (http://www.tug.org/tex4ht/)" /> 
<meta name="originator" content="TeX4ht (http://www.tug.org/tex4ht/)" /> 
<!-- html,xhtml,mathml,NLM --> 
<meta name="src" content="Math.tex" /> 
<meta name="date" content="2015-09-22 12:35:00" /> 
<link rel="stylesheet" type="text/css" href="Math.css" /> 
</head><body 
>
   <div class="maketitle">



<h2 class="titleHead">Crystal structure of
chlorido-(2-ethoxy-6-(((quinolin-8-yl)methyl)-phenolato-<!--l. 16--><math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="inline" ><mi 
>&#x03BA;</mi></math><sup class="textsuperscript">3</sup><italic>N</italic>,<italic>N</italic><!--l. 16--><math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="inline" ><mi 
>&#x2032;</mi></math>,<italic>O</italic>)-copper(II),
C<!--l. 16--><math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="inline" ><mstyle 
class="mbox"><mtext  >18</mtext></mstyle></math>H<!--l. 16--><math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="inline" ><mstyle 
class="mbox"><mtext  >15</mtext></mstyle></math>ClCuN<!--l. 16--><math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="inline" ><mstyle 
class="mbox"><mtext  >2</mtext></mstyle></math>O<!--l. 16--><math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="inline" ><mstyle 
class="mbox"><mtext  >2</mtext></mstyle></math></h2>
<div class="author" ><span 
class="cmr-12">Shengli Li</span></div><br />
<div class="date" ><span 
class="cmr-12">September 22, 2015</span></div>
   </div>
   <div 
class="abstract" 
>
<div class="center" 
>
<!--l. 18--><p class="noindent" >
</p><!--l. 18--><p class="noindent" ><span 
class="cmbx-9">Abstract</span></p></div>
     <!--l. 19--><p class="indent" >    <span 
class="cmr-9">C</span><!--l. 19--><math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="inline" ><mstyle 
class="mbox"><mtext  >18</mtext></mstyle></math><span 
class="cmr-9">H</span><!--l. 19--><math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="inline" ><mstyle 
class="mbox"><mtext  >15</mtext></mstyle></math><span 
class="cmr-9">ClCuN</span><!--l. 19--><math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="inline" ><mstyle 
class="mbox"><mtext  >2</mtext></mstyle></math><span 
class="cmr-9">O</span><!--l. 19--><math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="inline" ><mstyle 
class="mbox"><mtext  >2</mtext></mstyle></math><span 
class="cmr-9">,</span>
     <span 
class="cmr-9">monoclinic, P2</span><!--l. 19--><math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="inline" ><mstyle 
class="mbox"><mtext  >1</mtext></mstyle></math><span 
class="cmr-9">/</span><italic>c</italic>
     <span 
class="cmr-9">(no. 14), </span><italic>a</italic><!--l. 19--><math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="inline" > <mo 
class="MathClass-rel">=</mo></math> <span 
class="cmr-9">8.949(2)</span><span 
class="cmr-9">&#x00A0;</span><span 
class="cmr-9">Å</span><span 
class="cmr-9">,</span>
     <italic>b</italic><!--l. 19--><math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="inline" > <mo 
class="MathClass-rel">=</mo></math> <span 
class="cmr-9">22.198(5)</span><span 
class="cmr-9">&#x00A0;</span><span 
class="cmr-9">Å</span><span 
class="cmr-9">,</span>
     <italic>c</italic><!--l. 19--><math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="inline" > <mo 
class="MathClass-rel">=</mo></math> <span 
class="cmr-9">8.279(2)</span><span 
class="cmr-9">&#x00A0;</span><span 
class="cmr-9">Å</span><span 
class="cmr-9">,</span>
     <!--l. 19--><math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="inline" ><mi 
>&#x03B2;</mi></math><!--l. 19--><math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="inline" > <mo 
class="MathClass-rel">=</mo></math> <span 
class="cmr-9">106.646(3)</span><span 
class="tcrm-0900">°</span><span 
class="cmr-9">,</span>
     <italic>V </italic><!--l. 19--><math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="inline" > <mo 
class="MathClass-rel">=</mo></math> <span 
class="cmr-9">1575.6</span><span 
class="cmr-9">&#x00A0;</span><span 
class="cmr-9">Å</span><sup class="textsuperscript"><span 
class="cmr-9">3</span></sup><span 
class="cmr-9">,</span>
     <italic>Z</italic><!--l. 19--><math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="inline" > <mo 
class="MathClass-rel">=</mo></math> <span 
class="cmr-9">4,</span>
     <italic>R</italic><!--l. 19--><math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="inline" ><mstyle 
class="mbox"><mtext  >gt</mtext></mstyle></math><italic>(F)</italic><!--l. 19--><math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="inline" > <mo 
class="MathClass-rel">=</mo></math> <span 
class="cmr-9">0.0293,</span>
     <italic>wR</italic><!--l. 19--><math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="inline" ><mstyle 
class="mbox"><mtext  >ref</mtext></mstyle></math><italic>(F</italic><sup class="textsuperscript"><span 
class="cmr-9">2</span></sup><italic>)</italic><!--l. 19--><math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="inline" > <mo 
class="MathClass-rel">=</mo></math> <span 
class="cmr-9">0.0778,</span>
     <italic>T</italic><!--l. 19--><math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="inline" > <mo 
class="MathClass-rel">=</mo></math> <span 
class="cmr-9">293</span><span 
class="cmr-9">&#x00A0;K.</span>
</p>
</div>
<!--l. 22--><p class="indent" >   The <italic>sçhiff </italic> báse ligand <!--l. 22--><math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="inline" ><mi 
>&#x03B1;</mi></math><sup class="textsuperscript"><span 
class="cmr-9">3</span></sup>
(2-ethoxy-6-(((quinolin-8-yl)methyl)-phenolato
<!--l. 22--><math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="inline" ><mi 
>&#x03B1;</mi></math><sup class="textsuperscript"><span 
class="cmr-9">3</span></sup> <italic>L</italic>
was synthesized according \(\sum ^{3}_{2} + \Pi ^3\) to the literature method [1]. The synthesis of the
title complex was carried out by reacting CuCl<mstyle 
class="mbox"><mtext  ><span 
class="cmr-7">2</span></mtext></mstyle><span 
class="cmsy-10">&#x22C5;</span>2H<mstyle 
class="mbox"><mtext  ><span 
class="cmr-7">2</span></mtext></mstyle>O and the schiff base
ligand (molar ratio of 1:1) in methanol under the stirring condition at room

temperature. The filtrated solution was left to slowly evaporate in air to
obtain single crystal suitable for X-ray diffraction with the yield about 60%. </p><table class="equation"><tr><td>
<a 
 id="x1-2r1"></a>
<!--l. 23--><math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="block" class="equation">
                    <mfrac><mrow 
><mi 
>&#x2202;</mi><msup><mrow 
><mi 
>C</mi></mrow><mrow 
><mo 
class="MathClass-bin">*</mo></mrow></msup 
></mrow>
<mrow 
><mi 
>&#x2202;</mi><msup><mrow 
><mi 
>t</mi></mrow><mrow 
><mo 
class="MathClass-bin">*</mo></mrow></msup 
></mrow></mfrac> <mo 
class="MathClass-rel">=</mo> <mi 
>D</mi><mfrac><mrow 
><msup><mrow 
><mi 
>&#x2202;</mi></mrow><mrow 
><mn>2</mn></mrow></msup 
><msup><mrow 
><mi 
>C</mi></mrow><mrow 
><mo 
class="MathClass-bin">*</mo></mrow></msup 
></mrow>
<mrow 
><mi 
>&#x2202;</mi><msup><mrow 
><mi 
>y</mi><msup><mrow 
></mrow><mrow 
><mo 
class="MathClass-bin">*</mo></mrow></msup 
></mrow><mrow 
><mn>2</mn></mrow></msup 
></mrow></mfrac>  <mo 
class="MathClass-bin">-</mo> <msub><mrow 
><mi 
>k</mi></mrow><mrow 
><mi 
>R</mi></mrow></msub 
> <mfenced separators="" 
open="("  close=")" ><mrow><msup><mrow 
><mi 
>C</mi></mrow><mrow 
><mo 
class="MathClass-bin">*</mo></mrow></msup 
><mo 
class="MathClass-bin">-</mo> <msub><mrow 
><mi 
>C</mi></mrow><mrow 
>
<mn>1</mn></mrow></msub 
></mrow></mfenced> <mo 
class="MathClass-punc">.</mo>
</math></td><td class="eq-no">(1)</td></tr></table>

</body></html> 

Kindly advice how to get the customized mathml conversions.

1

Your requirements 2 and 3 are default tex4ht options for mathml output.

For the first one, you need to use text mode greek letters, it is simply not possible to detect at the moment math starts whether it contains only single Greek letter or some complex expression. You can use textgreek package for example:

\usepackage{textgreek}
...
\textalpha\textsuperscript{3}

it produces:

<span 
class="grmn-1000">α</span><sup class="textsuperscript"><span 
class="cmr-9">3</span></sup>

ad 4)

use make4ht command to get the output in utf8 encoding:

make4ht -uc cfgifile.cfg filename 

ad 5)

superscripts should be converted correctly, but support for subscript package is missing in tex4ht. Put this file, subscript.4ht to the directory with your document:

\NewConfigure{textsubscript}{2}

\renewcommand\textsubscript[1]{%
  \a:textsubscript #1\b:textsubscript%
}

\Configure{textsubscript}{\HCode{<sub class="textsubscript">}}{\HCode{</sub>}}

You also use some unnecessary configurations in your .cfg file, I would use something like:

\Preamble{xhtml,mathml,NLM}
% do you use some custom xml tags?
\Configure{section}{\HCode{<span>\Hnewline}}{\HCode{</span>\Hnewline}}
{\HCode{<sect>\Hnewline}}    {\HCode{</sect>\Hnewline}} 
\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;}}
\begin{document}
\EndPreamble

This is the result:

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.