Html 新windows中的mathjax
我有一个玩MathJax的测试代码,它显示一些编号的和可参考的数学公式,还有一个按钮,用于在浏览器中打开具有相同数学内容的新窗口Html 新windows中的mathjax,html,mathjax,new-window,Html,Mathjax,New Window,我有一个玩MathJax的测试代码,它显示一些编号的和可参考的数学公式,还有一个按钮,用于在浏览器中打开具有相同数学内容的新窗口 <!DOCTYPE html> <html> <head> <title>MathJax Equation References</title> <!-- Copyright (c) 2012-2013 The MathJax Consortium --> <meta http-equiv=
<!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>
MathJax方程参考
MathJax.Hub.Config({
jax:[“输入/文本”,“输出/HTML-CSS”],
扩展:[“tex2jax.js”],
tex2jax:{
inlineMath:[[“$”,“$”],[“\\(“,“\\)”],
displayMath:[['$','$$'],[“\\[”,“\\]”],
},
特克斯:{
扩展名:[“AMSmath.js”],
等式编号:{自动编号:“AMS”}//自动等式编号!!!
}
});
在方程\eqref{eq:sample}中,我们找到
有趣的积分:
\开始{等式}
\int\u 0^\infty\frac{x^3}{e^x-1}\,dx=\frac{\pi^4}{15}
\标签{eq:sample}
\结束{方程}
方程式参考的检验
下面是一个标记的方程式:
\开始{equation}x+1\over\sqrt{1-x^2}\label{ref1}\end{equation}
引用ref1:\ref{ref1},
另一个编号的没有标签:
$$x+1\over\sqrt{1-x^2}$$
此项使用\n编号:
$$x+1\over\sqrt{1-x^2}\n数字$$
下面是一个使用等式环境的例子:
\开始{等式}
x+1\over\sqrt{1-x^2}
\结束{方程}
还有一个等式*环境:
\开始{等式*}
x+1\over\sqrt{1-x^2}
\结束{方程*}
试试看
var contents=document.getElementById(“content”).innerHTML;
函数myFunction(){
var myWindow=window.open(“,”_blank“,”工具栏=yes,宽度=400,高度=400”);
myWindow.document.write('MathJax等式引用MathJax.Hub.Config({jax:[“输入/TeX”,“输出/HTML-CSS”],扩展名:[“tex2jax.js”],tex2jax:{inlineMath:[[“$”,“$”,[“\\(”,“\\)”],displayMath:[“$$”,“$$”,[“\\\[”,“\\\]”],processEscapes:true,processEnvironments:true},TeX:{extensions:[“AMSmath.js”],equalationNumber:{autoNumber:“AMS”}//自动eqn编号!!!});“+contents+”
”;
setTimeout(function(){myWindow.stop();},15000);//确保窗口在最多15秒后停止加载
}
但是新页面中的数学内容不会在页面加载时呈现,有没有关于如何修复它的线索?主窗口和新窗口中的
标记相同
提前感谢您将整个MathJax配置放在一行中,但在其中留下了一条注释:
//自动eqn编号!!!});
这将导致最终的})代码>被注释掉,这会破坏配置(现在是无效的JavaScript)
只需删除//自动eqn编号代码>
如果打开开发人员控制台,您将发现一条错误消息,这将是调试的良好起点。您已将整个MathJax配置放在一行中,但在其中留下了一条注释:
//自动eqn编号!!!});
这将导致最终的})代码>被注释掉,这会破坏配置(现在是无效的JavaScript)
只需删除//自动eqn编号代码>
如果打开开发人员控制台,您将发现一条错误消息,这将是调试的良好起点