diff --git a/ts/core/MmlTree/MmlNodes/mtable.ts b/ts/core/MmlTree/MmlNodes/mtable.ts index e7d6320a9..3e73e03bc 100644 --- a/ts/core/MmlTree/MmlNodes/mtable.ts +++ b/ts/core/MmlTree/MmlNodes/mtable.ts @@ -61,7 +61,7 @@ export class MmlMtable extends AbstractMmlNode { * Extra properties for this node */ public properties = { - useHeight: 1 + useHeight: true }; /** @@ -116,6 +116,7 @@ export class MmlMtable extends AbstractMmlNode { .appendChild(child); } } + level = this.getProperty('scriptlevel') as number || level; display = !!(this.attributes.getExplicit('displaystyle') || this.attributes.getDefault('displaystyle')); attributes = this.addInheritedAttributes(attributes, { columnalign: this.attributes.get('columnalign'), diff --git a/ts/core/MmlTree/SerializedMmlVisitor.ts b/ts/core/MmlTree/SerializedMmlVisitor.ts index 44455e2cb..5a8641688 100644 --- a/ts/core/MmlTree/SerializedMmlVisitor.ts +++ b/ts/core/MmlTree/SerializedMmlVisitor.ts @@ -210,6 +210,8 @@ export class SerializedMmlVisitor extends MmlVisitor { } setclass && this.setDataAttribute(data, 'texclass', texclass < 0 ? 'NONE' : TEXCLASSNAMES[texclass]); } + node.getProperty('scriptlevel') && node.getProperty('useHeight') === false && + this.setDataAttribute(data, 'smallmatrix', 'true'); return data; } diff --git a/ts/input/mathml/MathMLCompile.ts b/ts/input/mathml/MathMLCompile.ts index d30ec6367..90dea5156 100644 --- a/ts/input/mathml/MathMLCompile.ts +++ b/ts/input/mathml/MathMLCompile.ts @@ -159,6 +159,9 @@ export class MathMLCompile { } else if (name === 'data-mjx-variant') { mml.attributes.set('mathvariant', value); ignoreVariant = true; + } else if (name === 'data-mjx-smallmatrix') { + mml.setProperty('scriptlevel', 1); + mml.setProperty('useHeight', false); } } else if (name !== 'class') { let val = value.toLowerCase(); diff --git a/ts/input/tex/base/BaseItems.ts b/ts/input/tex/base/BaseItems.ts index 2913ac182..b28504430 100644 --- a/ts/input/tex/base/BaseItems.ts +++ b/ts/input/tex/base/BaseItems.ts @@ -846,6 +846,9 @@ export class ArrayItem extends BaseItem { const scriptlevel = this.arraydef['scriptlevel']; delete this.arraydef['scriptlevel']; let mml = this.create('node', 'mtable', this.table, this.arraydef); + if (scriptlevel) { + mml.setProperty('scriptlevel', scriptlevel); + } if (this.frame.length === 4) { // @test Enclosed frame solid, Enclosed frame dashed NodeUtil.setAttribute(mml, 'frame', this.dashed ? 'dashed' : 'solid'); @@ -866,10 +869,6 @@ export class ArrayItem extends BaseItem { NodeUtil.setAttribute(mml, 'padding', 0); } } - if (scriptlevel) { - // @test Subarray, Small Matrix - mml = this.create('node', 'mstyle', [mml], {scriptlevel: scriptlevel}); - } if (this.getProperty('open') || this.getProperty('close')) { // @test Cross Product Formula mml = ParseUtil.fenced(this.factory.configuration, diff --git a/ts/output/chtml/Wrappers/mtable.ts b/ts/output/chtml/Wrappers/mtable.ts index bbb9f9fe6..50061fd37 100644 --- a/ts/output/chtml/Wrappers/mtable.ts +++ b/ts/output/chtml/Wrappers/mtable.ts @@ -58,6 +58,9 @@ CommonMtableMixin, CHTMLmtr, CHTMLConstru 'position': 'relative', 'box-sizing': 'border-box' }, + 'mjx-mstyle[size="s"] mjx-mtable': { + 'vertical-align': '.354em' + }, 'mjx-labels': { position: 'absolute', left: 0, diff --git a/ts/output/chtml/Wrappers/mtd.ts b/ts/output/chtml/Wrappers/mtd.ts index 8825c57f4..ac56da3fa 100644 --- a/ts/output/chtml/Wrappers/mtd.ts +++ b/ts/output/chtml/Wrappers/mtd.ts @@ -109,9 +109,12 @@ CommonMtdMixin>(CHTMLWrapper) { this.adaptor.setStyle(this.chtml, 'textAlign', calign); } // - // Include a strut to force minimum height and depth + // If we are using minimum row heights, + // Include a strut to force minimum height and depth // - this.adaptor.append(this.chtml, this.html('mjx-tstrut')); + if (this.parent.parent.node.getProperty('useHeight')) { + this.adaptor.append(this.chtml, this.html('mjx-tstrut')); + } } } diff --git a/ts/output/common/Wrappers/mrow.ts b/ts/output/common/Wrappers/mrow.ts index 59117dff8..1109c0726 100644 --- a/ts/output/common/Wrappers/mrow.ts +++ b/ts/output/common/Wrappers/mrow.ts @@ -102,7 +102,9 @@ export function CommonMrowMixin(Base: T): MrowCons for (const child of this.childNodes) { const noStretch = (child.stretch.dir === DIRECTION.None); if (all || noStretch) { - const {h, d} = child.getBBox(noStretch); + let {h, d, rscale} = child.getBBox(noStretch); + h *= rscale; + d *= rscale; if (h > H) H = h; if (d > D) D = d; } diff --git a/ts/output/common/Wrappers/mtable.ts b/ts/output/common/Wrappers/mtable.ts index 84135d004..15450cd0d 100644 --- a/ts/output/common/Wrappers/mtable.ts +++ b/ts/output/common/Wrappers/mtable.ts @@ -617,8 +617,16 @@ export function CommonMtableMixin< */ public updateHDW(cell: C, i: number, j: number, H: number[], D: number[], W: number[] = null) { let {h, d, w} = cell.getBBox(); - if (h < .75) h = .75; - if (d < .25) d = .25; + const scale = cell.parent.bbox.rscale; + if (cell.parent.bbox.rscale !== 1) { + h *= scale; + d *= scale; + w *= scale; + } + if (this.node.getProperty('useHeight')) { + if (h < .75) h = .75; + if (d < .25) d = .25; + } if (h > H[j]) H[j] = h; if (d > D[j]) D[j] = d; if (W && w > W[i]) W[i] = w;