如何获取自定义 mathml 编码

如何获取自定义 mathml 编码

我正在使用tex4ht并尝试转换texhtml文档。

Mathml编码用于转换方程式。但我需要自定义 mathml 编码。我想将简单、复杂和显示数学方程式分开。

  1. 简单 $$ - $\upkappa$\textsuperscript{3} 如果将普通希腊字母和简单数学视为简单数学。(例如:一个上标或下标和普通希腊字母)。我的要求简单的数学应该转换为正常实体

  2. 复数 () - (\frac{1}{2}\sum^{3}_{2} + \Pi^3) 多个上标和下标分数以及任何其他特殊符号均视为复杂的数学方程式。我的要求是内联复杂数学应该转换为内联数学编码。

  3. 显示数学 -\begin{equation} \end{equation},align,aligned 应该被视为显示 mathml 编码。

  4. 重音符号未转换为正确的实体。例如:\c{c} - ç、\'{a} - á

  5. 所有的\textsuperscript{}and\textsubscript{}命令都应该转换为<sup> </sup> and <sub> </sub>。但是我无法得到这个。

梅威瑟:

\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}

我的CFG文件是:

\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

我的 html 输出是:

<?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> 

请指教如何获得定制的mathml转换。

答案1

您的要求2和3是输出tex4ht的默认选项mathml

对于第一个,您需要使用文本模式希腊字母,在数学开始时根本无法检测它是否仅包含单个希腊字母或一些复杂表达式。textgreek例如,您可以使用包:

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

它产生:

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

广告4)

使用make4ht命令以 utf8 编码获取输出:

make4ht -uc cfgifile.cfg filename 

广告5)

上标应该可以正确转换,但subscript中缺少对包的支持tex4ht。将此文件放入subscript.4ht包含您文档的目录中:

\NewConfigure{textsubscript}{2}

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

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

您还在文件中使用了一些不必要的配置.cfg,我会使用类似这样的配置:

\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

结果如下:

在此处输入图片描述

相关内容