入门

金宝搏188MathJax allows you to in金宝搏188clude mathematics in your web pages,eitherusing LaTeX,MathML,or AsciiMath notation,数学将使用jav金宝搏188ascript生成HTML,SVG or MathMLequations for viewing in any modern browser.

There are two ways to access 金宝搏188MathJax: the easiest way is to use thecopy of MathJax available from a distributed network service such asCDNJS.com,但您也可以下载并在自己的服务器上安装Mathjax的副本,金宝搏188或者在硬盘上本地使用(不需要网络访问)。All three of these are describedbelow,with links to more detailed explanations.This page gives thequickest and easiest ways to get 金宝搏188MathJax up and running on your website,but you may want to read the details in order to customize thesetup for your pages.

使用内容交付网络(cdn)

The easiest way to use 金宝搏188MathJax is to link directly to a publicinstallation available through a Content Distribution Network(CDN).When you use a CDN,不需要自己安装Mathjax,金宝搏188你可以马上开始使用Mathjax。金宝搏188

a cdn will automatically arrange for your readers to download 金宝搏188MathJaxfiles from a fast,nearby server.

要使用来自cd金宝搏188n的mathjax,你需要做两件事:

  1. 在包含数学的网页金宝搏188中链接到Mathjax。金宝搏188
  2. 把数学放金宝搏188到你的网页上,这样Mathjax就可以显示它了。金宝搏188

Warning

We retired our self-hosted CDN at麻省理工金宝搏188大学in April,2017.We recommend usingCDNJS.comwhich uses the same provider.The use of麻省理工金宝搏188大学受其管辖terms of service.

开始使用CDNJS,你通过

<脚本 类型="text/javascript" 异步的
  src="https://cdnjs.cloudflare.com/ajax/libs/金宝搏188mathjax/2.6.1/MathJax.js?config=TeX-MML-AM_CHTML">

              脚本>

进入阻止您的文档。(It can also go in theif necessary,but the head is to be preferred.) This willload the latest version of 金宝搏188MathJax from the distributed server,andconfigure it to recognize 金宝搏188mathematics in both TeX,MathML,and AsciiMath notation,and ask it to generate its output using HTML with CSS to display the金宝搏188mathematics.

Warning

这个TEX-MML-AM-CHTML公司配置是最通用(因而也是最大的)组合配置文件之一。We list it here because it will quickly get you started using 金宝搏188MathJax.It is probably not the most efficient configuration for your purposes and other组合配置文件are available.您还可以提供额外的配置参数来根据您的需要定制一个组合配置,或者使用我们的开发工具来生成您自己的组合配置文件。

More details about the configuration process can be found in the加载和配置Mathjax金宝搏188instructions.

Note

To see how to enter 金宝搏188mathematics in your web pages,seePutting金宝搏188mathematics in a web pagebelow.

Putting 金宝搏188mathematics in a web page

To put 金宝搏188mathematics in your web page,you can useTeXLaTeXnotation,MathMLnotation,AsciiMathnotation,or a combination of all three within the same page;The金宝搏188mathjax配置告诉Mathjax您要使用哪个,and how youplan to indicate the 金宝搏188mathematics when you are using TeX/LaTeX or AsciiMath notation.上面例子中使用的配置文件告诉mathjax查找两个tex,金宝搏188AsciiMath,以及页面中的MathML符号。其他配置文件告诉Mathjax只使用这些输入选项中的一个或其金宝搏188他输出选项中的一个。These threeformats are described in more detail below.

TeX and LaTeX input

金宝搏188Mathematics that is written inTeXLaTeXformat isindicated usingmath delimiters围绕着数学,告诉Mathjax你页面金宝搏188的哪个部分代表数学,什么是正常文本。金宝搏188有两种类型的方程:一种发生在段落中的方程(线性数学)。金宝搏188以及较大的方程,这些方程与文本的其余部分相互独立(显示数学)。金宝搏188

默认的数学分隔符是$…$$\[...\]fordisplayed 金宝搏188mathematics,和\(...\)用于在线数学。金宝搏188Notein particular that the美元…行内分隔符是not默认使用。这是因为美元符号经常出现在数学环境中,金宝搏188which could cause some text to be treatedas 金宝搏188mathematics unexpectedly.For example,带单块限位器,“……”the cost is $2.50 for the first one,另外一个2.00美元……会导致“第一个2.50美元,and" to be treated as 金宝搏188mathematics since it falls between dollarsigns.因此,如果您想在LineMash模式下使用一美元,you must enable that explicitly in your configuration:

<脚本 类型="text/x-金宝搏188mathjax-config">
金宝搏188.枢纽.Config({
  TX2JAX: {内线: [[“$”,“$”], ['\\(','\\)']]}
});

               脚本>
<脚本 类型="text/javascript" 异步的 src=“到mathjax金宝搏188/mathjax.js的路径?配置=TEX-AMS CHTML”>
                脚本>

See theconfig/default.js文件,或tex2jax配置选项页对于您可以为TX2JAXpreprocessor,which is the component of 金宝搏188MathJax that identifies TeX notation withinthe page.See theTeX and LaTeX关于Mathjax对Tex的支持金宝搏188,and in particular how to deal withsingle dollar signs in your text when you have enabled singledollar-sign delimiters.

Here is a complete sample page containing TeX 金宝搏188mathematics (alsoavailable in the测试/sample-tex.html文件):


<html>
<head>
<标题>金宝搏188Mathjax Tex测试页
               标题>
<脚本 类型="text/x-金宝搏188mathjax-config">
  金宝搏188.枢纽.Config({TX2JAX: {内线: [[“$”,“$”], ['\\(','\\)'[}{});

                脚本>
<脚本 类型="text/javascript" 异步的
  src=“https://example.com/金宝搏188mathjax.js?配置=TEX-AMS CHTML”>

                 脚本>

                  head>
<body>当$a ne 0美元,there are two solutions to \(ax^2 + bx + c = 0\) and they are$$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$
                   body>

                    html> 

因为tex符号是页面文本的一部分,当你学习数学时,你必须记住一些注意事项,尤其是,金宝搏188你要小心使用不到的标志,since those are what the browser uses to indicate the start ofa tag in HTML.Putting a space on both sides of the less-than signshould be sufficient,but seeTex和乳胶支架详情。

If you are using 金宝搏188MathJax within a blog,wiki,or other contentmanagement system,the markup language used by that system mayinterfere with the TeX notation used by 金宝搏188MathJax.For example,if yourblog uses降价notation for authoring your pages,theunderscores used by TeX to indicate subscripts may be confused withthe use of underscores by Markdown to indicate italics,这两个房间可能会阻止你的数学被展示。金宝搏188SeeTeXand LaTeX support关于如何处理这个问题的一些建议。

Tex输入处理器有许多扩展,由组合的配置文件加载,其中包括TeXin their name (e.g.,TEX-AMSY-CHTML)These include:

  • TeX/AMSmath.js,它定义了AMS数学环境和宏,
  • TeX/AMSsymbols.js,它定义了符号的宏MSAM10MSBM10fonts,
  • TX/NoErr.JS,which shows the original TeX code rather thanan error message when there is a problem processing the TeX,和
  • tex/名词定义.js,which prevents undefined macros fromproducing an error message,and instead shows the macro name in red.

其他扩展可以在需要时自动加载。

Note

SeeTex和乳胶支架for details on the otherTeX extensions that are available.

MathML input

数学写作金宝搏188MathMLnotation,您可以使用标准标记您的主题金宝搏188 tags,where display="block"> 表示显示的数学和金宝搏188 display=“inline”> or just represents in-line 金宝搏188mathematics.

Note that even on old browsers this will work in HTML files,不仅仅是XHTML文件(MathjaxWor金宝搏188ks同时使用这两个文件),and that the web page need not be served with anyspecial MIME-type.但是请注意,在HTML中(与XHTML相反),你应该notinclude a namespace prefix for your tags;例如,你不应该使用 exceptin an XHTML file where you have tied them通过添加xmlns:m=“http://www.w3.org/1998/math/mathml”attributeto your file'stag.

Although it is not required,建议您将xmlns=“http://www.w3.org/1998/math/mathml”attribute on all tags in your document (and this is preferred to the use ofa namespace prefix likeM:上面,因为这些都是不赞成的inhtml5),以便使您的MathML在最广泛的情况下工作。

Here is a complete sample page containing MathML 金宝搏188mathematics (alsoavailable in the测试/示例-mml.html文件):


<html>
<head>
<标题>金宝搏188MathJax MathML Test Page
               标题>
<脚本 类型="text/javascript" 异步的
  src=“https://example.com/金宝搏188mathjax.js?配置=mml_chtml“>

                脚本>

                 head>
<body>

<p>什么时候?<数学 XMLNS=“http://www.w3.org/1998/math/mathml”>
  <惯性矩>a
                  惯性矩><mo>γ
                   mo><mn>0
                    mn> 
                     数学>,there are two solutions to<数学 XMLNS=“http://www.w3.org/1998/math/mathml”> <惯性矩>a
                      惯性矩><msup><惯性矩>x
                       惯性矩><mn>
                        mn>
                         msup> <mo>+
                          mo> <惯性矩>
                           惯性矩><惯性矩>x
                            惯性矩> <mo>+
                             mo> <惯性矩>c
                              惯性矩> <mo>=
                               mo> <mn>0
                                mn> 
                                 数学>他们是<数学 XMLNS=“http://www.w3.org/1998/math/mathml” display="block"> <惯性矩>x
                                  惯性矩> <mo>=
                                   mo> <mrow> <MFRAC> <mrow> <mo>-
                                    mo> <惯性矩>
                                     惯性矩> <mo>±
                                      mo> <MQRT> <msup><惯性矩>
                                       惯性矩><mn>
                                        mn>
                                         msup> <mo>-
                                          mo> <mn>4
                                           mn><惯性矩>a
                                            惯性矩><惯性矩>c
                                             惯性矩> 
                                              MQRT> 
                                               mrow> <mrow> <mn>
                                                mn><惯性矩>a
                                                 惯性矩> 
                                                  mrow> 
                                                   MFRAC> 
                                                    mrow> <多行文本>.
                                                     多行文本> 
                                                      数学> 
                                                       p> 
                                                        body> 
                                                         html> 

在HTML页(而不是XHTML页)中输入MathML符号时,你应该not使用自动关闭标签,but should use explicitopen and close tags for all your math elements.For example,你应该使用

<模型空间 width="5pt">
               模型空间>

rather than 宽度=“5PT” /> 在一个HTML文档。如果你使用自动关闭窗体,有些浏览器无法正常构建数学树,and 金宝搏188MathJax will receive a damaged math structure,whichwill not be rendered as the original notation would have been.Typically,this will cause parts of your expression to not bedisplayed.不幸的是,there is nothing 金宝搏188MathJax can do about that,since the browser has incorrectly interpreted the tags long beforeMathJax has a chance to work with them.

The component of 金宝搏188MathJax that recognizes MathML notation within thepage is called themml2jax延伸,它只有很少的配置选项;see theconfig/default.jsfile or themml2jax配置选项有关详细信息,请参见第页。

Note

See theMathMLpage for more on金宝搏188MathJax's MathML support.

AsciiMath input

金宝搏188MathJax v2.0 introduced a new input format:AsciiMath通过合并表示法阿西米塔姆默认情况下,you mark 金宝搏188mathematicalexpressions written in this form by surrounding them in "back-ticks",i.e.,“…”.

以下是包含asciiMath符号的完整示例页(在test/sample-asciimath.html文件):


<html>
<head>
<标题>金宝搏188Mathjax AsciiMath测试页
               标题>
<脚本 类型="text/javascript" 异步的
  src=“https://example.com/金宝搏188mathjax.js?配置=AM“CHTML”>
                脚本>

                 head>
<body>

<p>当A!=0,there are two solutions to `ax^2 + bx + c = 0` andthey are
                  p>
<p style=“文本对齐:居中”>`x = (-b +- sqrt(b^2-4ac))/(2a) .`
                   p>


                    body> 
                     html> 

The component of 金宝搏188MathJax that recognizes asciimath notation within thepage is called theasciimath2jax延伸,它只有很少的配置选项;see theconfig/default.jsfile or theasciimath2jax configuration options有关详细信息,请参见第页。

Note

See theAsciiMath支持page for more on金宝搏188MathJax's AsciiMath support.

Installing Your Own Copy of 金宝搏188MathJax

We recommend using a cdn service if you can,but you can also install金宝搏188MathJax on your own server,或者在本地硬盘上。要做到这一点,你需要做以下事情:

  1. 获取Mathjax的副本,并将其放金宝搏188在服务器或硬盘上。
  2. Configure 金宝搏188MathJax to suit the needs of your site.
  3. 将Math金宝搏188jax链接到要包含数学的网页中。金宝搏188
  4. 把数学放金宝搏188到你的网页上,这样Mathjax就可以显示它了。金宝搏188

Downloading and Installing 金宝搏188MathJax

Math金宝搏188jax源代码是托管OnGithub.To install 金宝搏188MathJax on your own server,下载the latest distributionandunpack the archive and place the resulting 金宝搏188MathJax folder onto yourweb server at a convenient location where you can include it into yourweb pages.For example,making金宝搏188服务器上的顶级目录是实现这一点的一种自然方法。这将允许您通过URL引用主Mathjax文件金宝搏188/金宝搏188Mathjax/Mathjax.js在服务器上的任何页面中。

一旦在服务器上设置了Math金宝搏188jax,you can test it using thefiles in the金宝搏188MathJax/testdirectory.If you are putting 金宝搏188MathJaxon a server,load them in your browser using their web addressesrather than opening them locally (i.e.,使用一个http://网址:ratherthan A文件:/ /URL)。When you view the索引文件文件,aftera few moments you should see a message indicating that 金宝搏188MathJax appearsto be working.如果不是,检查文件是否已完全传输到服务器,权限是否允许服务器访问MathJAX目录中的文件和文件夹。(确保验证MathJAX文件夹的权限。)检查服务器日志文件是否存在与MathJAX安装相关的任何错误;金宝搏188this may help locate problems in the permission orlocations of files.

Note

For more details (such as version control access) see安装说明.

Configuring your copy of 金宝搏188MathJax

当您将Mathjax包含到您的网页金宝搏188中时,如下面所述,它将加载文件配置/tex-mml-am chtml.js(i.e.,文件名TeX-MML-AM_CHTML.jsin theconfigfolder of themain金宝搏188folder).This file preloads all the mostcommonly-used components of 金宝搏188MathJax,允许它处理Tex或LaTex格式的数学,金宝搏188AsciiMath format,or in MathML notation.It will produce output in HTML (with CSS) to render the金宝搏188mathematics.

There are a number of other prebuilt configuration files that you canchoose from as well,或者你可以用config/default.jsfile andcustomize the settings yourself.

Note

The combined configuration files aredescribed more fully inCommon Configurations,配置选项在Configuration Options.

将Mathjax副本链接到网页金宝搏188

You can include 金宝搏188MathJax in your web page by putting

<脚本 类型="text/javascript" 异步的 src="path-to-金宝搏188MathJax/MathJax.js?config=TeX-MML-AM_CHTML">
               脚本>

在您的文档中块。Here,path-to-金宝搏188MathJaxshouldbe replaced by the URL for the main 金宝搏188MathJax directory,所以如果你把金宝搏188directory at the top level of you server's website,you could use

<脚本 类型="text/javascript" 异步的 src=“/金宝搏188mathjax/mathjax.js?配置=tex-mml-am_chtml“>
               脚本>

to load 金宝搏188MathJax in your page.For example,your page could look like

<html>
    <head>...<脚本 类型="text/javascript" 异步的 src=“/金宝搏188mathjax/mathjax.js?配置=tex-mml-am_chtml“>
               脚本>
    
                head>
    <body>...
                 body>

                  html>

Note

If you have installed 金宝搏188MathJax on a server that is in a differentdomain from the one serving the page that loads MathJax,一定要读关于共享服务器的说明更多详细信息。In that case,您可以考虑使用金宝搏188MathJax CDNrather than installing your own copyof 金宝搏188MathJax.

从这里到哪里?

If you have followed the instructions above,you should now have金宝搏188MathJax installed and configured on your web server,and you should beable to use it to write web pages that include 金宝搏188mathematics.At thispoint,you can start making pages that contain 金宝搏188mathematical content!

You could also read more about the details of how to定制MATHJAX金宝搏188.

If you are trying to use 金宝搏188MathJax in blog or wiki software or in someother content-management system,you might want to read about在流行平台金宝搏188中使用gmathjax.

如果你正在处理包含数学的动态页面,金宝搏188youmight want to read about the金宝搏188MathJax Application ProgrammingInterface(其API)so you know how to include金宝搏188mathematics in your interactive pages.

If you are having trouble getting 金宝搏188MathJax to work,你可以阅读更多关于installing 金宝搏188MathJax,或loading andconfiguring 金宝搏188MathJax.

最后,如果你有问题或意见,or want to help support金宝搏188MathJax,你可以去看看金宝搏188Mathjax社区论坛金宝搏188MathJax bug tracker.