使用 \begin{align} 进行 Make4HT(MathML 和 LaTeX 输出)

使用 \begin{align} 进行 Make4HT(MathML 和 LaTeX 输出)

当使用Make4ht如何获取MathMLLaTeX输出时\begin{align}。它被转换\begin{equation}参考Make4ht MathML 和 TeX

\documentclass[9pt]{elife}
\usepackage[utf8]{inputenc}
\usepackage[version=4]{mhchem}
\usepackage{siunitx}
\usepackage{hyperref}
\usepackage{amsmath,amssymb}
\usepackage{xspace}
\newcommand\eqannotate[1]{#1}

\title{Crowding-induced phase separation of nuclear transport receptors in FG nucleoporin assemblies}

\author[1]{Davis K. Luke}
\author[2]{Ford J. Ian}
\affil[1]{Department of Physics and Astronomy, University College London, London, United Kingdom}
\affil[2]{Institute for the Physics of Living Systems, University College London, London, United Kingdom}
\corr{[email protected]}{LKD}

\begin{document}

\maketitle

\begin{abstract}
The rapid ($< 1$~ms) transport of biological material to and from the cell nucleus is regulated by the nuclear pore complex (NPC). At the core of the NPC is a permeability barrier consisting of $\left( \frac{\rho^{(i)}(z)}{\rho^\textbf{Bulk}} \right)$ intrinsically disordered Phe-Gly (FG) nucleoporins (FG Nups).
\end{abstract}

\section{Introduction}

In previous work, we revealed {a universal physical behaviour in the experimentally observed binding of two well-characterized NTRs, 

\begin{align}
W^{(i)}(z) &= c^{(i)}(z) + V_{ext}^{(i)}(z) + \int \rho^{(3)}(z) u^{(i)}(z-z')\textrm{d}z' - \mu^{(i)} \nonumber, \\
& \approx - k_{\textrm{B}}T \ln \left( \frac{\rho^{(i)}(z)}{\rho^{(i)}_{\textrm{bulk}}} \right),
\end{align}

Was Further validated by a minimal physical model that treated the FG Nups as flexible homopolymers the NTRs as uniformly cohesive spheres.

\begin{align*}
    W^{(i)}(z) &= c^{(i)}(z) + V_{ext}^{(i)}(z) + \int \rho^{(3)}(z) u^{(i)}(z-z')\textrm{d}z' - \mu^{(i)} \nonumber, \\
    & \approx - k_{\textrm{B}}T \ln \left( \frac{\rho^{(i)}(z)}{\rho^{(i)}_{\textrm{bulk}}} \right),
    \end{align*}

\end{document}

elife LaTeX Template可在此处获取:https://github.com/zhoupc/eLife_submission/blob/master/elife.cls

答案1

首先,您的 TeX 示例包含一些编码错误,例如\textbf在数学模式中使用了。这是一个修复版本:

% https://tex.stackexchange.com/q/637885/2891
\documentclass[9pt]{elife}
\usepackage[utf8]{inputenc}
\usepackage[version=4]{mhchem}
\usepackage{siunitx}
\usepackage{hyperref}
\usepackage{amsmath,amssymb}
\usepackage{xspace}
\newcommand\eqannotate[1]{#1}

\title{Crowding-induced phase separation of nuclear transport receptors in FG nucleoporin assemblies}

\author[1]{Davis K. Luke}
\author[2]{Ford J. Ian}
\affil[1]{Department of Physics and Astronomy, University College London, London, United Kingdom}
\affil[2]{Institute for the Physics of Living Systems, University College London, London, United Kingdom}
\corr{[email protected]}{LKD}

\begin{document}

\maketitle

\begin{abstract}
The rapid ($ < 1$~ms) transport of biological material to and from the cell nucleus is regulated by the nuclear pore complex (NPC). At the core of the NPC is a permeability barrier consisting of $\left( \frac{\rho^{(i)}(z)}{\rho^{\mathbf{Bulk}}} \right)$ intrinsically disordered Phe-Gly (FG) nucleoporins (FG Nups).
\end{abstract}

\section{Introduction}

In previous work, we revealed {a universal physical behaviour in the experimentally observed binding of two well-characterized NTRs, 

\begin{align}
W^{(i)}(z) &= c^{(i)}(z) + V_{ext}^{(i)}(z) + \int \rho^{(3)}(z) u^{(i)}(z-z')\mathrm{d}z' - \mu^{(i)} \nonumber, \\
& \approx - k_{\mathrm{B}}T \ln \left( \frac{\rho^{(i)}(z)}{\rho^{(i)}_{\mathrm{bulk}}} \right),
\end{align}

Was Further validated by a minimal physical model that treated the FG Nups as flexible homopolymers the NTRs as uniformly cohesive spheres.

\begin{align*}
    W^{(i)}(z) &= c^{(i)}(z) + V_{ext}^{(i)}(z) + \int \rho^{(3)}(z) u^{(i)}(z-z')\mathrm{d}z' - \mu^{(i)} \nonumber, \\
    & \approx - k_{\mathrm{B}}T \ln \left( \frac{\rho^{(i)}(z)}{\rho^{(i)}_{\mathrm{bulk}}} \right),
    \end{align*}

\end{document}

修复这些错误后,以下配置文件即可正常工作。它重用了 MathJax TeX4ht 配置中的环境处理代码。它还使用正则表达式来清理<>字符,因为它们可能会导致 XML 解析错误。

\Preamble{xhtml,mathml}
\newtoks\eqtoks 

\ExplSyntaxOn
\cs_new_protected:Npn \alteqtoks #1
{
  \tl_set:Nx \l_tmpa_tl {\detokenize{#1}}
  % % replace < > and & with xml entities
  \regex_replace_all:nnN { \x{26} } { &amp; } \l_tmpa_tl
  \regex_replace_all:nnN { \x{3C} } { &lt; } \l_tmpa_tl
  \regex_replace_all:nnN { \x{3E} } { &gt; } \l_tmpa_tl
  % replace \par command with blank lines
  \regex_replace_all:nnN { \x{5C}par\b } {\x{A}\x{A}} \l_tmpa_tl
  \tl_set:Nx \eqtoks{ \l_tmpa_tl }
  
  %\HCode{\l_tmpb_tl}
}
\ExplSyntaxOff

\def\AltMath#1${\alteqtoks{#1}% 
   #1\HCode{</mrow><annotation encoding="application/x-tex">\eqtoks</annotation>}$} 
\Configure{$}{\Configure{@math}{display="inline"}\DviMath\HCode{<semantics><mrow>}}{\HCode{</semantics>}\EndDviMath}{\expandafter\AltMath} 

\long\def\AltDisplay#1\]{\alteqtoks{#1}#1\HCode{</mrow><annotation encoding="application/x-tex">\eqtoks</annotation></semantics>}\]}
\Configure{[]}{\Configure{@math}{display="block"}\DviMath$$\DisplayMathtrue\HCode{<semantics><mrow>}\AltDisplay}{$$\EndDviMath}

\renewcommand\eqannotate[1]{\alteqtoks{#1}\HCode{<semantics><mrow>}#1\HCode{</mrow><annotation encoding="application/x-tex">\eqtoks</annotation></semantics>}}


% environment support
\newcommand\VerbMathToks[2]{%
  \alteqtoks{\begin{#2}
    #1
  \end{#2}}%
  \ifvmode\IgnorePar\fi\EndP\Configure{@math}{display="block"}\DviMath\DisplayMathtrue\HCode{<semantics><mrow>}
  \begin{old#2}
    #1
  \end{old#2}
  \HCode{</mrow><annotation encoding="application/x-tex">}
  \HCode{\eqtoks}
  \HCode{</annotation></semantics>}
  \EndDviMath
}
\ExplSyntaxOn
\newcommand\VerbMath[1]{%
  \cs_if_exist:cTF{#1}{
    \expandafter\let\csname old#1\expandafter\endcsname\csname #1\endcsname
    \expandafter\let\csname endold#1\expandafter\endcsname\csname end#1\endcsname
    \RenewDocumentEnvironment{#1}{+!b}{%
      \NoFonts\expandafter\VerbMathToks\expandafter{##1}{#1}\EndNoFonts%
    }{}
  }{}%
}

\ExplSyntaxOff
\begin{document}
\VerbMath{subarray}
\VerbMath{smallmatrix}
\VerbMath{matrix}
\VerbMath{pmatrix}
\VerbMath{bmatrix}
\VerbMath{Bmatrix}
\VerbMath{vmatrix}
\VerbMath{Vmatrix}
\VerbMath{cases}
\VerbMath{subequations}
\VerbMath{aligned}
\VerbMath{alignedat}
\VerbMath{gathered}
\VerbMath{gather}
\VerbMath{gather*}
\VerbMath{alignat}
\VerbMath{alignat*}
\VerbMath{xalignat}
\VerbMath{xalignat*}
\VerbMath{xxalignat}
\VerbMath{align}
\VerbMath{align*}
\VerbMath{flalign}
\VerbMath{flalign*}
\VerbMath{split}
\VerbMath{multline}
\VerbMath{multline*}
\VerbMath{equation}
\VerbMath{equation*}
\VerbMath{math}
\VerbMath{displaymath}
\VerbMath{eqnarray}
\VerbMath{eqnarray*}
\EndPreamble

结果如下:

在此处输入图片描述

适合您环境的代码align*

<!-- l. 41 --><math display='block' xmlns='http://www.w3.org/1998/Math/MathML'><mrow><semantics><mrow>
<!-- tex4ht:inline --><mrow><mtable class='align-star' columnalign='left'>                           
<mtr><mtd class='align-odd' columnalign='right'><msup><mrow><mi>W</mi></mrow><mrow><mo class='MathClass-open' stretchy='false'>(</mo><mi>i</mi><mo class='MathClass-close' stretchy='false'>)</mo></mrow></msup><mo class='MathClass-open' stretchy='false'>(</mo><mi>z</mi><mo class='MathClass-close' stretchy='false'>)</mo></mtd>                           
<mtd class='align-even'> <mo class='MathClass-rel'>=</mo> <msup><mrow><mi>c</mi></mrow><mrow><mo class='MathClass-open' stretchy='false'>(</mo><mi>i</mi><mo class='MathClass-close' stretchy='false'>)</mo></mrow></msup><mo class='MathClass-open' stretchy='false'>(</mo><mi>z</mi><mo class='MathClass-close' stretchy='false'>)</mo> <mo class='MathClass-bin'>+</mo> <msubsup><mrow><mi>V</mi> </mrow><mrow>
<mi mathvariant='italic'>ext</mi></mrow><mrow><mo class='MathClass-open' stretchy='false'>(</mo><mi>i</mi><mo class='MathClass-close' stretchy='false'>)</mo></mrow></msubsup><mo class='MathClass-open' stretchy='false'>(</mo><mi>z</mi><mo class='MathClass-close' stretchy='false'>)</mo> <mo class='MathClass-bin'>+</mo><mo> ∫
 <!-- nolimits --></mo><!-- nolimits --><msup><mrow><mi>ρ</mi></mrow><mrow><mo class='MathClass-open' stretchy='false'>(</mo><mn>3</mn><mo class='MathClass-close' stretchy='false'>)</mo></mrow></msup><mo class='MathClass-open' stretchy='false'>(</mo><mi>z</mi><mo class='MathClass-close' stretchy='false'>)</mo><msup><mrow><mi>u</mi></mrow><mrow><mo class='MathClass-open' stretchy='false'>(</mo><mi>i</mi><mo class='MathClass-close' stretchy='false'>)</mo></mrow></msup><mo class='MathClass-open' stretchy='false'>(</mo><mi>z</mi> <mo class='MathClass-bin'>−</mo> <msup><mrow><mi>z</mi></mrow><mrow><mi>′</mi></mrow></msup><mo class='MathClass-close' stretchy='false'>)</mo><mstyle mathvariant='normal'><mi>d</mi></mstyle><msup><mrow><mi>z</mi></mrow><mrow><mi>′</mi></mrow></msup><mo class='MathClass-bin'>−</mo> <msup><mrow><mi>μ</mi></mrow><mrow><mo class='MathClass-open' stretchy='false'>(</mo><mi>i</mi><mo class='MathClass-close' stretchy='false'>)</mo></mrow></msup><mo class='MathClass-punc'>,</mo><mspace width='2em'></mspace></mtd>                       
<mtd class='align-label' columnalign='right'></mtd>                       
<mtd class='align-label'> 
<mspace width='2em'></mspace></mtd></mtr><mtr><mtd class='align-odd' columnalign='right'></mtd>                               
<mtd class='align-even'> <mo class='MathClass-rel'>≈</mo><mo class='MathClass-bin'>−</mo><msub><mrow><mi>k</mi></mrow><mrow><mstyle mathvariant='normal'><mi>B</mi></mstyle></mrow></msub><mi>T</mi><mi class='qopname'> ln</mi><mo> ⁡<!-- FUNCTION APPLICATION --> </mo><!-- nolimits --> <mrow><mo fence='true' form='prefix'> (</mo><mrow> <mfrac><mrow><msup><mrow><mi>ρ</mi></mrow><mrow><mo class='MathClass-open' stretchy='false'>(</mo><mi>i</mi><mo class='MathClass-close' stretchy='false'>)</mo></mrow></msup><mo class='MathClass-open' stretchy='false'>(</mo><mi>z</mi><mo class='MathClass-close' stretchy='false'>)</mo></mrow>
<mrow><msubsup><mrow><mi>ρ</mi></mrow><mrow>
<mstyle mathvariant='normal'><mi>bulk</mi></mstyle></mrow><mrow><mo class='MathClass-open' stretchy='false'>(</mo><mi>i</mi><mo class='MathClass-close' stretchy='false'>)</mo></mrow></msubsup></mrow></mfrac> </mrow><mo fence='true' form='postfix'>)</mo></mrow> <mo class='MathClass-punc'>,</mo><mspace width='2em'></mspace></mtd>                                                            
<mtd class='align-label' columnalign='right'></mtd>                       
<mtd class='align-label'><mspace width='2em'></mspace></mtd></mtr></mtable></mrow>
</mrow><annotation encoding='application/x-tex'> \begin {align*}  W^{(i)}(z) &amp;= c^{(i)}(z) + V_{ext}^{(i)}(z) + \int \rho ^{(3)}(z) u^{(i)}(z-z')\mathrm {d}z' - \mu ^{(i)} \nonumber , \\ &amp; \approx - k_{\mathrm {B}}T \ln \left ( \frac {\rho ^{(i)}(z)}{\rho ^{(i)}_{\mathrm {bulk}}} \right ),  \end {align*} </annotation></semantics> </mrow></math>
                                                                         

相关内容