Skip to content

Is it possible to tell Math.js to use \times instead of \cdot when converting an expression to TeX? #3383

Closed Answered by gwhitney
p1ckle-rick asked this question in Q&A
Discussion options

You must be logged in to vote

The below code should show you the possibilities. You can set the .toTex property on multiply, but it only affects function-call-style expressions, not infix-operator expressions. To get those, you need to use the 'options' argument of .toTex() with a function that detects an OperatorNode with function multiply.

math.multiply.toTex = '${args[0]} \\times ${args[1]}'
const tree1 = math.parse('1*2')
const tree2 = math.parse('multiply(1,2)')
console.log(tree1.toTex())  // 1\cdot2
console.log(tree2.toTex())  // 1 \times 2 
console.log(tree1.toTex({handler: (node,options) => {
    if (node.type === 'OperatorNode' && node.fn === 'multiply') {
        return node.args.map(node => node.toTex(optio…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by p1ckle-rick
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants