commit 9ecb67ec22458cb33c5a1067ed1d34b99e2efff0
parent 4a4d88c26f47e0e682fb6e0e1cfbc13986748956
Author: Davide P. Cervone <dpvc@union.edu>
Date: Tue, 2 Sep 2014 10:26:45 -0400
Add minimal support for \hfill (just to handle column alignment in matrices and arrays). Issue #903.
Diffstat:
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/unpacked/jax/input/TeX/jax.js b/unpacked/jax/input/TeX/jax.js
@@ -258,7 +258,7 @@
STACKITEM.array = STACKITEM.Subclass({
type: "array", isOpen: true, arraydef: {},
Init: function () {
- this.table = []; this.row = []; this.env = {}; this.frame = []
+ this.table = []; this.row = []; this.env = {}; this.frame = []; this.hfill = [];
this.SUPER(arguments).Init.apply(this,arguments);
},
checkItem: function (item) {
@@ -286,7 +286,15 @@
}
return this.SUPER(arguments).checkItem.call(this,item);
},
- EndEntry: function () {this.row.push(MML.mtd.apply(MML,this.data)); this.data = []},
+ EndEntry: function () {
+ var mtd = MML.mtd.apply(MML,this.data);
+ if (this.hfill.length) {
+ if (this.hfill[0] === 0) mtd.columnalign = "right";
+ if (this.hfill[this.hfill.length-1] === this.data.length)
+ mtd.columnalign = (mtd.columnalign ? "center" : "left");
+ }
+ this.row.push(mtd); this.data = []; this.hfill = [];
+ },
EndRow: function () {this.table.push(MML.mtr.apply(MML,this.row)); this.row = []},
EndTable: function () {
if (this.data.length || this.row.length) {this.EndEntry(); this.EndRow()}
@@ -915,6 +923,9 @@
// noalign: 'HandleNoAlign',
eqalignno: ['Matrix',null,null,"right left right",MML.LENGTH.THICKMATHSPACE+" 3em",".5em",'D'],
leqalignno: ['Matrix',null,null,"right left right",MML.LENGTH.THICKMATHSPACE+" 3em",".5em",'D'],
+ hfill: 'HFill',
+ hfil: 'HFill', // \hfil treated as \hfill for now
+ hfilll: 'HFill', // \hfilll treated as \hfill for now
// TeX substitution macros
bmod: ['Macro','\\mmlToken{mo}[lspace="thickmathspace" rspace="thickmathspace"]{mod}'],
@@ -1713,6 +1724,14 @@
}
},
+ HFill: function (name) {
+ var top = this.stack.Top();
+ if (top.isa(STACKITEM.array)) top.hfill.push(top.data.length);
+ else TEX.Error(["UnsupportedHFill","Unsupported use of %1",name]);
+ },
+
+
+
/************************************************************************/
/*
* LaTeX environments