<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>MathJax AsciiMath Support — MathJax v2.0 documentation</title> <link rel="stylesheet" href="_static/mj.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '', VERSION: '2.0', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="_static/jquery.js"></script> <script type="text/javascript" src="_static/underscore.js"></script> <script type="text/javascript" src="_static/doctools.js"></script> <!--<script type="text/javascript" src="../../MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>--> <link rel="top" title="MathJax v2.0 documentation" href="index.html" /> <link rel="next" title="MathJax Output Formats" href="output.html" /> <link rel="prev" title="MathJax MathML Support" href="mathml.html" /> </head> <body> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="output.html" title="MathJax Output Formats" accesskey="N">next</a> |</li> <li class="right" > <a href="mathml.html" title="MathJax MathML Support" accesskey="P">previous</a> |</li> <li><a href="index.html">MathJax v2.0 documentation</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="mathjax-asciimath-support"> <span id="asciimath-support"></span><h1>MathJax AsciiMath Support<a class="headerlink" href="#mathjax-asciimath-support" title="Permalink to this headline">¶</a></h1> <p>The support for <a class="reference internal" href="glossary.html#term-asciimath"><em class="xref std std-term">AsciiMath</em></a> in MathJax consists of two parts: the <cite>asciimath2jax</cite> preprocessor, and the <cite>AsciiMath</cite> input processor. The first of these looks for mathematics within your web page (indicated by delimiters like <tt class="docutils literal"><span class="pre">`...`</span></tt>) and marks the mathematics for later processing by MathJax. The AsciiMath input processor is what converts the AsciiMath notation into MathJax’s internal format, where one of MathJax’s output processors then displays it in the web page.</p> <p>The AsciiMath input jax actually includes a copy of Peter Jipsen’s <tt class="docutils literal"><span class="pre">ASCIIMathML.js</span></tt> file (see the <a class="reference external" href="http://www1.chapman.edu/~jipsen/mathml/asciimath.html">AsciiMath home page</a> for details), and is included by permission of the author. This means that the results of MathJax’s AsciiMath processing should be the same as using the actual <tt class="docutils literal"><span class="pre">ASCIIMathML.js</span></tt> package (at least as far as the MathML that it generates is concerned). Thanks go to David Lippman for writing the initial version of the AsciiMath preprocessor and input jax.</p> <p>The <cite>asciimath2jax</cite> preprocessor can be configured to look for whatever markers you want to use for your math delimiters. See the <a class="reference internal" href="options/asciimath2jax.html#configure-asciimath2jax"><em>asciimath2jax configuration options</em></a> section for details on how to customize the action of <cite>asciimath2jax</cite>.</p> <p>The AsciiMath input processor handles conversion of your mathematical notation into MathJax’s internal format (which is essentially MathML). The AsciiMath input processor has few configuration options (see the <a class="reference internal" href="options/AsciiMath.html#configure-asciimath"><em>AsciiMath options</em></a> section for details).</p> <p>The AsciiMath input jax handles only the original ASCIIMathML notation (from ASCIIMathML v1.4.7), not the extened LaTeXMathML notation added in version 2.0 of ASCIIMathML, though the AsciiMath input jax does expose the tables that define the symbols that AsciiMath processes, and so it would be possible to extend them to include additional symbols. In general, it is probably better to use MathJax’s <a class="reference internal" href="tex.html#tex-support"><em>TeX input jax</em></a> to handle LaTeX notation instead.</p> <div class="section" id="asciimath-delimiters"> <h2>AsciiMath delimiters<a class="headerlink" href="#asciimath-delimiters" title="Permalink to this headline">¶</a></h2> <p>By default, the <cite>asciimath2jax</cite> preprocessor defines the back-tick (<tt class="docutils literal"><span class="pre">`</span></tt>) as the delimiters for mathematics in AsciiMath format. It does <strong>not</strong> define <tt class="docutils literal"><span class="pre">$...$</span></tt> as math delimiters. That is because dollar signs appear too often in non-mathematical settings, which could cause some text to be treated as mathematics unexpectedly. For example, with single-dollar delimiters, ”... the cost is $2.50 for the first one, and $2.00 for each additional one ...” would cause the phrase “2.50 for the first one, and” to be treated as mathematics since it falls between dollar signs. For this reason, if you want to use single-dollars for AsciiMath notation, you must enable that explicitly in your configuration:</p> <div class="highlight-javascript"><div class="highlight"><pre><span class="nx">MathJax</span><span class="p">.</span><span class="nx">Hub</span><span class="p">.</span><span class="nx">Config</span><span class="p">({</span> <span class="nx">asciimath2jax</span><span class="o">:</span> <span class="p">{</span> <span class="nx">delimiters</span><span class="o">:</span> <span class="p">[[</span><span class="s1">'$'</span><span class="p">,</span><span class="s1">'$'</span><span class="p">],</span> <span class="p">[</span><span class="s1">'`'</span><span class="p">,</span><span class="s1">'`'</span><span class="p">]]</span> <span class="p">}</span> <span class="p">});</span> </pre></div> </div> <p>Note that the dollar signs are frequently used as a delimiter for mathematics in the <a class="reference internal" href="glossary.html#term-tex"><em class="xref std std-term">TeX</em></a> format, and you can not enable the dollar-sign delimiter for both. It is probably best to leave dollar signs for TeX notation.</p> <p>See the <tt class="docutils literal"><span class="pre">config/default.js</span></tt> file, or the <a class="reference internal" href="options/asciimath2jax.html#configure-asciimath2jax"><em>asiimath2jax configuration options</em></a> page, for additional configuration parameters that you can specify for the <cite>asciimath2jax</cite> preprocessor, which is the component of MathJax that identifies AsciiMath notation within the page.</p> </div> <div class="section" id="asciimath-in-html-documents"> <h2>AsciiMath in HTML documents<a class="headerlink" href="#asciimath-in-html-documents" title="Permalink to this headline">¶</a></h2> <p>The AsciiMath syntax is descibed in the <a class="reference external" href="http://www1.chapman.edu/~jipsen/mathml/asciimathsyntax.html">ASCIIMathML syntax page</a>.</p> <p>Keep in mind that your mathematics is part of an HTML document, so you need to be aware of the special characters used by HTML as part of its markup. There cannot be HTML tags within the math delimiters (other than <tt class="docutils literal"><span class="pre"><BR></span></tt>) as AsciiMath-formatted math does not include HTML tags. Also, since the mathematics is initially given as text on the page, you need to be careful that your mathematics doesn’t look like HTML tags to the browser (which parses the page before MathJax gets to see it). In particular, that means that you have to be careful about things like less-than and greater-than signs (<tt class="docutils literal"><span class="pre"><</span></tt> and <tt class="docutils literal"><span class="pre">></span></tt>), and ampersands (<tt class="docutils literal"><span class="pre">&</span></tt>), which have special meaning to the browsers. For example,</p> <div class="highlight-html"><pre>... when `x<y` we have ...</pre> </div> <p>will cause a problem, because the brower will think <tt class="docutils literal"><span class="pre"><y</span></tt> is the beginning of a tag named <tt class="docutils literal"><span class="pre">y</span></tt> (even though there is no such tag in HTML). When this happens, the browser will think the tag continues up to the next <tt class="docutils literal"><span class="pre">></span></tt> in the document (typically the end of the next actual tag in the HTML file), and you may notice that you are missing part of the text of the document. In the example above, the “<tt class="docutils literal"><span class="pre">we</span> <span class="pre">have</span> <span class="pre">...</span></tt>” will not be displayed because the browser thinks it is part of the tag starting at <tt class="docutils literal"><span class="pre"><y</span></tt>. This is one indication you can use to spot this problem; it is a common error and should be avoided.</p> <p>Usually, it is sufficient to simply put spaces around these symbols to cause the browser to avoid them, so</p> <div class="highlight-html"><pre>... when `x < y` we have ...</pre> </div> <p>should work. Alternatively, you can use the HTML entities <tt class="docutils literal"><span class="pre">&lt;</span></tt>, <tt class="docutils literal"><span class="pre">&gt;</span></tt> and <tt class="docutils literal"><span class="pre">&amp;</span></tt> to encode these characters so that the browser will not interpret them, but MathJax will. E.g.,</p> <div class="highlight-html"><div class="highlight"><pre>... when `x <span class="ni">&lt;</span> y` we have ... </pre></div> </div> <p>Keep in mind that the browser interprets your text before MathJax does.</p> </div> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="index.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">MathJax AsciiMath Support</a><ul> <li><a class="reference internal" href="#asciimath-delimiters">AsciiMath delimiters</a></li> <li><a class="reference internal" href="#asciimath-in-html-documents">AsciiMath in HTML documents</a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="mathml.html" title="previous chapter">MathJax MathML Support</a></p> <h4>Next topic</h4> <p class="topless"><a href="output.html" title="next chapter">MathJax Output Formats</a></p> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="search.html" method="get"> <input type="text" name="q" size="18" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="output.html" title="MathJax Output Formats" >next</a> |</li> <li class="right" > <a href="mathml.html" title="MathJax MathML Support" >previous</a> |</li> <li><a href="index.html">MathJax v2.0 documentation</a> »</li> </ul> </div> <div class="footer"> © Copyright 2012 Design Science. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7. </div> </body> </html>