Replies: 10 comments
-
It is still true that I have no time to do this myself but feel free to ask questions anytime! |
Beta Was this translation helpful? Give feedback.
-
The underlying problem if I remember correctly is that functions don't have a notion of precedence, other than operators, and the function In order for this to be fixed I guess that the precedence logic from Or maybe there is a better solution than everything I've done previously. |
Beta Was this translation helpful? Give feedback.
-
Another approach would be to replace some of the LaTeX templates with actual functions that have their own logic in them. But that probably won't scale because it would be a case by case solution. |
Beta Was this translation helpful? Give feedback.
-
I think that implementing precedence logic for On the other hand, putting logic to the |
Beta Was this translation helpful? Give feedback.
-
You don't need to define a helper function to create templates. If I remember correctly you can put a function in there directly instead of the template string (similar or equal to the custom LaTeX handler described in the documentation). |
Beta Was this translation helpful? Give feedback.
-
This is the relevant code: mathjs/src/expression/node/FunctionNode.js Lines 385 to 415 in 47a291a If the |
Beta Was this translation helpful? Give feedback.
-
Thanks for your inputs @m93a . Would be nice to improve the LaTeX output for the cases you reported. We should indeed pay close attention to correctly handling precedence like Max points out. |
Beta Was this translation helpful? Give feedback.
-
Another case that I noticed is where parentheses surround the numerator and denominator of a fraction. So |
Beta Was this translation helpful? Give feedback.
-
For anyone interested in working on this, here's how Sympy does it: sympy/printing/precedence.py |
Beta Was this translation helpful? Give feedback.
-
@thunderkid you're right, in that case the parentheses can be removed from LaTeX output. |
Beta Was this translation helpful? Give feedback.
-
There are many functions in
mathjs
that, when rendered withtoTex()
, put too many parens around the arguments. For example a simplecross(c, d)
will produce:\left( c\right)\times\left( d\right)
instead ofc \times d
. This was already mentioned in #307 where @FSMaxB said he isn't going to have time for that, so it was closed. However some two years later, things could be different. And if not, I could look into the code myself and see what I can do…Steps needed:
not(a)
⇒\neg\left( a\right)
×\neg a
expm1(x)
⇒\left(e^{ x}-1\right)
) ×e^{ x}-1
-(1/2)
⇒-\left(\frac{1}{2}\right)
×-\frac{1}{2}
-((a/b))
add(x, add(y, z))
⇒\left( x+\left( y+ z\right)\right)
×x+y+z
@josdejong What do you think about this?
Beta Was this translation helpful? Give feedback.
All reactions