# If you use the jsMath control panel, it will add parameters to the URL, which interfere with TiddlyWiki's save function. The jsMath options are stored in a cookie, so after setting them it is safe to reload your tiddlywiki file. (A fix for this has been submitted, and hopefully will be in tiddlywiki 2.0.4)\n# The font browser font size and alignment does not always match the math. (anyone have an idea to fix this?)\n# The use of certain math characters (like \s\ssqrt) causes firefox 1.5.0.1 to crash. Firefox 1.5 does not have this problem, nor do more recent nightly builds of firefox from mozilla.org. So it seems this is a firefox bug and is already fixed. (Though if you are able to discover a workaround, please let me know!)
[[Plugin: jsMath]]
<<newTiddler>>\n----\n[[Plugin: jsMath]]\n[[Plugin: arXiv Links]]\n[[Plugin: Scientific Notation]]\n[[Bugs]]\nStyleSheet
/***\n|Name|Plugin: Scientific Notation|\n|Created by|BobMcElrath|\n|Email|my first name at my last name dot org|\n|Location|http://bob.mcelrath.org/tiddlyjsmath-2.0.3.html|\n|Version|1.0|\n|Requires|[[TiddlyWiki|http://www.tiddlywiki.com]] &ge; 2.0.3, [[jsMath|http://www.math.union.edu/~dpvc/jsMath/]] &ge; 3.0, [[Plugin: jsMath]]|\n!Description\nThis plugin will render numbers expressed in scientific notation, such as {{{3.5483e12}}} using the jsMath plugin to display it in an intuitive way such as 3.5483e12. You may customize the number of significant figures displayed, as well as "normalize" numbers so that {{{47392.387e9}}} is displayed as 47392.387e9.\n!Installation\nInstall the Requirements, above, add this tiddler to your tiddlywiki, and give it the {{{systemConfig}}} tag.\n!History\n* 1-Feb-06, version 1.0, Initial release\n!Code\n***/\n//{{{\nconfig.formatters.push({\n name: "scientificNotation",\n match: "\s\sb[0-9]+\s\s.[0-9]+[eE][+-]?[0-9]+\s\sb",\n element: "span",\n className: "math",\n normalize: true, // set to 'true' to convert numbers to X.XXX \stimes 10^{y}\n sigfigs: 3, // with this many digits in the mantissa\n handler: function(w) {\n var snRegExp = new RegExp("\s\sb([0-9]+(?:\s\s.[0-9]+)?)[eE]([-0-9+]+)\s\sb");\n var mymatch = snRegExp.exec(w.matchText);\n var mantissa = mymatch[1];\n var exponent = parseInt(mymatch[2]);\n // normalize the number.\n if(this.normalize) {\n mantissa = parseFloat(mantissa);\n while(mantissa > 10.0) {\n mantissa = mantissa / 10.0;\n exponent++; \n }\n while(mantissa < 1.0) {\n mantissa = mantissa * 10.0;\n exponent--;\n }\n var sigfigsleft = this.sigfigs;\n mantissa = parseInt(mantissa) + "." + (Math.round(Math.pow(10,this.sigfigs-1)*mantissa)+"").substr(1,this.sigfigs-1);\n }\n var e = document.createElement(this.element);\n e.className = this.className;\n if(exponent == 0) {\n e.appendChild(document.createTextNode(mantissa));\n } else {\n e.appendChild(document.createTextNode(mantissa + "\s\stimes 10^{" + exponent + "}"));\n }\n w.output.appendChild(e);\n }\n});\n//}}}
/***\n|Name|Plugin: arXiv Links|\n|Created by|BobMcElrath|\n|Email|my first name at my last name dot org|\n|Location|http://bob.mcelrath.org/tiddlyjsmath-2.0.3.html|\n|Version|1.0|\n|Requires|[[TiddlyWiki|http://www.tiddlywiki.com]] &ge; 2.0.3|\n!Description\nThis formatting plugin will render links to the [[arXiv|http://www.arxiv.org]] preprint system. If you type a paper reference such as hep-ph/0509024, it will be rendered as an external link to the abstract of that paper.\n!Installation\nAdd this tiddler to your tiddlywiki, and give it the {{{systemConfig}}} tag.\n!History\n* 1-Feb-06, version 1.0, Initial release\n!Code\n***/\n//{{{\nconfig.formatters.push({\n name: "arXivLinks",\n match: "\s\sb(?:astro-ph|cond-mat|hep-ph|hep-th|hep-lat|gr-qc|nucl-ex|nucl-th|quant-ph|(?:cs|math|nlin|physics|q-bio)(?:\s\s.[A-Z]{2})?)/[0-9]{7}\s\sb",\n element: "a",\n handler: function(w) {\n var e = createExternalLink(w.output, "http://arxiv.org/abs/"+w.matchText);\n e.target = "_blank"; // open in new window\n w.outputText(e,w.matchStart,w.nextMatch);\n }\n});\n//}}}\n
/***\n|Name|Plugin: jsMath|\n|Created by|BobMcElrath|\n|Email|my first name at my last name dot org|\n|Location|http://bob.mcelrath.org/tiddlyjsmath.html|\n|Version|1.5.1|\n|Requires|[[TiddlyWiki|http://www.tiddlywiki.com]] &ge; 2.0.3, [[jsMath|http://www.math.union.edu/~dpvc/jsMath/]] &ge; 3.0|\n!Description\nLaTeX is the world standard for specifying, typesetting, and communicating mathematics among scientists, engineers, and mathematicians. For more information about LaTeX itself, visit the [[LaTeX Project|http://www.latex-project.org/]]. This plugin typesets math using [[jsMath|http://www.math.union.edu/~dpvc/jsMath/]], which is an implementation of the TeX math rules and typesetting in javascript, for your browser. Notice the small button in the lower right corner which opens its control panel.\n!Installation\nIn addition to this plugin, you must also [[install jsMath|http://www.math.union.edu/~dpvc/jsMath/download/jsMath.html]] on the same server as your TiddlyWiki html file. If you're using TiddlyWiki without a web server, then the jsMath directory must be placed in the same location as the TiddlyWiki html file.\n\nI also recommend modifying your StyleSheet use serif fonts that are slightly larger than normal, so that the math matches surrounding text, and \s\ssmall fonts are not unreadable (as in exponents and subscripts).\n{{{\n.viewer {\n line-height: 125%;\n font-family: serif;\n font-size: 12pt;\n}\n}}}\n\nIf you had used a previous version of [[Plugin: jsMath]], it is no longer necessary to edit the main tiddlywiki.html file to add the jsMath <script> tag. [[Plugin: jsMath]] now uses ajax to load jsMath.\n!History\n* 11-Nov-05, version 1.0, Initial release\n* 22-Jan-06, version 1.1, updated for ~TW2.0, tested with jsMath 3.1, editing tiddlywiki.html by hand is no longer necessary.\n* 24-Jan-06, version 1.2, fixes for Safari, Konqueror\n* 27-Jan-06, version 1.3, improved error handling, detect if ajax was already defined (used by ZiddlyWiki)\n* 12-Jul-06, version 1.4, fixed problem with not finding image fonts\n* 26-Feb-07, version 1.5, fixed problem with Mozilla "unterminated character class".\n* 27-Feb-07, version 1.5.1, Runs compatibly with TW 2.1.0+, by Bram Chen\n!Examples\n|!Source|!Output|h\n|{{{The variable $x$ is real.}}}|The variable $x$ is real.|\n|{{{The variable \s(y\s) is complex.}}}|The variable \s(y\s) is complex.|\n|{{{This \s[\sint_a^b x = \sfrac{1}{2}(b^2-a^2)\s] is an easy integral.}}}|This \s[\sint_a^b x = \sfrac{1}{2}(b^2-a^2)\s] is an easy integral.|\n|{{{This $$\sint_a^b \ssin x = -(\scos b - \scos a)$$ is another easy integral.}}}|This $$\sint_a^b \ssin x = -(\scos b - \scos a)$$ is another easy integral.|\n|{{{Block formatted equations may also use the 'equation' environment \sbegin{equation} \sint \stan x = -\sln \scos x \send{equation} }}}|Block formatted equations may also use the 'equation' environment \sbegin{equation} \sint \stan x = -\sln \scos x \send{equation}|\n|{{{Equation arrays are also supported \sbegin{eqnarray} a &=& b \s\s c &=& d \send{eqnarray} }}}|Equation arrays are also supported \sbegin{eqnarray} a &=& b \s\s c &=& d \send{eqnarray} |\n|{{{I spent \s$7.38 on lunch.}}}|I spent \s$7.38 on lunch.|\n|{{{I had to insert a backslash (\s\s) into my document}}}|I had to insert a backslash (\s\s) into my document|\n!Code\n***/\n//{{{\n\n// AJAX code adapted from http://timmorgan.org/mini\n// This is already loaded by ziddlywiki...\nif(typeof(window["ajax"]) == "undefined") {\n ajax = {\n x: function(){try{return new ActiveXObject('Msxml2.XMLHTTP')}catch(e){try{return new ActiveXObject('Microsoft.XMLHTTP')}catch(e){return new XMLHttpRequest()}}},\n gets: function(url){var x=ajax.x();x.open('GET',url,false);x.send(null);return x.responseText}\n }\n}\n\n// Load jsMath\njsMath = {\n Setup: {inited: 1}, // don't run jsMath.Setup.Body() yet\n Autoload: {root: new String(document.location).replace(/[^\s/]*$/,'jsMath/')} // URL to jsMath directory, change if necessary\n};\nvar jsMathstr;\ntry {\n jsMathstr = ajax.gets(jsMath.Autoload.root+"jsMath.js");\n} catch(e) {\n alert("jsMath was not found: you must place the 'jsMath' directory in the same place as this file. "\n +"The error was:\sn"+e.name+": "+e.message);\n throw(e); // abort eval\n}\ntry {\n window.eval(jsMathstr);\n} catch(e) {\n alert("jsMath failed to load. The error was:\sn"+e.name + ": " + e.message + " on line " + e.lineNumber);\n}\njsMath.Setup.inited=0; // allow jsMath.Setup.Body() to run again\n\n// Define wikifers for latex\nconfig.formatterHelpers.mathFormatHelper = function(w) {\n var e = document.createElement(this.element);\n e.className = this.className;\n var endRegExp = new RegExp(this.terminator, "mg");\n endRegExp.lastIndex = w.matchStart+w.matchLength;\n var matched = endRegExp.exec(w.source);\n if(matched) {\n var txt = w.source.substr(w.matchStart+w.matchLength, \n matched.index-w.matchStart-w.matchLength);\n if(this.keepdelim) {\n txt = w.source.substr(w.matchStart, matched.index+matched[0].length-w.matchStart);\n }\n e.appendChild(document.createTextNode(txt));\n w.output.appendChild(e);\n w.nextMatch = endRegExp.lastIndex;\n }\n}\n\nconfig.formatters.push({\n name: "displayMath1",\n match: "\s\s\s$\s\s\s$",\n terminator: "\s\s\s$\s\s\s$\s\sn?", // 2.0 compatability\n termRegExp: "\s\s\s$\s\s\s$\s\sn?",\n element: "div",\n className: "math",\n handler: config.formatterHelpers.mathFormatHelper\n});\n\nconfig.formatters.push({\n name: "inlineMath1",\n match: "\s\s\s$", \n terminator: "\s\s\s$", // 2.0 compatability\n termRegExp: "\s\s\s$",\n element: "span",\n className: "math",\n handler: config.formatterHelpers.mathFormatHelper\n});\n\nvar backslashformatters = new Array(0);\n\nbackslashformatters.push({\n name: "inlineMath2",\n match: "\s\s\s\s\s\s\s(",\n terminator: "\s\s\s\s\s\s\s)", // 2.0 compatability\n termRegExp: "\s\s\s\s\s\s\s)",\n element: "span",\n className: "math",\n handler: config.formatterHelpers.mathFormatHelper\n});\n\nbackslashformatters.push({\n name: "displayMath2",\n match: "\s\s\s\s\s\s\s[",\n terminator: "\s\s\s\s\s\s\s]\s\sn?", // 2.0 compatability\n termRegExp: "\s\s\s\s\s\s\s]\s\sn?",\n element: "div",\n className: "math",\n handler: config.formatterHelpers.mathFormatHelper\n});\n\nbackslashformatters.push({\n name: "displayMath3",\n match: "\s\s\s\sbegin\s\s{equation\s\s}",\n terminator: "\s\s\s\send\s\s{equation\s\s}\s\sn?", // 2.0 compatability\n termRegExp: "\s\s\s\send\s\s{equation\s\s}\s\sn?",\n element: "div",\n className: "math",\n handler: config.formatterHelpers.mathFormatHelper\n});\n\n// These can be nested. e.g. \sbegin{equation} \sbegin{array}{ccc} \sbegin{array}{ccc} ...\nbackslashformatters.push({\n name: "displayMath4",\n match: "\s\s\s\sbegin\s\s{eqnarray\s\s}",\n terminator: "\s\s\s\send\s\s{eqnarray\s\s}\s\sn?", // 2.0 compatability\n termRegExp: "\s\s\s\send\s\s{eqnarray\s\s}\s\sn?",\n element: "div",\n className: "math",\n keepdelim: true,\n handler: config.formatterHelpers.mathFormatHelper\n});\n\n// The escape must come between backslash formatters and regular ones.\n// So any latex-like \scommands must be added to the beginning of\n// backslashformatters here.\nbackslashformatters.push({\n name: "escape",\n match: "\s\s\s\s.",\n handler: function(w) {\n w.output.appendChild(document.createTextNode(w.source.substr(w.matchStart+1,1)));\n w.nextMatch = w.matchStart+2;\n }\n});\n\nconfig.formatters=backslashformatters.concat(config.formatters);\n\nwindow.wikify = function(source,output,highlightRegExp,tiddler)\n{\n if(source && source != "") {\n if(version.major == 2 && version.minor > 0) {\n var wikifier = new Wikifier(source,getParser(tiddler),highlightRegExp,tiddler);\n wikifier.subWikifyUnterm(output);\n } else {\n var wikifier = new Wikifier(source,formatter,highlightRegExp,tiddler);\n wikifier.subWikify(output,null);\n }\n jsMath.ProcessBeforeShowing();\n }\n}\n//}}}\n
a reusable non-linear personal web notebook with LaTeX via [[jsMath|http://www.math.union.edu/~dpvc/jsMath/]]
$L_AT^EX$ TiddlyWiki
http://bob.mcelrath.org/tiddlyjsmath-2.0.3.html
/*{{{*/\n.viewer {\n line-height: 125%;\n font-family: serif;\n font-size: 12pt;\n}\n.viewer pre {\n font-size: 10pt;\n}\n#mainMenu {\n width: 11em;\n}\n/*}}}*/