@@ -143,9 +143,9 @@ class LatexAPI extends Module {
143143 parif ( elem , contents ) {
144144 elem = elem . toString ( )
145145 const contains = contents . some ( x => elem . indexOf ( x ) > 0 )
146- if ( elem [ 0 ] !== "(" && elem . at ( - 1 ) !== ")" && contains )
146+ if ( ( elem [ 0 ] !== "(" || elem . at ( - 1 ) !== ")" ) && contains )
147147 return this . par ( elem )
148- if ( elem [ 0 ] === "(" && elem . at ( - 1 ) === ")" && ! contains )
148+ if ( ( elem [ 0 ] === "(" || elem . at ( - 1 ) === ")" ) && ! contains )
149149 return elem . removeEnclosure ( )
150150 return elem
151151 }
@@ -170,13 +170,14 @@ class LatexAPI extends Module {
170170 else
171171 return `\\int\\limits_{${ args [ 0 ] } }^{${ args [ 1 ] } }${ args [ 2 ] } (t) dt`
172172 case "sqrt" :
173- return `\\sqrt\\left(${ args . join ( ", " ) } \\right)`
173+ const arg = this . parif ( args . join ( ", " ) , [ ] )
174+ return `\\sqrt{${ arg } }`
174175 case "abs" :
175176 return `\\left|${ args . join ( ", " ) } \\right|`
176177 case "floor" :
177- return `\\left\\lfloor${ args . join ( ", " ) } \\right\\rfloor`
178+ return `\\left\\lfloor{ ${ args . join ( ", " ) } }\\right\\rfloor`
178179 case "ceil" :
179- return `\\left\\lceil${ args . join ( ", " ) } \\right\\rceil`
180+ return `\\left\\lceil{ ${ args . join ( ", " ) } }\\right\\rceil`
180181 default :
181182 return `\\mathrm{${ f } }\\left(${ args . join ( ", " ) } \\right)`
182183 }
@@ -294,7 +295,7 @@ class LatexAPI extends Module {
294295 nstack . push ( this . parif ( n1 , [ "+" , "-" , "*" , "/" , "^" ] ) + "!" )
295296 break
296297 default :
297- nstack . push ( f + this . parif ( n1 , [ "+" , "-" , "*" , "/" , "^" ] ) )
298+ nstack . push ( this . functionToLatex ( f , [ this . parif ( n1 , [ "+" , "-" , "*" , "/" , "^" ] ) ] ) )
298299 break
299300 }
300301 break
@@ -332,6 +333,7 @@ class LatexAPI extends Module {
332333 if ( nstack . length > 1 ) {
333334 nstack = [ nstack . join ( ";" ) ]
334335 }
336+ console . log ( nstack [ 0 ] )
335337 return String ( nstack [ 0 ] )
336338 }
337339}
0 commit comments