Make \cases automatically use \text on the second entry in each row (so that it works like the real TeX \cases macro)

This commit is contained in:
Davide P. Cervone 2011-04-26 19:22:17 -04:00
parent bb09608b23
commit 86ed491787
4 changed files with 24 additions and 5 deletions

View File

@ -12,5 +12,5 @@
* http://www.apache.org/licenses/LICENSE-2.0
*/
MathJax.InputJax.TeX=MathJax.InputJax({id:"TeX",version:"1.1.1",directory:MathJax.InputJax.directory+"/TeX",extensionDir:MathJax.InputJax.extensionDir+"/TeX",config:{TagSide:"right",TagIndent:"0.8em",MultLineWidth:"85%"}});MathJax.InputJax.TeX.Register("math/tex");MathJax.InputJax.TeX.loadComplete("config.js");
MathJax.InputJax.TeX=MathJax.InputJax({id:"TeX",version:"1.1.2",directory:MathJax.InputJax.directory+"/TeX",extensionDir:MathJax.InputJax.extensionDir+"/TeX",config:{TagSide:"right",TagIndent:"0.8em",MultLineWidth:"85%"}});MathJax.InputJax.TeX.Register("math/tex");MathJax.InputJax.TeX.loadComplete("config.js");

File diff suppressed because one or more lines are too long

View File

@ -24,7 +24,7 @@
MathJax.InputJax.TeX = MathJax.InputJax({
id: "TeX",
version: "1.1.1",
version: "1.1.2",
directory: MathJax.InputJax.directory + "/TeX",
extensionDir: MathJax.InputJax.extensionDir + "/TeX",

View File

@ -791,7 +791,7 @@
matrix: 'Matrix',
array: 'Matrix',
pmatrix: ['Matrix','(',')'],
cases: ['Matrix','{','',"left left",null,".1em"],
cases: ['Matrix','{','',"left left",null,".1em",null,true],
eqalign: ['Matrix',null,null,"right left",MML.LENGTH.THICKMATHSPACE,".5em",'D'],
displaylines: ['Matrix',null,null,"center",null,".5em",'D'],
cr: 'Cr',
@ -1362,7 +1362,7 @@
{TEX.Error("MathJax maximum macro substitution count exceeded; is there a recursive macro call?")}
},
Matrix: function (name,open,close,align,spacing,vspacing,style) {
Matrix: function (name,open,close,align,spacing,vspacing,style,cases) {
var c = this.GetNext(); if (c === "") {TEX.Error("Missing argument for "+name)}
if (c === "{") {this.i++} else {this.string = c+"}"+this.string.slice(this.i+1); this.i = 0}
var array = STACKITEM.array().With({
@ -1372,6 +1372,7 @@
columnspacing: (spacing||"1em")
}
});
if (cases) {array.isCases = TRUE}
if (open || close) {array.open = open; array.close = close}
if (style === "D") {array.arraydef.displaystyle = TRUE}
if (align != null) {array.arraydef.columnalign = align}
@ -1380,6 +1381,24 @@
Entry: function (name) {
this.Push(STACKITEM.cell().With({isEntry: TRUE, name: name}));
if (this.stack.Top().isCases) {
var string = this.string;
var braces = 0, i = this.i, m = string.length;
while (i < m) {
var c = string.charAt(i);
if (c === "{") {braces++; i++}
else if (c === "}") {if (braces === 0) {m = 0} else {braces--; i++}}
else if (c === "&" && braces === 0) {TEX.Error("Extra alignment tab in \\cases text")}
else if (c === "\\") {
if (string.substr(i).match(/^((\\cr)[^a-zA-Z]|\\\\)/)) {m = 0} else {i += 2}
} else {i++}
}
var text = string.substr(this.i,i-this.i);
if (!text.match(/^\s*\\text[^a-zA-Z]/)) {
this.Push.apply(this,this.InternalMath(text,this.stack.env));
this.i = i;
}
}
},
Cr: function (name) {