Fixing issue with LaTeX sqrt.
This commit is contained in:
parent
e35f6cebec
commit
b989a685e9
1 changed files with 8 additions and 6 deletions
|
@ -143,9 +143,9 @@ class LatexAPI extends Module {
|
||||||
parif(elem, contents) {
|
parif(elem, contents) {
|
||||||
elem = elem.toString()
|
elem = elem.toString()
|
||||||
const contains = contents.some(x => elem.indexOf(x) > 0)
|
const contains = contents.some(x => elem.indexOf(x) > 0)
|
||||||
if(elem[0] !== "(" && elem.at(-1) !== ")" && contains)
|
if((elem[0] !== "(" || elem.at(-1) !== ")") && contains)
|
||||||
return this.par(elem)
|
return this.par(elem)
|
||||||
if(elem[0] === "(" && elem.at(-1) === ")" && !contains)
|
if((elem[0] === "(" || elem.at(-1) === ")") && !contains)
|
||||||
return elem.removeEnclosure()
|
return elem.removeEnclosure()
|
||||||
return elem
|
return elem
|
||||||
}
|
}
|
||||||
|
@ -170,13 +170,14 @@ class LatexAPI extends Module {
|
||||||
else
|
else
|
||||||
return `\\int\\limits_{${args[0]}}^{${args[1]}}${args[2]}(t) dt`
|
return `\\int\\limits_{${args[0]}}^{${args[1]}}${args[2]}(t) dt`
|
||||||
case "sqrt":
|
case "sqrt":
|
||||||
return `\\sqrt\\left(${args.join(", ")}\\right)`
|
const arg = this.parif(args.join(", "), [])
|
||||||
|
return `\\sqrt{${arg}}`
|
||||||
case "abs":
|
case "abs":
|
||||||
return `\\left|${args.join(", ")}\\right|`
|
return `\\left|${args.join(", ")}\\right|`
|
||||||
case "floor":
|
case "floor":
|
||||||
return `\\left\\lfloor${args.join(", ")}\\right\\rfloor`
|
return `\\left\\lfloor{${args.join(", ")}}\\right\\rfloor`
|
||||||
case "ceil":
|
case "ceil":
|
||||||
return `\\left\\lceil${args.join(", ")}\\right\\rceil`
|
return `\\left\\lceil{${args.join(", ")}}\\right\\rceil`
|
||||||
default:
|
default:
|
||||||
return `\\mathrm{${f}}\\left(${args.join(", ")}\\right)`
|
return `\\mathrm{${f}}\\left(${args.join(", ")}\\right)`
|
||||||
}
|
}
|
||||||
|
@ -294,7 +295,7 @@ class LatexAPI extends Module {
|
||||||
nstack.push(this.parif(n1, ["+", "-", "*", "/", "^"]) + "!")
|
nstack.push(this.parif(n1, ["+", "-", "*", "/", "^"]) + "!")
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
nstack.push(f + this.parif(n1, ["+", "-", "*", "/", "^"]))
|
nstack.push(this.functionToLatex(f, [this.parif(n1, ["+", "-", "*", "/", "^"])]))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
@ -332,6 +333,7 @@ class LatexAPI extends Module {
|
||||||
if(nstack.length > 1) {
|
if(nstack.length > 1) {
|
||||||
nstack = [nstack.join(";")]
|
nstack = [nstack.join(";")]
|
||||||
}
|
}
|
||||||
|
console.log(nstack[0])
|
||||||
return String(nstack[0])
|
return String(nstack[0])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue