Since version 3.1, jsMath has the ability to automatically load extensions when they are used by the mathematics on a particular page. Certain lesser-used functions (like the double-clicking off mathematics to view the TeX source code, and the Loading Extensions in jsMath
\mathchoicemacro) have been removed from the basejsMath.jsfile and moved to extensions in order to speed up the initial download of jsMath. You don't need to do anything special to use these extensions, since they will be loaded automatically when needed; you should not even be aware that they are extensions.The ability to load extensions at run time should make it easier to add features to jsMath. For these (non-standard) extensions, you may need to load a small definition file to declare the macros for the extension so that they will load the full package when they are used. You can load this definition file in one of two ways. The first is via the
jsMath.Extension.Require()command; for example:<SCRIPT> jsMath.Extension.Require("moreArrows"); </SCRIPT>which will load thejsMath/extensions/moreArrows.jsfile, which defines new macros for handling arrows that provide for labels above and below them.If you are using the
easy/load.jsfile rather than loadingjsMath.jsby hand, you can load extensions by placing their names in theloadFileslist. For example:loadFiles: ["extensions/moreArrows.js"],Alternatively, you can use the\require{}macro within a mathematical formula to load an extension:<SPAN CLASS="math"> \require{moreArrows} \xrightarrow{f} </SPAN>This loads thejsMath/extensions/moreArrows.jsfile and then uses one of the macros it defines. This makes it possible to load extensions into jsMath even when you can't enter SCRIPT tags into the web page (e.g., when you are using a content-management system).One important type of extension to load is the definition file for a font that is not one of the six built-in fonts. If you use the
\charmacro to access a font that has not been loaded, jsMath will load its definition file automatically.
Defining Your Own Extensions
Three things can trigger jsMath to load an extension: a macro, a LaTeX environment, or a font reference. If you want
\xrightarrowto autoload themoreArrows.jsextension, include<SCRIPT> jsMath.Extension.Macro('xrightarrow','moreArrows'); </SCRIPT>Note that themoreArrows.jsfile should redefine\xrightarrowto do whatever it is really supposed to do (otherwise you will receive an error message after the extension is loaded).Similarly, to have a macro load a font, use
<SCRIPT> jsMath.Extension.Font('bbold'); </SCRIPT>so that\bboldwill automatically load thebboldfont definition file (see the page on creating your own fonts for information about the fonts definition files). If you include definitions like<SCRIPT> jsMath.Macro('boxplus','\\mathbin{\\char{msam10}{1}}'); </SCRIPT>will cause\boxplusto autoload themsam10file and then make a binary operator out of the character at position 1 in that font.JsMath also has the ability to load a font based on a mathchardef definition. This is convenient if you are going to define control sequences to access many characters in a font (as is done, for example, in the AMSsymbols extension). In this case, you issue a command like the following:
<SCRIPT> jsMath.Extension.MathChar('msam10',{ boxminus: [2,0x0C], boxtimes: [2,0x02], boxdot: [2,0x00], boxplus: [2,0x01] </SCRIPT>which defines four control sequences referring to characters in themsam10font; the font will be loaded automatically whenever one of these four control sequences is used. The two values assigned to each represent the TeX math class (see the TeXbook p.154), and a character position within the font. In this example, all four are binary operators (class 2) and the character positions are given as hexadecimal constants.Finally, a LaTeX environment can be tied to a file to be autoloaded using the command:
<SCRIPT> jsMath.Extension.LaTeX('picture','picture-environment'); </SCRIPT>This would cause\begin{picture}to loadjsMath/extensions/picture-environment.js(this is just an example; that extension doesn't exist yet). As with macros, the extension file should define what the given environment should actually do.
|
|