Make4HT – HTML with LaTeX equation and MathML output

htlatexmake4httex4ht

I am trying to convert the HTML output with MathML and TeX equations based on the brilliant Solution given by michal.h21 in the below Thread

  1. Make4HT with \begin{align} (MathML and LaTeX Output)
  2. mathml configuration

I have a problem when converting HTML

  1. when using \begin{equation}/begin{equation*} showing error

! Missing } inserted.
    
                    }
    l.26 \end
             {equation*}

  1. for Double $$ used equation, TeX equation part not converted in the HTML output

  2. Need to re-configure for the Equation Number (label) as
    <eqno id="x1-3r2">(1)</eqno> of the all display Numbered Equation/environment
    (this is for cleanup purpose to move the equation Label to outside of the MathML and restructure the XML tag)

    <display-math><label>..<label><mathML>...</mathML><tex-math>...</tex-math>

Here is my MWE:

I am running a file through make4htmake4ht -l -a debug -c myconfig.cfg Sample.tex

\documentclass[9pt]{book}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\usepackage{amsmath,amssymb}
\usepackage{xspace}
\newcommand\eqannotate[1]{#1}

\begin{document}
Display equation with doble dollar
$$
a+b=c
$$
Display equation (equation env)
\begin{equation}
x+y=1
\end{equation}

Display equation (equation env)
\begin{equation*}
x+y=z
\end{equation*}

eqnarray environment
\begin{eqnarray}
x+y=1
\end{eqnarray}

display equation
\[
d+f=g
\]

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}

MY CFG

\Configure{ext}{xhtml}
\Preamble{xhtml,mathml,NLM,charset=UTF-8,-xtpipes,NoFonts,refcaption,ext=.xhtml}

\Configure{HtmlPar}{\EndP\HCode{<p class="noindent">}}
                   {\EndP\HCode{<p class="\ifdim\parindent=0pt no\fi indent">}}
                   {\HCode{</p>}}
                   {\HCode{</p>}}


\Configure{HTML}{\HCode{<html xmlns="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML">}}
                {\HCode{</html>}}

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

\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{aligned}
\VerbMath{alignedat}
\VerbMath{gather}
\VerbMath{gather*}
\VerbMath{alignat}
\VerbMath{alignat*}
\VerbMath{xalignat}
\VerbMath{xalignat*}
\VerbMath{xxalignat}
\VerbMath{align}
\VerbMath{align*}
\VerbMath{flalign}
\VerbMath{flalign*}
\VerbMath{multline}
\VerbMath{multline*}
\VerbMath{equation}
\VerbMath{equation*}
\VerbMath{math}
\VerbMath{displaymath}
\VerbMath{eqnarray}
\VerbMath{eqnarray*}
\EndPreamble

Best Answer

I would base the code on the newer answer. The second seems obsolete. It just needs a fix for equations, they cause the compilation error. Other than that, it mostly works. Except for $$ ... $$ math, I cannot find a correct solution.

Here is the updated config file:

\Preamble{xhtml,mathml,mathjax}
\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}}%
  \begingroup%
  \ifvmode\IgnorePar\fi\EndP\Configure{@math}{display="block"}\DviMath\DisplayMathtrue\HCode{<semantics><mrow>}
  \Configure{$$}{}{}{}
  \begin{old#2}
    #1
  \end{old#2}
  \HCode{</mrow><annotation encoding="application/x-tex">}
  \HCode{\eqtoks}
  \HCode{</annotation></semantics>}
  \EndDviMath
  \endgroup
}

\makeatletter
% we must handle equations separatelly. 
% it is a bit messy
\newcommand\VerbMathToksEquation[2]{%
  \alteqtoks{\begin{#2}
    #1
  \end{#2}}%
  \begingroup%
  \def\@tempa{#2}%
  \def\@equationname{equation}%
  \def\mlabeledtr{mtr}
  \ifx\@equationname\@tempa%
  \def\mlabeledtr{mlabeledtr} % this element can be used to print the equation number, but it is supported only by MathJax
  \fi
  \ifvmode\IgnorePar\fi\EndP\Configure{@math}{display="block"}\DviMath\DisplayMathtrue\HCode{<semantics><mrow><mtable><\mlabeledtr><mtd>}%
  \ifx\@equationname\@tempa%
  \incr@eqnum%
  \print@eqnum%
  \HCode{</mtd><mtd>}%
  \fi
    #1%
  \HCode{</mtd></\mlabeledtr></mtable></mrow><annotation encoding="application/x-tex">}%
  \HCode{\eqtoks}%
  \HCode{</annotation></semantics>}%
  \EndDviMath%
  \endgroup%
}
\makeatother

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

\newcommand\VerbEquation[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\VerbMathToksEquation\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*}
\VerbEquation{equation}
\VerbEquation{equation*}
\VerbMath{math}
\VerbMath{displaymath}
\VerbMath{eqnarray}
\VerbMath{eqnarray*}
\EndPreamble

This is the result:

enter image description here

<!DOCTYPE html> 
<html lang='en-US' xml:lang='en-US'> 
<head>                      <title></title> 
<meta charset='utf-8' /> 
<meta content='TeX4ht (https://tug.org/tex4ht/)' name='generator' /> 
<meta content='width=device-width,initial-scale=1' name='viewport' /> 
<link href='sample.css' rel='stylesheet' type='text/css' /> 
<meta content='sample.tex' name='src' /> 
 <script async='async' id='MathJax-script' src='https://cdn.jsdelivr.net/npm/mathjax@3/es5/mml-chtml.js' type='text/javascript'></script>  
</head><body>
<!-- l. 10 --><p class='noindent'>Inline math <!-- l. 10 --><math display='inline' xmlns='http://www.w3.org/1998/Math/MathML'><semantics><mrow><mi>a</mi> <mo class='MathClass-bin' stretchy='false'>+</mo> <mi>b</mi> <mo class='MathClass-rel' stretchy='false'>=</mo> <mi>c</mi></mrow><annotation encoding='application/x-tex'>a+b=c</annotation></semantics></math>
</p><!-- l. 12 --><p class='indent'>   Display equation with doble dollar
<!-- tex4ht:inline --></p><!-- l. 13 --><math display='block' xmlns='http://www.w3.org/1998/Math/MathML'><mrow>
                             <mi>a</mi> <mo class='MathClass-bin' stretchy='false'>+</mo> <mi>b</mi> <mo class='MathClass-rel' stretchy='false'>=</mo> <mi>c</mi>
</mrow></math>
<!-- l. 15 --><p class='nopar'>
</p><!-- l. 18 --><p class='indent'>   <!-- l. 18 --><math display='block' xmlns='http://www.w3.org/1998/Math/MathML'><mrow>
                                       <semantics><mrow><mi>a</mi> <mo class='MathClass-bin' stretchy='false'>+</mo> <mi>b</mi> <mo class='MathClass-rel' stretchy='false'>=</mo> <mi>c</mi></mrow><annotation encoding='application/x-tex'> a+b=c </annotation></semantics>
</mrow></math>
</p><!-- l. 22 --><p class='indent'>   Display equation (equation env)  </p><!-- l. 25 --><math display='block' xmlns='http://www.w3.org/1998/Math/MathML'><semantics><mrow><mtable><mlabeledtr><mtd><mstyle class='label' id='x1-2r1'></mstyle><!-- endlabel --><mstyle class='maketag'><mtext>(1)</mtext></mstyle><mspace class='nbsp' width='0.33em'></mspace></mtd><mtd> <mi>x</mi><mo class='MathClass-bin' stretchy='false'>+</mo><mi>y</mi><mo class='MathClass-rel' stretchy='false'>=</mo><mn>1</mn> </mtd></mlabeledtr></mtable></mrow><annotation encoding='application/x-tex'>\begin {equation}  x+y=1  \end {equation}</annotation></semantics></math>
<!-- l. 27 --><p class='indent'>   Display equation (equation* env)  </p><!-- l. 30 --><math display='block' xmlns='http://www.w3.org/1998/Math/MathML'><semantics><mrow><mtable><mtr><mtd> <mi>x</mi><mo class='MathClass-bin' stretchy='false'>+</mo><mi>y</mi><mo class='MathClass-rel' stretchy='false'>=</mo><mi>z</mi> </mtd></mtr></mtable></mrow><annotation encoding='application/x-tex'>\begin {equation*}  x+y=z  \end {equation*}</annotation></semantics></math>
                                                                  

                                                                  
<!-- l. 32 --><p class='indent'>   eqnarray environment </p><!-- l. 35 --><math display='block' xmlns='http://www.w3.org/1998/Math/MathML'><mrow><semantics><mrow>
<mtable class='eqnarray' columnalign='right center left' displaystyle='true'>
<mtr><mtd class='eqnarray-1'> <mi>x</mi> <mo class='MathClass-bin' stretchy='false'>+</mo> <mi>y</mi> <mo class='MathClass-rel' stretchy='false'>=</mo> <mn>1</mn></mtd><mtd class='eqnarray-2'>    </mtd><mtd class='eqnarray-3'>    </mtd><mtd class='eqnarray-4'> <mtext class='eqnarray'>(2)</mtext><mtext class='label' id='x1-3r'></mtext><mtext class='endlabel'></mtext></mtd>                                                                                 </mtr></mtable>
</mrow><annotation encoding='application/x-tex'> \begin {eqnarray}  x+y=1  \end {eqnarray} </annotation></semantics> </mrow></math>
<!-- l. 37 --><p class='indent'>   display equation <!-- l. 38 --><math display='block' xmlns='http://www.w3.org/1998/Math/MathML'><mrow>
                                             <semantics><mrow><mi>d</mi> <mo class='MathClass-bin' stretchy='false'>+</mo> <mi>f</mi> <mo class='MathClass-rel' stretchy='false'>=</mo> <mi>g</mi></mrow><annotation encoding='application/x-tex'> d+f=g </annotation></semantics>
</mrow></math>
</p><!-- l. 42 --><p class='indent'>   we revealed a universal physical behaviour in the
experimentally observed binding of two well-characterized NTRs,
                                                                  

                                                                  
</p><!-- l. 46 --><math display='block' xmlns='http://www.w3.org/1998/Math/MathML'><mrow><semantics><mrow>
<!-- tex4ht:inline --><mrow><mtable class='align' columnalign='left' displaystyle='true'>
        <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' stretchy='false'>=</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' stretchy='false'>+</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' stretchy='false'>+</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' stretchy='false'>−</mo> <msup><mrow><mi>z</mi></mrow><mrow><mi>′</mi></mrow></msup><mo class='MathClass-close' stretchy='false'>)</mo><mstyle class='text'><mtext class='textrm' mathvariant='normal'>d</mtext></mstyle><msup><mrow><mi>z</mi></mrow><mrow><mi>′</mi></mrow></msup><mo class='MathClass-bin' stretchy='false'>−</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' stretchy='false'>,</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' stretchy='false'>≈</mo><mo class='MathClass-bin' stretchy='false'>−</mo><msub><mrow><mi>k</mi></mrow><mrow><mstyle class='text'><mtext class='textrm' mathvariant='normal'>B</mtext></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 class='text'><mtext class='textrm' mathvariant='normal'>bulk</mtext></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' stretchy='false'>,</mo><mspace width='2em'></mspace></mtd>                                           <mtd class='align-label' columnalign='right'><mstyle class='label' id='x1-4r3'></mstyle><!-- endlabel --><mstyle class='maketag'><mtext>(3)</mtext></mstyle><mspace class='nbsp' width='0.33em'></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')\textrm {d}z' - \mu ^{(i)} \nonumber , \\ &amp; \approx - k_{\textrm {B}}T \ln \left ( \frac {\rho ^{(i)}(z)}{\rho ^{(i)}_{\textrm {bulk}}} \right ),  \end {align} </annotation></semantics> </mrow></math>
<!-- l. 48 --><p class='noindent'>Was Further validated by a minimal physical model that treated the FG
Nups as flexible homopolymers the NTRs as uniformly cohesive spheres.
</p><!-- l. 52 --><math display='block' xmlns='http://www.w3.org/1998/Math/MathML'><mrow><semantics><mrow>
<!-- tex4ht:inline --><mrow><mtable class='align-star' columnalign='left' displaystyle='true'>
        <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' stretchy='false'>=</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' stretchy='false'>+</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' stretchy='false'>+</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' stretchy='false'>−</mo> <msup><mrow><mi>z</mi></mrow><mrow><mi>′</mi></mrow></msup><mo class='MathClass-close' stretchy='false'>)</mo><mstyle class='text'><mtext class='textrm' mathvariant='normal'>d</mtext></mstyle><msup><mrow><mi>z</mi></mrow><mrow><mi>′</mi></mrow></msup><mo class='MathClass-bin' stretchy='false'>−</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' stretchy='false'>,</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' stretchy='false'>≈</mo><mo class='MathClass-bin' stretchy='false'>−</mo><msub><mrow><mi>k</mi></mrow><mrow><mstyle class='text'><mtext class='textrm' mathvariant='normal'>B</mtext></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 class='text'><mtext class='textrm' mathvariant='normal'>bulk</mtext></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' stretchy='false'>,</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')\textrm {d}z' - \mu ^{(i)} \nonumber , \\ &amp; \approx - k_{\textrm {B}}T \ln \left ( \frac {\rho ^{(i)}(z)}{\rho ^{(i)}_{\textrm {bulk}}} \right ),  \end {align*} </annotation></semantics> </mrow></math>
                                                                  

                                                                  
    
</body> 
</html>
Related Question