@@ -51,11 +51,12 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
51
51
* Implement \newcommand{\name}[n][default]{...}
52
52
*/
53
53
NewCommand : function ( name ) {
54
- var cs = this . trimSpaces ( this . GetArgument ( name ) ) ,
54
+ var CS = this . GetArgument ( name ) , cs = this . trimSpaces ( CS ) ,
55
55
n = this . GetBrackets ( name ) ,
56
56
opt = this . GetBrackets ( name ) ,
57
57
def = this . GetArgument ( name ) ;
58
58
if ( cs . charAt ( 0 ) === "\\" ) { cs = cs . substr ( 1 ) }
59
+ if ( cs === "" && CS . substr ( CS . length - 1 , 1 ) === " " ) { cs += " " }
59
60
if ( ! cs . match ( / ^ ( .| [ a - z ] + ) $ / i) ) {
60
61
TEX . Error ( [ "IllegalControlSequenceName" ,
61
62
"Illegal control sequence name for %1" , name ] ) ;
@@ -120,10 +121,11 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
120
121
name = this . GetCSname ( name ) ;
121
122
macro = this . csFindMacro ( name ) ;
122
123
if ( ! macro ) {
123
- if ( TEXDEF . mathchar0mi [ name ] ) { macro = [ "csMathchar0mi" , TEXDEF . mathchar0mi [ name ] ] } else
124
- if ( TEXDEF . mathchar0mo [ name ] ) { macro = [ "csMathchar0mo" , TEXDEF . mathchar0mo [ name ] ] } else
125
- if ( TEXDEF . mathchar7 [ name ] ) { macro = [ "csMathchar7" , TEXDEF . mathchar7 [ name ] ] } else
126
- if ( TEXDEF . delimiter [ "\\" + name ] != null ) { macro = [ "csDelimiter" , TEXDEF . delimiter [ "\\" + name ] ] }
124
+ if ( TEXDEF . mathchar0mi [ name ] ) { macro = [ "csMathchar0mi" , TEXDEF . mathchar0mi [ name ] ] } else
125
+ if ( TEXDEF . mathchar0mo [ name ] ) { macro = [ "csMathchar0mo" , TEXDEF . mathchar0mo [ name ] ] } else
126
+ if ( TEXDEF . mathchar7 [ name ] ) { macro = [ "csMathchar7" , TEXDEF . mathchar7 [ name ] ] } else
127
+ if ( TEXDEF . delimiter [ "\\" + name ] != null ) { macro = [ "csDelimiter" , TEXDEF . delimiter [ "\\" + name ] ] } else
128
+ return ;
127
129
}
128
130
} else { macro = [ "Macro" , c ] ; this . i ++ }
129
131
this . setDef ( cs , macro ) ;
@@ -145,8 +147,9 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
145
147
TEX . Error ( [ "MissingCS" ,
146
148
"%1 must be followed by a control sequence" , cmd ] )
147
149
}
148
- var cs = this . trimSpaces ( this . GetArgument ( cmd ) ) ;
149
- return cs . substr ( 1 ) ;
150
+ var cs = this . GetArgument ( cmd ) , CS = this . trimSpaces ( cs ) ;
151
+ if ( CS == "\\" && cs . substr ( cs . length - 1 , 1 ) === " " ) { CS += " " }
152
+ return CS . substr ( 1 ) ;
150
153
} ,
151
154
152
155
/*
0 commit comments