openwebwork / pg

Problem rendering engine for WeBWorK
http://webwork.maa.org/wiki/Category:Authors
Other
46 stars 76 forks source link

Update contextReaction.pl with several new features #1114

Open dpvc opened 1 month ago

dpvc commented 1 month ago

This PR updates the Reaction context to include several new features. These are documented in the changes to the POD section, but the main additions are:

This is work I did a while ago, but never made a PR for it until now.

pstaabp commented 4 weeks ago

Testing some of the examples in the POD, the complexes that you mentioned, I tried to create:

Formula("[CoCl_4(NH_3)_2]^−");

and got the error:

Unexpected character '−'; see position 18 of formula at line 15 of setunits/reaction.pg
   from within main::Formula called at line 15 of setunits/reaction.pg

and that line cited above is line 15.

I tested other cases using ^- without problems.

pstaabp commented 4 weeks ago

@drgrice1 when testing this with MQ, for the --> in the reactions, the --> show up in MQ as 3 characters. Could we add the --> to create a \longrightrarrow ? Not a huge thing, but would look nice.

drgrice1 commented 4 weeks ago

Perhaps. Add a feature request issue to https://github.com/openwebwork/mathquill, and I will look into it when I have time.

dpvc commented 4 weeks ago

I tried to create: Formula("[CoCl_4(NH_3)_2]^−"); and got the error: ...

It turns out that the minus is the Unicode minus at U+2212 rather than the hyphen-minus at U+002D. Since U+2212 is not defined as an operator, you get that error.

I must have copied the TeX output or something. Sorry about that. I suppose we could add the alternatives like in other contexts. I'll make a PR to fix the comment.