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 MathJaxmethod 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

posted on   yusisc  阅读(22)  评论(0编辑  收藏  举报

编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示