新的 mathjax windows
mathjax in new windows
我有一个玩 MathJax 的测试代码,它显示一些编号和可参考的数学方程式,以及一个按钮,旨在用相同的数学在浏览器中打开一个新的 windows内容...
<!DOCTYPE html>
<html>
<head>
<title>MathJax Equation References</title>
<!-- Copyright (c) 2012-2013 The MathJax Consortium -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
jax: ["input/TeX","output/HTML-CSS"],
extensions: ["tex2jax.js"],
tex2jax: {
inlineMath: [["$","$"],["\(","\)"]],
displayMath: [ ['$$','$$'], ["\[","\]"] ],
},
TeX: {
extensions: ["AMSmath.js"],
equationNumbers: { autoNumber: "AMS" } //automatic eqn numbering !!!
}
});
</script>
<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML"></script>
</head>
<body>
<div id="content">
In equation \eqref{eq:sample}, we find the value of an
interesting integral:
\begin{equation}
\int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15}
\label{eq:sample}
\end{equation}
<h1>A test of Equation References</h1>
<hr>
Here is a labeled equation:
\begin{equation}x+1\over\sqrt{1-x^2}\label{ref1}\end{equation}
with a reference to ref1: \ref{ref1},
and another numbered one with no label:
$$x+1\over\sqrt{1-x^2}$$
This one uses \nonumber:
$$x+1\over\sqrt{1-x^2}\nonumber$$
<hr>
Here's one using the equation environment:
\begin{equation}
x+1\over\sqrt{1-x^2}
\end{equation}
and one with equation* environment:
\begin{equation*}
x+1\over\sqrt{1-x^2}
\end{equation*}
<br><br><br>
<hr>
</div>
<button onclick="myFunction()">Try it</button>
<br><br><br>
<script>
var contents=document.getElementById("content").innerHTML;
function myFunction(){
var myWindow = window.open("", "_blank", "toolbar=yes,width=400,height=400");
myWindow.document.write(' <!DOCTYPE html><html><head><title>MathJax Equation References</title><!-- Copyright (c) 2012-203 The MathJax Consortium --><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><meta http-equiv="X-UA-Compatible" content="IE=edge" /> <script type="text/x-mathjax-config"> MathJax.Hub.Config({ jax: ["input/TeX","output/HTML-CSS"], extensions: ["tex2jax.js"], tex2jax: { inlineMath: [["$","$"],["\(","\)"]], displayMath: [ ["$$","$$"], ["\[","\]"] ], processEscapes: true, processEnvironments: true }, TeX: { extensions: ["AMSmath.js"], equationNumbers: { autoNumber: "AMS" } //automatic eqn numbering !!! } }); </scr'+'ipt><script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML"></scr'+'ipt></head><body>'+contents+'</div><br><br><br></body></html>');
setTimeout(function(){ myWindow.stop(); }, 15000); // assures that the windows stop loading after at most 15s
}
</script>
</body>
</html>
但是新页面中的数学内容不会在页面加载时呈现,关于如何修复它的任何线索?主标签和新标签 windows 中的 <head>
标签相同 ...
提前致谢
您已将整个 MathJax 配置放在一行中,但在其中留下了评论:
//automatic eqn numbering !!! } }); </scr'+'ipt>
这导致最后的 }});
被注释掉,这反过来又破坏了配置(它现在无效 JavaScript)。
只需删除 //automatic eqn numbering !!!
如果您打开开发人员控制台,您会发现一条错误消息,这将是一个很好的调试起点。
我有一个玩 MathJax 的测试代码,它显示一些编号和可参考的数学方程式,以及一个按钮,旨在用相同的数学在浏览器中打开一个新的 windows内容...
<!DOCTYPE html>
<html>
<head>
<title>MathJax Equation References</title>
<!-- Copyright (c) 2012-2013 The MathJax Consortium -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
jax: ["input/TeX","output/HTML-CSS"],
extensions: ["tex2jax.js"],
tex2jax: {
inlineMath: [["$","$"],["\(","\)"]],
displayMath: [ ['$$','$$'], ["\[","\]"] ],
},
TeX: {
extensions: ["AMSmath.js"],
equationNumbers: { autoNumber: "AMS" } //automatic eqn numbering !!!
}
});
</script>
<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML"></script>
</head>
<body>
<div id="content">
In equation \eqref{eq:sample}, we find the value of an
interesting integral:
\begin{equation}
\int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15}
\label{eq:sample}
\end{equation}
<h1>A test of Equation References</h1>
<hr>
Here is a labeled equation:
\begin{equation}x+1\over\sqrt{1-x^2}\label{ref1}\end{equation}
with a reference to ref1: \ref{ref1},
and another numbered one with no label:
$$x+1\over\sqrt{1-x^2}$$
This one uses \nonumber:
$$x+1\over\sqrt{1-x^2}\nonumber$$
<hr>
Here's one using the equation environment:
\begin{equation}
x+1\over\sqrt{1-x^2}
\end{equation}
and one with equation* environment:
\begin{equation*}
x+1\over\sqrt{1-x^2}
\end{equation*}
<br><br><br>
<hr>
</div>
<button onclick="myFunction()">Try it</button>
<br><br><br>
<script>
var contents=document.getElementById("content").innerHTML;
function myFunction(){
var myWindow = window.open("", "_blank", "toolbar=yes,width=400,height=400");
myWindow.document.write(' <!DOCTYPE html><html><head><title>MathJax Equation References</title><!-- Copyright (c) 2012-203 The MathJax Consortium --><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><meta http-equiv="X-UA-Compatible" content="IE=edge" /> <script type="text/x-mathjax-config"> MathJax.Hub.Config({ jax: ["input/TeX","output/HTML-CSS"], extensions: ["tex2jax.js"], tex2jax: { inlineMath: [["$","$"],["\(","\)"]], displayMath: [ ["$$","$$"], ["\[","\]"] ], processEscapes: true, processEnvironments: true }, TeX: { extensions: ["AMSmath.js"], equationNumbers: { autoNumber: "AMS" } //automatic eqn numbering !!! } }); </scr'+'ipt><script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML"></scr'+'ipt></head><body>'+contents+'</div><br><br><br></body></html>');
setTimeout(function(){ myWindow.stop(); }, 15000); // assures that the windows stop loading after at most 15s
}
</script>
</body>
</html>
但是新页面中的数学内容不会在页面加载时呈现,关于如何修复它的任何线索?主标签和新标签 windows 中的 <head>
标签相同 ...
提前致谢
您已将整个 MathJax 配置放在一行中,但在其中留下了评论:
//automatic eqn numbering !!! } }); </scr'+'ipt>
这导致最后的 }});
被注释掉,这反过来又破坏了配置(它现在无效 JavaScript)。
只需删除 //automatic eqn numbering !!!
如果您打开开发人员控制台,您会发现一条错误消息,这将是一个很好的调试起点。