numbas / Numbas

A completely browser-based e-assessment/e-learning system, with an emphasis on mathematics
http://www.numbas.org.uk
Apache License 2.0
197 stars 118 forks source link

When rendering `root(x,2)` to LaTeX, produce the same output as for `sqrt(x)` #1004

Closed christianp closed 1 year ago

christianp commented 1 year ago

Currently the LaTeX rendering for root(x,n) is \sqrt[n]{x}.

It would be convenient to omit the superscript n when n = 2, so the expression is equivalent to sqrt(x).

Maybe there should be a display flag to force this superscript to be displayed, when it's important.

darknight2135 commented 1 year ago

Hello! This is my first issue, I am not entirely sure if I need to add a condition when b=2 and nothing else. Could you kindly provide some guidance on this matter?

https://github.com/numbas/Numbas/blob/b3563830e02835c4e90ab23004a547696cc79a05/runtime/scripts/math.js#L287-L293

christianp commented 1 year ago

@darknight2135 thanks for offering to help. The code that needs to be changed is in jme-display.js - we'd need to test tree.args(1) for equality with 2, as a JME token.