Add more to TeX documentation, and include new examples

This commit is contained in:
Davide P. Cervone 2012-02-22 10:53:18 -05:00
parent 39b78b1477
commit 90f9948e19
9 changed files with 419 additions and 7 deletions

View File

@ -322,6 +322,33 @@ load extensions into pages that didn't load them in their
configurations (and prevents you from having to load all the
extensions into all pages even if they aren't used).
It is also possible to create a macro that will autoload an extension
when it is first used (under the assumption that the extension will
redefine it to perform its true function). For example
.. code-block:: html
<script type="text/x-mathjax-config">
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
MathJax.Hub.Insert(MathJax.InputJax.TeX.Definitions.macros,{
cancel: ["Extension","cancel"],
bcancel: ["Extension","cancel"],
xcancel: ["Extension","cancel"],
cancelto: ["Extension","cancel"]
});
});
</script>
would declare the ``\cancel``, ``\bcancel``, ``\xcancel``, and
``\cancelto`` macros to load the `cancel` extension (where they are
actually defined). Whichever is used first will cause the extension
to be loaded, redefining all four to their proper values. Note that
this may be better than loading the extension explicitly, since it
avoids loading the extra file on pages where these macros are *not*
used. The `sample autoloading macros
<http://cdn.mathjax.org/mathjax/latest/test/sample-autoload.html>`_
example page shows this in action.
The main extensions are described below.
@ -383,6 +410,9 @@ want to use the other macros that it defines. The `AMSsymbols` extension
is not loaded automatically, so you must include it explicitly if you want
to use the macros it defines.
Both extensions are included in all the combined configuration files
that load the TeX input processor.
Autobold
--------
@ -742,7 +772,20 @@ the paragraph, use
}
}
You may also wish to set the font family, as the default is "serif".
You may also wish to set the font family or other CSS values here.
If you are using a combined configuration file that loads the TeX
input processor, it will also load the `noErrors` extension
automatically. If you want to disable the `noErrors` extension so
that you receive the normal TeX error messages, use the following
configuration:
.. code-block:: javascript
TeX: { noErrors: { disabled: true } }
Any math that includes errors will be replaced by an error message
indicating what went wrong.
noUndefined
@ -777,6 +820,19 @@ default values set ``mathcolor`` to ``"red"``, but do not set any
other attributes. This example sets the background to a light pink,
and reduces the font size slightly.
If you are using a combined configuration file that loads the TeX
input processor, it will also load the `noUndefined` extension
automatically. If you want to disable the `noUndefined` extension so
that you receive the normal TeX error messages for undefined macros,
use the following configuration:
.. code-block:: javascript
TeX: { noUndefined: { disabled: true } }
Any math that includes an undefined control sequence name will be
replaced by an error message indicating what name was undefined.
Unicode support
---------------

View File

@ -122,7 +122,7 @@ MathML, and AsciiMath notaion that works in all modern browsers.</p>
</li>
</ul>
<hr class="docutils" />
<p>This version of the documentation was built February 20, 2012.</p>
<p>This version of the documentation was built February 22, 2012.</p>
</div>
</div>

File diff suppressed because one or more lines are too long

View File

@ -311,6 +311,29 @@ the non-standard <tt class="docutils literal"><span class="pre">\require{extensi
load extensions into pages that didn&#8217;t load them in their
configurations (and prevents you from having to load all the
extensions into all pages even if they aren&#8217;t used).</p>
<p>It is also possible to create a macro that will autoload an extension
when it is first used (under the assumption that the extension will
redefine it to perform its true function). For example</p>
<div class="highlight-html"><div class="highlight"><pre><span class="nt">&lt;script </span><span class="na">type=</span><span class="s">&quot;text/x-mathjax-config&quot;</span><span class="nt">&gt;</span>
<span class="nx">MathJax</span><span class="p">.</span><span class="nx">Hub</span><span class="p">.</span><span class="nx">Register</span><span class="p">.</span><span class="nx">StartupHook</span><span class="p">(</span><span class="s2">&quot;TeX Jax Ready&quot;</span><span class="p">,</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
<span class="nx">MathJax</span><span class="p">.</span><span class="nx">Hub</span><span class="p">.</span><span class="nx">Insert</span><span class="p">(</span><span class="nx">MathJax</span><span class="p">.</span><span class="nx">InputJax</span><span class="p">.</span><span class="nx">TeX</span><span class="p">.</span><span class="nx">Definitions</span><span class="p">.</span><span class="nx">macros</span><span class="p">,{</span>
<span class="nx">cancel</span><span class="o">:</span> <span class="p">[</span><span class="s2">&quot;Extension&quot;</span><span class="p">,</span><span class="s2">&quot;cancel&quot;</span><span class="p">],</span>
<span class="nx">bcancel</span><span class="o">:</span> <span class="p">[</span><span class="s2">&quot;Extension&quot;</span><span class="p">,</span><span class="s2">&quot;cancel&quot;</span><span class="p">],</span>
<span class="nx">xcancel</span><span class="o">:</span> <span class="p">[</span><span class="s2">&quot;Extension&quot;</span><span class="p">,</span><span class="s2">&quot;cancel&quot;</span><span class="p">],</span>
<span class="nx">cancelto</span><span class="o">:</span> <span class="p">[</span><span class="s2">&quot;Extension&quot;</span><span class="p">,</span><span class="s2">&quot;cancel&quot;</span><span class="p">]</span>
<span class="p">});</span>
<span class="p">});</span>
<span class="nt">&lt;/script&gt;</span>
</pre></div>
</div>
<p>would declare the <tt class="docutils literal"><span class="pre">\cancel</span></tt>, <tt class="docutils literal"><span class="pre">\bcancel</span></tt>, <tt class="docutils literal"><span class="pre">\xcancel</span></tt>, and
<tt class="docutils literal"><span class="pre">\cancelto</span></tt> macros to load the <cite>cancel</cite> extension (where they are
actually defined). Whichever is used first will cause the extension
to be loaded, redefining all four to their proper values. Note that
this may be better than loading the extension explicitly, since it
avoids loading the extra file on pages where these macros are <em>not</em>
used. The <a class="reference external" href="http://cdn.mathjax.org/mathjax/latest/test/sample-autoload.html">sample autoloading macros</a>
example page shows this in action.</p>
<p>The main extensions are described below.</p>
<div class="section" id="action">
<h3>Action<a class="headerlink" href="#action" title="Permalink to this headline"></a></h3>
@ -366,6 +389,8 @@ environments it defines, but you will have to load it explicitly if you
want to use the other macros that it defines. The <cite>AMSsymbols</cite> extension
is not loaded automatically, so you must include it explicitly if you want
to use the macros it defines.</p>
<p>Both extensions are included in all the combined configuration files
that load the TeX input processor.</p>
</div>
<div class="section" id="autobold">
<h3>Autobold<a class="headerlink" href="#autobold" title="Permalink to this headline"></a></h3>
@ -687,7 +712,17 @@ the paragraph, use</p>
<span class="p">}</span>
</pre></div>
</div>
<p>You may also wish to set the font family, as the default is &#8220;serif&#8221;.</p>
<p>You may also wish to set the font family or other CSS values here.</p>
<p>If you are using a combined configuration file that loads the TeX
input processor, it will also load the <cite>noErrors</cite> extension
automatically. If you want to disable the <cite>noErrors</cite> extension so
that you receive the normal TeX error messages, use the following
configuration:</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="nx">TeX</span><span class="o">:</span> <span class="p">{</span> <span class="nx">noErrors</span><span class="o">:</span> <span class="p">{</span> <span class="nx">disabled</span><span class="o">:</span> <span class="kc">true</span> <span class="p">}</span> <span class="p">}</span>
</pre></div>
</div>
<p>Any math that includes errors will be replaced by an error message
indicating what went wrong.</p>
</div>
<div class="section" id="noundefined">
<h3>noUndefined<a class="headerlink" href="#noundefined" title="Permalink to this headline"></a></h3>
@ -716,6 +751,16 @@ the following to your <tt class="xref py py-meth docutils literal"><span class="
default values set <tt class="docutils literal"><span class="pre">mathcolor</span></tt> to <tt class="docutils literal"><span class="pre">&quot;red&quot;</span></tt>, but do not set any
other attributes. This example sets the background to a light pink,
and reduces the font size slightly.</p>
<p>If you are using a combined configuration file that loads the TeX
input processor, it will also load the <cite>noUndefined</cite> extension
automatically. If you want to disable the <cite>noUndefined</cite> extension so
that you receive the normal TeX error messages for undefined macros,
use the following configuration:</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="nx">TeX</span><span class="o">:</span> <span class="p">{</span> <span class="nx">noUndefined</span><span class="o">:</span> <span class="p">{</span> <span class="nx">disabled</span><span class="o">:</span> <span class="kc">true</span> <span class="p">}</span> <span class="p">}</span>
</pre></div>
</div>
<p>Any math that includes an undefined control sequence name will be
replaced by an error message indicating what name was undefined.</p>
</div>
<div class="section" id="unicode-support">
<h3>Unicode support<a class="headerlink" href="#unicode-support" title="Permalink to this headline"></a></h3>

View File

@ -322,6 +322,33 @@ load extensions into pages that didn't load them in their
configurations (and prevents you from having to load all the
extensions into all pages even if they aren't used).
It is also possible to create a macro that will autoload an extension
when it is first used (under the assumption that the extension will
redefine it to perform its true function). For example
.. code-block:: html
<script type="text/x-mathjax-config">
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
MathJax.Hub.Insert(MathJax.InputJax.TeX.Definitions.macros,{
cancel: ["Extension","cancel"],
bcancel: ["Extension","cancel"],
xcancel: ["Extension","cancel"],
cancelto: ["Extension","cancel"]
});
});
</script>
would declare the ``\cancel``, ``\bcancel``, ``\xcancel``, and
``\cancelto`` macros to load the `cancel` extension (where they are
actually defined). Whichever is used first will cause the extension
to be loaded, redefining all four to their proper values. Note that
this may be better than loading the extension explicitly, since it
avoids loading the extra file on pages where these macros are *not*
used. The `sample autoloading macros
<http://cdn.mathjax.org/mathjax/latest/test/sample-autoload.html>`_
example page shows this in action.
The main extensions are described below.
@ -383,6 +410,9 @@ want to use the other macros that it defines. The `AMSsymbols` extension
is not loaded automatically, so you must include it explicitly if you want
to use the macros it defines.
Both extensions are included in all the combined configuration files
that load the TeX input processor.
Autobold
--------
@ -742,7 +772,20 @@ the paragraph, use
}
}
You may also wish to set the font family, as the default is "serif".
You may also wish to set the font family or other CSS values here.
If you are using a combined configuration file that loads the TeX
input processor, it will also load the `noErrors` extension
automatically. If you want to disable the `noErrors` extension so
that you receive the normal TeX error messages, use the following
configuration:
.. code-block:: javascript
TeX: { noErrors: { disabled: true } }
Any math that includes errors will be replaced by an error message
indicating what went wrong.
noUndefined
@ -777,6 +820,19 @@ default values set ``mathcolor`` to ``"red"``, but do not set any
other attributes. This example sets the background to a light pink,
and reduces the font size slightly.
If you are using a combined configuration file that loads the TeX
input processor, it will also load the `noUndefined` extension
automatically. If you want to disable the `noUndefined` extension so
that you receive the normal TeX error messages for undefined macros,
use the following configuration:
.. code-block:: javascript
TeX: { noUndefined: { disabled: true } }
Any math that includes an undefined control sequence name will be
replaced by an error message indicating what name was undefined.
Unicode support
---------------

View File

@ -4,7 +4,7 @@
<title>MathJax Example Page</title>
<!-- Copyright (c) 2012 Design Science, Inc. -->
<style>
li {margin-top: .25em}
li {margin-top: .2em}
</style>
</head>
<body>
@ -21,7 +21,12 @@ View the page source for any of these examples to see how they work.
<li><a href="sample-eqnum.html">Page of TeX equations with automatic numbering</a></li>
<li><a href="sample-eqnum.html">Page of TeX equations with equation references</a></li>
<p>
<li><a href="sample-signals.html">Page showing MathJax signals during page processing</a></li>
<li><a href="sample-macros.html">Example of defining TeX macros</a></li>
<li><a href="sample-autoload.html">Defining macros to autoload the extensions in
which they are implemented</a></li>
<p>
<li><a href="sample-all-at-once.html">Example of waiting until all the
math is typeset before displaying the page (avoids "flicker")</a></li>
<p>
<li><a href="sample-dynamic-steps.html">Showing an equation one step at a time</a></li>
<li><a href="sample-dynamic.html">Display an equation typed in by a user</a></li>
@ -29,6 +34,8 @@ View the page source for any of these examples to see how they work.
<p>
<li><a href="sample-loader.html">Loading MathJax into a page after it is loaded</a></li>
<li><a href="sample-loader-config.html">Loading MathJax dynamically with in-line configuration</a></li>
<p>
<li><a href="sample-signals.html">Page showing MathJax signals during page processing</a></li>
</ul>

View File

@ -0,0 +1,136 @@
<!DOCTYPE html>
<html>
<head>
<title>Wait Until MathJax is Finished Before Showing Page</title>
<!-- Copyright (c) 2012 Design Science, Inc. -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!--
|
| This shows how to prevent the page from being displayed until after
| MathJax has finished typesetting all the math. This avoids the
| "flicker" that occurs as source TeX code is removed from the page and
| then typeset. You probably don't want to do this on a page with lots
| of math.
|
|-->
<script type="text/x-mathjax-config">
//
// The document is hidden until MathJax is finished, then
// this function runs, making it visible again.
//
MathJax.Hub.Queue(function () {
document.getElementById("hide_page").style.visibility = "";
});
</script>
<script type="text/javascript" src="../MathJax.js?config=TeX-AMS_HTML-full"></script>
<style>
h1 {text-align:center}
h2 {
font-weight: bold;
background-color: #DDDDDD;
padding: .2em .5em;
margin-top: 1.5em;
border-top: 3px solid #666666;
border-bottom: 2px solid #999999;
}
</style>
</head>
<body>
<!--
|
| This DIV keeps the page blank until after the math is typeset.
|-->
<div id="hide_page" style="visibility:hidden">
<noscript>
<div style="color:#CC0000; text-align:center">
<b>Warning: <a href="http://www.mathjax.org/">MathJax</a>
requires JavaScript to process the mathematics on this page.<br />
If your browser supports JavaScript, be sure it is enabled.</b>
</div>
<hr>
</noscript>
<h1>Sample MathJax Equations</h1>
<blockquote>
<h2>The Lorenz Equations</h2>
<p>
\begin{align}
\dot{x} & = \sigma(y-x) \\
\dot{y} & = \rho x - y - xz \\
\dot{z} & = -\beta z + xy
\end{align}
</p>
<h2>The Cauchy-Schwarz Inequality</h2>
<p>\[
\left( \sum_{k=1}^n a_k b_k \right)^{\!\!2} \leq
\left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)
\]</p>
<h2>A Cross Product Formula</h2>
<p>\[
\mathbf{V}_1 \times \mathbf{V}_2 =
\begin{vmatrix}
\mathbf{i} & \mathbf{j} & \mathbf{k} \\
\frac{\partial X}{\partial u} & \frac{\partial Y}{\partial u} & 0 \\
\frac{\partial X}{\partial v} & \frac{\partial Y}{\partial v} & 0 \\
\end{vmatrix}
\]</p>
<h2>The probability of getting \(k\) heads when flipping \(n\) coins is:</h2>
<p>\[P(E) = {n \choose k} p^k (1-p)^{ n-k} \]</p>
<h2>An Identity of Ramanujan</h2>
<p>\[
\frac{1}{(\sqrt{\phi \sqrt{5}}-\phi) e^{\frac25 \pi}} =
1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}}
{1+\frac{e^{-8\pi}} {1+\ldots} } } }
\]</p>
<h2>A Rogers-Ramanujan Identity</h2>
<p>\[
1 + \frac{q^2}{(1-q)}+\frac{q^6}{(1-q)(1-q^2)}+\cdots =
\prod_{j=0}^{\infty}\frac{1}{(1-q^{5j+2})(1-q^{5j+3})},
\quad\quad \text{for $|q|<1$}.
\]</p>
<h2>Maxwell's Equations</h2>
<p>
\begin{align}
\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\
\nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
\nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
\nabla \cdot \vec{\mathbf{B}} & = 0
\end{align}
</p>
<h2>In-line Mathematics</h2>
<p>Finally, while display equations look good for a page of samples, the
ability to mix math and text in a paragraph is also important. This
expression \(\sqrt{3x-1}+(1+x)^2\) is an example of an inline equation. As
you see, MathJax equations can be used this way as well, without unduly
disturbing the spacing between lines.</p>
</blockquote>
</div>
</body>
</html>

48
test/sample-autoload.html Normal file
View File

@ -0,0 +1,48 @@
<!DOCTYPE html>
<html>
<head>
<title>Example of defining a macro that autoloads an extension</title>
<!-- Copyright (c) 2012 Design Science, Inc. -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!--
|
| This page shows how to define macros that autoloads an extension
| where those macros are implemented.
|
| The \cancel, \bcancel, \xcancel, and \cancelto macros are
| all defined within the cancel extension, so we tie these
| macros to the function that loads an extension, passing it
| the name of the extension to load.
|
|-->
<script type="text/x-mathjax-config">
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
MathJax.Hub.Insert(MathJax.InputJax.TeX.Definitions.macros,{
cancel: ["Extension","cancel"],
bcancel: ["Extension","cancel"],
xcancel: ["Extension","cancel"],
cancelto: ["Extension","cancel"]
});
});
</script>
<script type="text/javascript" src="../MathJax.js?config=TeX-AMS_HTML-full"></script>
</head>
<body>
<p>
This page makes <code>\cancel</code>, <code>\bcancel</code>,
<code>\xcancel</code>, and <code>\cancelto</code> all be defined so that
they will load the <code>cancel.js</code> extension when first used.
</p>
<p>
Here is the first usage: \(\cancel{x+1}\). It will cause the cancel
package to be loaded automatically.
</p>
</body>
</html>

64
test/sample-macros.html Normal file
View File

@ -0,0 +1,64 @@
<!DOCTYPE html>
<html>
<head>
<title>Example of defining a macro that autoloads an extension</title>
<!-- Copyright (c) 2012 Design Science, Inc. -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!--
|
| This page shows how to define macros in your configuration, or as part
| of the body of the page itself.
|
|-->
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
TeX: {
Macros: {
RR: '{\\bf R}', // a simple string replacement
bold: ['\\boldsymbol{#1}',1] // this macro has one parameter
}
}
});
</script>
<script type="text/javascript" src="../MathJax.js?config=TeX-AMS_HTML-full"></script>
</head>
<body>
<!--
|
| Here we use a math block that contains nothing but definitions in
| standard TeX format. It is enclosed in a DIV that doesn't display, so
| that there are no extra spaces generated by having the extra
| mathematics in the text.
|
| The first macro makes it easy to display vectors using \<x,y,z>
| the second uses \newcommand to create a macro
|
|-->
<div style="display:none">
\(
\def\<#1>{\left<#1\right>}
\newcommand{\CC}{\mathbf{C}}
\)
</div>
<p>
This page uses two different methods to define macros: either putting them
in JavaScript notation in the MathJax configuration, or in TeX notation in
the body of the document.
</p>
<p>Some math that used the definitions:
\[
f\colon\RR\to\RR^3 \hbox{ by } f(t)=\< t+1,{1\over 1+t^2}, \sqrt{t^2+1} >
\]
and
\[
\{\,z\in\CC \mid z^2 = \bold{\alpha}\,\}
\]
</body>
</html>