Write Latex functions in html by applying MathJax
Applying MathJax
to get Latex
effect
To add LaTex
function to a html page, one could applying MathJax
method adding the following code to head
section of the html file.
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
If inline function is also needed, add the following code to the head
section, as well.
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {inlineMath: [['$', '$']]},
messageStyle: "none"
});
</script>
An example
a simple html page code is as follow.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>MathJax AsciiMath Test Page</title>
<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {inlineMath: [['$','$'], ['\(','\)']]}
});
</script>
</head>
<body>
<h1>here are some $latex$ functions</h1>
<p>
$$\int_0^infty \frac{x}{y}$$
$$ \int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15}$$
$$ \int_0^\infty \frac{x^3}{e^x-1}dx = \frac{\pi^4}{15}$$
</p>
</body>
</html>
</html>
Copy above code save, save it to a text file and rename the file to page.html
. Then, open it in a web browser, you will find a page looks as follow.
ref:
http://blog.csdn.net/LiJiancheng0614/article/details/47069817
http://blog.csdn.net/liyuanbhu/article/details/50636416