![TeX4ht:\displaystyle 在 eqnarray、align 和 array 环境中](https://linux22.com/image/455625/TeX4ht%3A%5Cdisplaystyle%20%E5%9C%A8%20eqnarray%E3%80%81align%20%E5%92%8C%20array%20%E7%8E%AF%E5%A2%83%E4%B8%AD.png)
我正在使用tex4ht
将 LaTeX 文档转换为 HTML。我想知道如何在 和 环境中获得方程的完整显示eqnarray
。align
以下array
代码片段说明了我的问题。
\documentclass[12pt,a4paper,twoside,english]{book}
\usepackage{amsmath}
\begin{document}
\begin{eqnarray*}
\displaystyle
\omega = \sqrt{\displaystyle\frac{\displaystyle k}{\displaystyle m}}
& \displaystyle\mbox{ and }
& \displaystyle\gamma = \frac{\displaystyle b}{\displaystyle m}
\end{eqnarray*}
\begin{align*}
\displaystyle
\omega = \sqrt{\displaystyle\frac{\displaystyle k}{\displaystyle m}}
& \displaystyle\mbox{ and }
& \displaystyle\gamma = \frac{\displaystyle b}{\displaystyle m}
\end{align*}
\begin{equation*}
\left\{
\begin{array}{rcl}
\displaystyle
\omega & = & \sqrt{\displaystyle\frac{\displaystyle k}{\displaystyle m}} \\
\displaystyle
\gamma & = & \frac{\displaystyle b}{\displaystyle m}
\end{array}
\right.
\end{equation*}
\begin{equation*}
\omega = \sqrt{\frac{k}{m}}
\end{equation*}
\end{document}
如果我使用 编译它pdflatex
,渲染效果很好。但是,使用tex4ht
( make4ht --utf8 test.tex "mathml,mathjax"
) 时,分数会被挤压。HTML 如下所示:
我尝试放入\displaystyle
尽可能多的分数。请注意,当等式处于常规equation
环境(第四行)时,它看起来不错。有没有办法在前三行中为这些分数留出更多空间?
答案1
我们需要使用该displaystyle="true"
属性来获取分数等的正确大小。我将在 TeX4ht 源中修复它。与此同时,您可以使用以下配置文件,该文件使用原始 TeX4ht 配置并添加了此属性:
\Preamble{xhtml}
\begin{document}
\catcode`\:=11
\makeatletter
\Configure{eqnarray}
{\HCode{<\a:mathml mtable\Hnewline \a:mathml displaystyle="true" \mml:class="eqnarray\ifx
\@seqncr\@eqncr\else-star\fi"
\a:mathml columnalign="right center left" >}}%
{\HCode{</\a:mathml mtable>}}
{\HCode{<\a:mathml mtr>}} {\HCode{</\a:mathml mtr>}}
{\Tg<\a:mathml mtd\Hnewline \mml:class="eqnarray-\HCol">
\ifnum \HCol=4
\Tg<\a:mathml mtext
\mml:class="eqnarray">\ht:special{t4ht@,&\#x00A0;}%
\PauseMathClass
\mtexttrue
\Configure{$}%
{\EndPauseMathClass \mtextfalse
\ht:special{t4ht@,}%
\HCode{</\a:mathml mtext><\a:mathml
mstyle\Hnewline \mml:class="math">}}%
{\HCode{</\a:mathml mstyle><\a:mathml
mtext \a:@mtext>}\ht:special{t4ht@,&\#x00A0;}%
\PauseMathClass
\mtexttrue}%
{}%
\Configure{()}%
{\EndPauseMathClass \mtextfalse
\ht:special{t4ht@,}%
\HCode{</\a:mathml mtext><\a:mathml
mstyle\Hnewline \mml:class="math">}$}%
{$\HCode{</\a:mathml mstyle><\a:mathml
mtext \a:@mtext>}\ht:special{t4ht@,&\#x00A0;}%
\PauseMathClass
\mtexttrue}%
{}%
%
\fi}
{\ifnum \HCol=4 \mtextfalse
\EndPauseMathClass\ht:special{t4ht@,}%
\Tg</\a:mathml mtext>\fi
\Tg</\a:mathml mtd>}
\def\:tempc#1#2{%
\ConfigureEnv{#1}
{\def\end:al:env{}\ifmmode\else
\ifvmode\else \def\end:al:env{\par\ShowPar\IgnoreIndent}\fi\fi}
{\end:al:env }
{}{}%
\Configure{#1}
{\IgnorePar
\ifvmode \EndP \else \EndP \HCode{<!--tex4ht:inline-->}\fi
\ifmathml
\Tg<\a:mathml mrow>\def\end:mathalign{\Tg</\a:mathml mrow>}%
\else
\Configure{@math}{%\a:mathml
display="block"
}\DviMath
\def\end:mathalign{\EndDviMath \DisplayMathfalse}%
\DisplayMathtrue
\fi
\HCode{<\a:mathml mtable\Hnewline
\a:mathml columnalign="left" \a:mathml displaystyle="true" \mml:class="#2">}}
{\HCode{</\a:mathml mtable>}\end:mathalign }
{\HCode{<\a:mathml mtr>}} {\HCode{</\a:mathml mtr>}}
{\HCode{<\a:mathml mtd\Hnewline
\ifodd\HCol \a:mathml columnalign="right" \fi
%
\mml:class="align-\ifnum \HCol>\maxfields@ label\else
\ifodd\HCol\space odd\else even\fi
\fi">}}
{\HCode{\ifodd\HCol\space\else
<\a:mathml mspace width="2em"/>\fi
</\a:mathml mtd>}}}
\:tempc{align}{align}
\:tempc{alignat}{alignat}
\:tempc{xalignat}{xalignat}
\:tempc{xxalignat}{xxalignat}
\:tempc{flalign}{flalign}
\:tempc{align*}{align-star}
\:tempc{alignat*}{alignat-star}
\:tempc{xalignat*}{xalignat-star}
\:tempc{flalign*}{flalign-star}
\Configure{halignTB<>}{array}{\HCode{\Hnewline
\a:mathml equalrows="false"
\ifx\columnlines\empty\else\a:mathml columnlines="\columnlines" \fi
\a:mathml equalcolumns="false" \a:mathml class="array" \a:mathml displaystyle="true" }<>\HAlign}
\makeatother
\catcode`\:=12
\EndPreamble
结果如下: