JsMath: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
__TOC__ |
|||
⚫ | |||
⚫ | |||
⚫ | |||
Reference instructions: |
Reference instructions: |
||
Line 7: | Line 7: | ||
* [http://www.math.union.edu/~dpvc/jsMath/authors/morefonts.html Installing extra fonts] |
* [http://www.math.union.edu/~dpvc/jsMath/authors/morefonts.html Installing extra fonts] |
||
== Client-Side Install == |
|||
# Install the '''standard fonts'''<br/> |
|||
⚫ | |||
⚫ | |||
⚫ | |||
: The packages are found [http://www.math.union.edu/~dpvc/jsMath/download/extra-fonts/welcome.html here]. To install them, create a directory '''<tt>fonts</tt>''' in jsmath directory, and unzip them there, i.e. you should end up with 2 directories named <tt>./jsmath/fonts/msam10</tt> and <tt>./jsmath/fonts/msbm10</tt>. |
|||
# Download all '''extra fonts''' ([http://www.math.union.edu/~dpvc/jsMath/download/extra-fonts/welcome.html from here]), and install them on your system. Typically not all fonts are needed ('''msam10.ttf''' and '''msbm10.ttf''' are the most frequently used ones) but since you never know, better install them all. |
|||
== Server-Side Install == |
|||
<ol> |
|||
* Install the '''standard fonts'''. |
|||
<li>Install '''jsmath''' main package.</li> |
|||
⚫ | |||
⚫ | |||
⚫ | |||
The packages are found [http://www.math.union.edu/~dpvc/jsMath/download/extra-fonts/welcome.html here]. To install them, create a directory '''<tt>fonts</tt>''' in jsmath directory, and unzip them there, i.e. you should end up with 2 directories named <tt>./jsmath/fonts/msam10</tt> and <tt>./jsmath/fonts/msbm10</tt>. |
|||
</li> |
|||
</ol> |
|||
== Install on MediaWiki == |
== Install on MediaWiki == |
||
Line 25: | Line 28: | ||
* [http://www.mediawiki.org/wiki/Extension:JsMath Mediawiki extension JsMath] |
* [http://www.mediawiki.org/wiki/Extension:JsMath Mediawiki extension JsMath] |
||
=== |
=== Install JsMath === |
||
Install jsMath in <tt>/miki/jsmath</tt>. See [http://www.math.union.edu/~dpvc/jsmath/authors/installation.html detailed instructions] |
|||
* Install the following jsMath '''extra fonts''' package (in <tt>/miki/jsmath/fonts) : |
|||
=== Configure jsMath === |
|||
* Edit the file <tt>/miki/jsmath/easy/load.js</tt>: |
|||
[http://www.math.union.edu/~dpvc/jsmath/authors/easy-config.html Detailed instructions] are available from the homepage of jsMath. |
|||
⚫ | |||
This extension assumes that jsMath is configured through the file <tt>easy/load.js</tt>. |
|||
//... |
|||
<ol> |
|||
<li>jsMath can find out the root directory where it is installed, but it doesn't hurt to help it a bit: |
|||
⚫ | |||
root: "/miki/jsmath", |
root: "/miki/jsmath", |
||
</source> |
|||
//... |
|||
</li> |
|||
<li>Increase a bit the size of formulae: |
|||
<source lang="javascript" enclose="prevalid"> |
|||
scale: 130, |
scale: 130, |
||
</source> |
|||
//... |
|||
</li> |
|||
<li>Turn off jsMath's special interpretation of <tt>\(</tt>, <tt>\[</tt>, <tt>$</tt> and <tt>$$</tt> as math mode delimiters. |
|||
<source lang="javascript" enclose="prevalid"> |
|||
processSlashParens: 0, // process \(...\) in text? |
processSlashParens: 0, // process \(...\) in text? |
||
processSlashBrackets: 0, // process \[...\] in text? |
processSlashBrackets: 0, // process \[...\] in text? |
||
Line 43: | Line 56: | ||
doubleDollarsAreInLine: 0, // make $$...$$ be in-line math? |
doubleDollarsAreInLine: 0, // make $$...$$ be in-line math? |
||
allowDisableTag: 1, // allow ID="tex2math_off" to disable tex2math? |
allowDisableTag: 1, // allow ID="tex2math_off" to disable tex2math? |
||
</source> |
|||
//... |
|||
</li> |
|||
⚫ | |||
<li>Load AMSmath and some extra fonts. Notice that you also need to install the extra fonts <tt>cmbsy10</tt>, <tt>cmmib10</tt>, <tt>msam10</tt> and <tt>msbm10</tt> on the server, as outlined on this [http://www.math.union.edu/~dpvc/jsmath/authors/morefonts.html page]. |
|||
<source lang="javascript" enclose="prevalid"> |
|||
⚫ | |||
"extensions/boldsymbol.js", "extensions/moreArrows.js"], |
"extensions/boldsymbol.js", "extensions/moreArrows.js"], |
||
//... |
|||
loadFonts: ["cmmib10", "cmbsy10"], |
loadFonts: ["cmmib10", "cmbsy10"], |
||
</source> |
|||
//... |
|||
</li> |
|||
<li>Finally, we disable the use of image fonts to save space on the server: |
|||
<source lang="php" enclose="prevalid"> |
|||
noImageFonts: 1 |
noImageFonts: 1 |
||
</source> |
</source> |
||
</ol> |
|||
⚫ | |||
=== |
=== Install Extra Fonts === |
||
Install the following jsMath '''extra fonts''' package (in <tt>/miki/jsmath/fonts</tt>) : '''cmbsy10''', '''cmib10''', '''msam10''', '''msbm10'''. Keep only the files '''def.js''' since we don't use image fonts. |
|||
⚫ | |||
⚫ | |||
=== Configure the extension === |
|||
Edit <tt>/miki/LocalSettings.php</tt> as follows: |
|||
<ol> |
|||
<li>TeX support '''must''' be enabled (see this [[w:Manual:Enable TeX|page]]), but it is '''not mandatory''' to compile the render engine. Only setting this variable is enough: |
|||
<source lang="php" enclose="prevalid"> |
|||
$wgUseTeX = true; |
|||
</source> |
|||
</li> |
|||
<li>Then you add the following lines at the end of the file <tt>/miki/LocalSettings.php</tt>. This selects jsMath as the default rendering engine for new users, and then loads the extension. |
|||
<source lang="php" enclose="prevalid"> |
|||
$wgJsMathDefault = 1; |
|||
$wgJsMathRoot = "/miki/jsmath"; |
|||
require_once( "$IP/extensions/JsMath/JsMath.php" ); |
|||
</source> |
|||
See the [http://www.mediawiki.org/wiki/Extension:JsMath Mediawiki extension doc] to enable plugins by default (like <tt>smallFonts.js</tt>). |
|||
</li> |
|||
<li>For each user in MediaWiki, '''select jsMath''' as method to render math formulae. For new user, this shall be done automatically.</li> |
|||
</ol> |
|||
== Troubleshoot == |
== Troubleshoot == |
||
Line 61: | Line 101: | ||
== Examples == |
== Examples == |
||
Some text before <math>\textstyle{a_i^e}</math> and after |
* Some text before <math>\textstyle{a_i^e}</math> and after |
||
Some text before <math>\displaystyle{a_i^e}</math> and after |
* Some text before <math>\displaystyle{a_i^e}</math> and after |
||
Some text before <span class="math">a_i^e</span> and after |
* Some text before <span class="math">a_i^e</span> and after |
||
Some text before <div class="math">a_i^e</div> and after |
* Some text before <div class="math">a_i^e</div> and after |
||
* Some text before <math>\textstyle{ \sum_{i=1}^n(x_i-\overline x) (y_i-\overline y) }</math> and after |
|||
* Some text before <math>\displaystyle{ \sum_{i=1}^n(x_i-\overline x) (y_i-\overline y) }</math> and after |
|||
* Some text before <span class="math">\sum_{i=1}^n(x_i-\overline x) (y_i-\overline y)</span> and after |
|||
* Some text before <div class="math">\sum_{i=1}^n(x_i-\overline x) (y_i-\overline y)</div> and after |
Revision as of 18:19, 6 January 2010
This page is dedicated to jsMath, a javascript that allows to render LaTeX formula in HTML pages with very high output quality and that works across multiple browsers on Windows, Linux and Mac.
Reference instructions:
Client-Side Install
- Install the standard fonts
- Download all extra fonts (from here), and install them on your system. Typically not all fonts are needed (msam10.ttf and msbm10.ttf are the most frequently used ones) but since you never know, better install them all.
Server-Side Install
- Install jsmath main package.
- Install extra fonts package for fonts msam10 and msbm10 (these fonts are required for extension AMSsymbols, which is frequently used).
The packages are found here. To install them, create a directory fonts in jsmath directory, and unzip them there, i.e. you should end up with 2 directories named ./jsmath/fonts/msam10 and ./jsmath/fonts/msbm10.
Install on MediaWiki
On MediaWiki, there exists an extension that ease the use of jsMath. We describe here how the extension is installed on this wiki.
Reference information:
Install JsMath
Install jsMath in /miki/jsmath. See detailed instructions
Configure jsMath
Detailed instructions are available from the homepage of jsMath. This extension assumes that jsMath is configured through the file easy/load.js.
- jsMath can find out the root directory where it is installed, but it doesn't hurt to help it a bit:
root: "/miki/jsmath",
- Increase a bit the size of formulae:
scale: 130,
- Turn off jsMath's special interpretation of \(, \[, $ and $$ as math mode delimiters.
processSlashParens: 0, // process \(...\) in text? processSlashBrackets: 0, // process \[...\] in text? processDoubleDollars: 0, // process $$...$$ in text? processSingleDollars: 0, // process $...$ in text? processLaTeXenvironments: 0, // process \begin{xxx}...\end{xxx} outside math mode? fixEscapedDollars: 0, // convert \$ to $ outside of math mode? doubleDollarsAreInLine: 0, // make $$...$$ be in-line math? allowDisableTag: 1, // allow ID="tex2math_off" to disable tex2math?
- Load AMSmath and some extra fonts. Notice that you also need to install the extra fonts cmbsy10, cmmib10, msam10 and msbm10 on the server, as outlined on this page.
loadFiles: ["extensions/AMSmath.js", "extensions/AMSsymbols.js", "extensions/boldsymbol.js", "extensions/moreArrows.js"], loadFonts: ["cmmib10", "cmbsy10"],
- Finally, we disable the use of image fonts to save space on the server:
noImageFonts: 1
Install Extra Fonts
Install the following jsMath extra fonts package (in /miki/jsmath/fonts) : cmbsy10, cmib10, msam10, msbm10. Keep only the files def.js since we don't use image fonts.
Install the extension
Create the directory /miki/extensions/JsMath and save the files there (2 files from here: JsMath.i18n.php and JsMath.php).
Configure the extension
Edit /miki/LocalSettings.php as follows:
- TeX support must be enabled (see this page), but it is not mandatory to compile the render engine. Only setting this variable is enough:
$wgUseTeX = true;
- Then you add the following lines at the end of the file /miki/LocalSettings.php. This selects jsMath as the default rendering engine for new users, and then loads the extension.
$wgJsMathDefault = 1; $wgJsMathRoot = "/miki/jsmath"; require_once( "$IP/extensions/JsMath/JsMath.php" );
See the Mediawiki extension doc to enable plugins by default (like smallFonts.js).
- For each user in MediaWiki, select jsMath as method to render math formulae. For new user, this shall be done automatically.
Troubleshoot
- I get the error message "unknown control sequence \msbm" when using
\mathbb{...}
(blackboard bold).
- Most probably this is because jsmath cannot find the font definition file at ./jsmath/fonts/msbm10/def.js on the server side (see [1]).
\mathbb
uses the fonts msbm, and to work properly, the author package msbm10.zip (see here) must be unzipped in directory ./jsmath/fonts/. Also for best rendering the msbm10 truetype font should be installed on the client side.
Examples
- Some text before <math>\textstyle{a_i^e}</math> and after
- Some text before <math>\displaystyle{a_i^e}</math> and after
- Some text before a_i^e and after
- Some text before a_i^eand after
- Some text before <math>\textstyle{ \sum_{i=1}^n(x_i-\overline x) (y_i-\overline y) }</math> and after
- Some text before <math>\displaystyle{ \sum_{i=1}^n(x_i-\overline x) (y_i-\overline y) }</math> and after
- Some text before \sum_{i=1}^n(x_i-\overline x) (y_i-\overline y) and after
- Some text before \sum_{i=1}^n(x_i-\overline x) (y_i-\overline y)and after