Skip to content

Commit 90f9948

Browse files
committed
Add more to TeX documentation, and include new examples
1 parent 39b78b1 commit 90f9948

File tree

9 files changed

+419
-7
lines changed

9 files changed

+419
-7
lines changed

docs/html/_sources/tex.txt

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,33 @@ load extensions into pages that didn't load them in their
322322
configurations (and prevents you from having to load all the
323323
extensions into all pages even if they aren't used).
324324

325+
It is also possible to create a macro that will autoload an extension
326+
when it is first used (under the assumption that the extension will
327+
redefine it to perform its true function). For example
328+
329+
.. code-block:: html
330+
331+
<script type="text/x-mathjax-config">
332+
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
333+
MathJax.Hub.Insert(MathJax.InputJax.TeX.Definitions.macros,{
334+
cancel: ["Extension","cancel"],
335+
bcancel: ["Extension","cancel"],
336+
xcancel: ["Extension","cancel"],
337+
cancelto: ["Extension","cancel"]
338+
});
339+
});
340+
</script>
341+
342+
would declare the ``\cancel``, ``\bcancel``, ``\xcancel``, and
343+
``\cancelto`` macros to load the `cancel` extension (where they are
344+
actually defined). Whichever is used first will cause the extension
345+
to be loaded, redefining all four to their proper values. Note that
346+
this may be better than loading the extension explicitly, since it
347+
avoids loading the extra file on pages where these macros are *not*
348+
used. The `sample autoloading macros
349+
<http://cdn.mathjax.org/mathjax/latest/test/sample-autoload.html>`_
350+
example page shows this in action.
351+
325352
The main extensions are described below.
326353

327354

@@ -383,6 +410,9 @@ want to use the other macros that it defines. The `AMSsymbols` extension
383410
is not loaded automatically, so you must include it explicitly if you want
384411
to use the macros it defines.
385412

413+
Both extensions are included in all the combined configuration files
414+
that load the TeX input processor.
415+
386416

387417
Autobold
388418
--------
@@ -742,7 +772,20 @@ the paragraph, use
742772
}
743773
}
744774

745-
You may also wish to set the font family, as the default is "serif".
775+
You may also wish to set the font family or other CSS values here.
776+
777+
If you are using a combined configuration file that loads the TeX
778+
input processor, it will also load the `noErrors` extension
779+
automatically. If you want to disable the `noErrors` extension so
780+
that you receive the normal TeX error messages, use the following
781+
configuration:
782+
783+
.. code-block:: javascript
784+
785+
TeX: { noErrors: { disabled: true } }
786+
787+
Any math that includes errors will be replaced by an error message
788+
indicating what went wrong.
746789

747790

748791
noUndefined
@@ -777,6 +820,19 @@ default values set ``mathcolor`` to ``"red"``, but do not set any
777820
other attributes. This example sets the background to a light pink,
778821
and reduces the font size slightly.
779822

823+
If you are using a combined configuration file that loads the TeX
824+
input processor, it will also load the `noUndefined` extension
825+
automatically. If you want to disable the `noUndefined` extension so
826+
that you receive the normal TeX error messages for undefined macros,
827+
use the following configuration:
828+
829+
.. code-block:: javascript
830+
831+
TeX: { noUndefined: { disabled: true } }
832+
833+
Any math that includes an undefined control sequence name will be
834+
replaced by an error message indicating what name was undefined.
835+
780836

781837
Unicode support
782838
---------------

docs/html/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ <h2>Reference Pages<a class="headerlink" href="#reference-pages" title="Permalin
122122
</li>
123123
</ul>
124124
<hr class="docutils" />
125-
<p>This version of the documentation was built February 20, 2012.</p>
125+
<p>This version of the documentation was built February 22, 2012.</p>
126126
</div>
127127
</div>
128128

docs/html/searchindex.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/html/tex.html

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,29 @@ <h2>TeX and LaTeX in HTML documents<a class="headerlink" href="#tex-and-latex-in
311311
load extensions into pages that didn&#8217;t load them in their
312312
configurations (and prevents you from having to load all the
313313
extensions into all pages even if they aren&#8217;t used).</p>
314+
<p>It is also possible to create a macro that will autoload an extension
315+
when it is first used (under the assumption that the extension will
316+
redefine it to perform its true function). For example</p>
317+
<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>
318+
<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>
319+
<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>
320+
<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>
321+
<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>
322+
<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>
323+
<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>
324+
<span class="p">});</span>
325+
<span class="p">});</span>
326+
<span class="nt">&lt;/script&gt;</span>
327+
</pre></div>
328+
</div>
329+
<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
330+
<tt class="docutils literal"><span class="pre">\cancelto</span></tt> macros to load the <cite>cancel</cite> extension (where they are
331+
actually defined). Whichever is used first will cause the extension
332+
to be loaded, redefining all four to their proper values. Note that
333+
this may be better than loading the extension explicitly, since it
334+
avoids loading the extra file on pages where these macros are <em>not</em>
335+
used. The <a class="reference external" href="http://cdn.mathjax.org/mathjax/latest/test/sample-autoload.html">sample autoloading macros</a>
336+
example page shows this in action.</p>
314337
<p>The main extensions are described below.</p>
315338
<div class="section" id="action">
316339
<h3>Action<a class="headerlink" href="#action" title="Permalink to this headline"></a></h3>
@@ -366,6 +389,8 @@ <h3>AMSmath and AMSsymbols<a class="headerlink" href="#amsmath-and-amssymbols" t
366389
want to use the other macros that it defines. The <cite>AMSsymbols</cite> extension
367390
is not loaded automatically, so you must include it explicitly if you want
368391
to use the macros it defines.</p>
392+
<p>Both extensions are included in all the combined configuration files
393+
that load the TeX input processor.</p>
369394
</div>
370395
<div class="section" id="autobold">
371396
<h3>Autobold<a class="headerlink" href="#autobold" title="Permalink to this headline"></a></h3>
@@ -687,7 +712,17 @@ <h3>noErrors<a class="headerlink" href="#noerrors" title="Permalink to this head
687712
<span class="p">}</span>
688713
</pre></div>
689714
</div>
690-
<p>You may also wish to set the font family, as the default is &#8220;serif&#8221;.</p>
715+
<p>You may also wish to set the font family or other CSS values here.</p>
716+
<p>If you are using a combined configuration file that loads the TeX
717+
input processor, it will also load the <cite>noErrors</cite> extension
718+
automatically. If you want to disable the <cite>noErrors</cite> extension so
719+
that you receive the normal TeX error messages, use the following
720+
configuration:</p>
721+
<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>
722+
</pre></div>
723+
</div>
724+
<p>Any math that includes errors will be replaced by an error message
725+
indicating what went wrong.</p>
691726
</div>
692727
<div class="section" id="noundefined">
693728
<h3>noUndefined<a class="headerlink" href="#noundefined" title="Permalink to this headline"></a></h3>
@@ -716,6 +751,16 @@ <h3>noUndefined<a class="headerlink" href="#noundefined" title="Permalink to thi
716751
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
717752
other attributes. This example sets the background to a light pink,
718753
and reduces the font size slightly.</p>
754+
<p>If you are using a combined configuration file that loads the TeX
755+
input processor, it will also load the <cite>noUndefined</cite> extension
756+
automatically. If you want to disable the <cite>noUndefined</cite> extension so
757+
that you receive the normal TeX error messages for undefined macros,
758+
use the following configuration:</p>
759+
<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>
760+
</pre></div>
761+
</div>
762+
<p>Any math that includes an undefined control sequence name will be
763+
replaced by an error message indicating what name was undefined.</p>
719764
</div>
720765
<div class="section" id="unicode-support">
721766
<h3>Unicode support<a class="headerlink" href="#unicode-support" title="Permalink to this headline"></a></h3>

docs/source/tex.rst

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,33 @@ load extensions into pages that didn't load them in their
322322
configurations (and prevents you from having to load all the
323323
extensions into all pages even if they aren't used).
324324

325+
It is also possible to create a macro that will autoload an extension
326+
when it is first used (under the assumption that the extension will
327+
redefine it to perform its true function). For example
328+
329+
.. code-block:: html
330+
331+
<script type="text/x-mathjax-config">
332+
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
333+
MathJax.Hub.Insert(MathJax.InputJax.TeX.Definitions.macros,{
334+
cancel: ["Extension","cancel"],
335+
bcancel: ["Extension","cancel"],
336+
xcancel: ["Extension","cancel"],
337+
cancelto: ["Extension","cancel"]
338+
});
339+
});
340+
</script>
341+
342+
would declare the ``\cancel``, ``\bcancel``, ``\xcancel``, and
343+
``\cancelto`` macros to load the `cancel` extension (where they are
344+
actually defined). Whichever is used first will cause the extension
345+
to be loaded, redefining all four to their proper values. Note that
346+
this may be better than loading the extension explicitly, since it
347+
avoids loading the extra file on pages where these macros are *not*
348+
used. The `sample autoloading macros
349+
<http://cdn.mathjax.org/mathjax/latest/test/sample-autoload.html>`_
350+
example page shows this in action.
351+
325352
The main extensions are described below.
326353

327354

@@ -383,6 +410,9 @@ want to use the other macros that it defines. The `AMSsymbols` extension
383410
is not loaded automatically, so you must include it explicitly if you want
384411
to use the macros it defines.
385412

413+
Both extensions are included in all the combined configuration files
414+
that load the TeX input processor.
415+
386416

387417
Autobold
388418
--------
@@ -742,7 +772,20 @@ the paragraph, use
742772
}
743773
}
744774
745-
You may also wish to set the font family, as the default is "serif".
775+
You may also wish to set the font family or other CSS values here.
776+
777+
If you are using a combined configuration file that loads the TeX
778+
input processor, it will also load the `noErrors` extension
779+
automatically. If you want to disable the `noErrors` extension so
780+
that you receive the normal TeX error messages, use the following
781+
configuration:
782+
783+
.. code-block:: javascript
784+
785+
TeX: { noErrors: { disabled: true } }
786+
787+
Any math that includes errors will be replaced by an error message
788+
indicating what went wrong.
746789

747790

748791
noUndefined
@@ -777,6 +820,19 @@ default values set ``mathcolor`` to ``"red"``, but do not set any
777820
other attributes. This example sets the background to a light pink,
778821
and reduces the font size slightly.
779822

823+
If you are using a combined configuration file that loads the TeX
824+
input processor, it will also load the `noUndefined` extension
825+
automatically. If you want to disable the `noUndefined` extension so
826+
that you receive the normal TeX error messages for undefined macros,
827+
use the following configuration:
828+
829+
.. code-block:: javascript
830+
831+
TeX: { noUndefined: { disabled: true } }
832+
833+
Any math that includes an undefined control sequence name will be
834+
replaced by an error message indicating what name was undefined.
835+
780836

781837
Unicode support
782838
---------------

test/examples.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<title>MathJax Example Page</title>
55
<!-- Copyright (c) 2012 Design Science, Inc. -->
66
<style>
7-
li {margin-top: .25em}
7+
li {margin-top: .2em}
88
</style>
99
</head>
1010
<body>
@@ -21,14 +21,21 @@ <h1>MathJax Example Pages</h1>
2121
<li><a href="sample-eqnum.html">Page of TeX equations with automatic numbering</a></li>
2222
<li><a href="sample-eqnum.html">Page of TeX equations with equation references</a></li>
2323
<p>
24-
<li><a href="sample-signals.html">Page showing MathJax signals during page processing</a></li>
24+
<li><a href="sample-macros.html">Example of defining TeX macros</a></li>
25+
<li><a href="sample-autoload.html">Defining macros to autoload the extensions in
26+
which they are implemented</a></li>
27+
<p>
28+
<li><a href="sample-all-at-once.html">Example of waiting until all the
29+
math is typeset before displaying the page (avoids "flicker")</a></li>
2530
<p>
2631
<li><a href="sample-dynamic-steps.html">Showing an equation one step at a time</a></li>
2732
<li><a href="sample-dynamic.html">Display an equation typed in by a user</a></li>
2833
<li><a href="sample-dynamic-2.html">Preview text containing math typed in by a user</a></li>
2934
<p>
3035
<li><a href="sample-loader.html">Loading MathJax into a page after it is loaded</a></li>
3136
<li><a href="sample-loader-config.html">Loading MathJax dynamically with in-line configuration</a></li>
37+
<p>
38+
<li><a href="sample-signals.html">Page showing MathJax signals during page processing</a></li>
3239

3340
</ul>
3441

0 commit comments

Comments
 (0)