Skip to content

Commit

Permalink
Fix error message with \vdotswithin{} by making sure top.table exists…
Browse files Browse the repository at this point in the history
… before using is. (mathjax/MathJax#3078)
  • Loading branch information
dpvc committed Aug 11, 2023
1 parent 49db078 commit efcb980
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions ts/input/tex/mathtools/MathtoolsMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ export const MathtoolsMethods: Record<string, ParseMethod> = {
*/
VDotsWithin(parser: TexParser, name: string) {
const top = parser.stack.Top() as EqnArrayItem;
const isFlush = (top.getProperty('flushspaceabove') === top.table.length);
const isFlush = (top.table && top.getProperty('flushspaceabove') === top.table.length);
const arg = '\\mmlToken{mi}{}' + parser.GetArgument(name) + '\\mmlToken{mi}{}';
const base = new TexParser(arg, parser.stack.env, parser.configuration).mml();
let mml = parser.create('node', 'mpadded', [
Expand Down Expand Up @@ -428,11 +428,15 @@ export const MathtoolsMethods: Record<string, ParseMethod> = {
ShortVDotsWithin(parser: TexParser, _name: string) {
const top = parser.stack.Top() as EqnArrayItem;
const star = parser.GetStar();
MathtoolsMethods.FlushSpaceAbove(parser, '\\MTFlushSpaceAbove');
!star && top.EndEntry();
if (top.EndEntry) {
MathtoolsMethods.FlushSpaceAbove(parser, '\\MTFlushSpaceAbove');
!star && top.EndEntry();
}
MathtoolsMethods.VDotsWithin(parser, '\\vdotswithin');
star && top.EndEntry();
MathtoolsMethods.FlushSpaceBelow(parser, '\\MTFlushSpaceBelow');
if (top.EndEntry) {
star && top.EndEntry();
MathtoolsMethods.FlushSpaceBelow(parser, '\\MTFlushSpaceBelow');
}
},

/**
Expand All @@ -443,8 +447,10 @@ export const MathtoolsMethods: Record<string, ParseMethod> = {
*/
FlushSpaceAbove(parser: TexParser, name: string) {
const top = MathtoolsUtil.checkAlignment(parser, name);
top.setProperty('flushspaceabove', top.table.length); // marker so \vdotswithin can shorten its height
top.addRowSpacing('-' + parser.options.mathtools['shortvdotsadjustabove']);
if (top.table) {
top.setProperty('flushspaceabove', top.table.length); // marker so \vdotswithin can shorten its height
top.addRowSpacing('-' + parser.options.mathtools['shortvdotsadjustabove']);
}
},

/**
Expand All @@ -455,9 +461,11 @@ export const MathtoolsMethods: Record<string, ParseMethod> = {
*/
FlushSpaceBelow(parser: TexParser, name: string) {
const top = MathtoolsUtil.checkAlignment(parser, name);
top.Size() && top.EndEntry();
top.EndRow();
top.addRowSpacing('-' + parser.options.mathtools['shortvdotsadjustbelow']);
if (top.table) {
top.Size() && top.EndEntry();
top.EndRow();
top.addRowSpacing('-' + parser.options.mathtools['shortvdotsadjustbelow']);
}
},

/**
Expand Down

0 comments on commit efcb980

Please sign in to comment.