我已经保持显示方程的原样。但方程交叉链接没有转换。如何实现这一点?我的示例 LaTeX 文件是:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}\label{eq1}
\alpha + \beta = \gamma
\end{equation}
This is the equation cross ref link Eq.~\ref{eq1}
\end{document}
我的CFG
是:
\usepackage{verbatim}
\usepackage[T1]{fontenc}
\Preamble{xhtml}
% Configure for mathjax
\Configure{VERSION}{}
\Configure{DOCTYPE}{\HCode{<!DOCTYPE html>\Hnewline}}
\Configure{HTML}{\HCode{<html>\Hnewline}}{\HCode{\Hnewline</html>}}
\Configure{@HEAD}{\HCode{
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
TeX: {
Macros: {
\unexpanded{La : "\\Lambda",
B: "\\beta",
twosilt: "\\textrm{2-silt}",}
}
},
extensions: ["tex2jax.js"],
tex2jax: {
\unexpanded{
inlineMath: [ ['\$','\$'], ["\\\\(","\\\\)"] ],
displayMath: [ ['$$','$$'], ["\\[","\\]"] ],}
processEscapes: true
}
});
</script>
}}
\Configure{@HEAD}{\HCode{<script type="text/javascript"\Hnewline
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"\Hnewline
></script>\Hnewline}}
\newtoks\eqtoks
\def\AltMath#1${\eqtoks{$#1$}%
\HCode{\the\eqtoks}$}
\Configure{$}{}{}{\expandafter\AltMath}
\def\AltlMathI#1\){\eqtoks{\(#1\)}%
\HCode{\the\eqtoks}}
\Configure{()}{\AltlMathI}{}
\def\AltlDisplay#1\]{\eqtoks{\[#1\]}%
\HCode{\the\eqtoks}}
\Configure{[]}{\AltlDisplay}{}
\begin{document}
\newcommand\VerbMath[1]{%
\renewenvironment{#1}{%
\NoFonts%
\string\begin\{#1\}%
\verbatim}{\endverbatim\string\end\{#1\}\EndNoFonts}%
}
\VerbMath{equation}
\VerbMath{cases}
\VerbMath{array}
\VerbMath{matrix}
\VerbMath{pmatrix}
\VerbMath{eqnarray}
\VerbMath{eqnarray*}
\EndPreamble
答案1
mathjax
您还需要使用\ref
指向方程的处理命令(而不是指向部分或图形的命令,这些命令仍然由 LaTeX 处理)。由于数学中的所有内容都由处理mathjax
,因此最简单的解决方案是使用$\ref{label}$
:
This is the equation cross ref link Eq.~$\ref{eq1}$
第二个问题是公式默认没有编号,所以你无法获得参考编号:
可以通过在配置TeX
部分中插入以下代码来解决此问题:mathjax
equationNumbers: { autoNumber: "AMS" }
具有更新配置的完整配置文件mathjax
:
\usepackage{verbatim}
\usepackage[T1]{fontenc}
\Preamble{xhtml}
% Configure for mathjax
\Configure{VERSION}{}
\Configure{DOCTYPE}{\HCode{<!DOCTYPE html>\Hnewline}}
\Configure{HTML}{\HCode{<html>\Hnewline}}{\HCode{\Hnewline</html>}}
\Configure{@HEAD}{\HCode{
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
TeX: {
Macros: {
\unexpanded{La : "\\Lambda",
B: "\\beta",
twosilt: "\\textrm{2-silt}",}
},
equationNumbers: { autoNumber: "AMS" }
},
extensions: ["tex2jax.js"],
tex2jax: {
\unexpanded{
inlineMath: [ ['\$','\$'], ["\\\\(","\\\\)"] ],
displayMath: [ ['$$','$$'], ["\\[","\\]"] ],}
processEscapes: true
}
});
</script>
}}
\Configure{@HEAD}{\HCode{<script type="text/javascript"\Hnewline
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"\Hnewline
></script>\Hnewline}}
\newtoks\eqtoks
\def\AltMath#1${\eqtoks{$#1$}%
\HCode{\the\eqtoks}$}
\Configure{$}{}{}{\expandafter\AltMath}
\def\AltlMathI#1\){\eqtoks{\(#1\)}%
\HCode{\the\eqtoks}}
\Configure{()}{\AltlMathI}{}
\def\AltlDisplay#1\]{\eqtoks{\[#1\]}%
\HCode{\the\eqtoks}}
\Configure{[]}{\AltlDisplay}{}
\begin{document}
\newcommand\VerbMath[1]{%
\renewenvironment{#1}{%
\NoFonts%
\string\begin\{#1\}%
\verbatim}{\endverbatim\string\end\{#1\}\EndNoFonts}%
}
\VerbMath{equation}
\VerbMath{cases}
\VerbMath{array}
\VerbMath{matrix}
\VerbMath{pmatrix}
\VerbMath{eqnarray}
\VerbMath{eqnarray*}
\EndPreamble
现在结果好多了: