Repository navigation
AutoCommands of greek letters adds a space after the letter. #43
Description
Activity
Note, I am able to work around this by adding a variable named
theta '.This is how commands (things that start with backslash) have always been dealt with (auto commands are still commands). I think you are the only one that has really tried to do much with Greek letters in this way, and so there hasn't been much demand to really look into it.
It should be okay to change the
textmethod of theVariableclass (on line 539 ofsrc/commands/mathElements.tsto something liketext() { let text = this.ctrlSeq; if (text.startsWith('\\')) { if (text.startsWith('\\operatorname{')) text = text.slice(14, text.length); else text = text.slice(1, text.length); } if (text.endsWith(' ') || text.endsWith('}')) { text = text.slice(0, -1); if ( !( this.right instanceof Bracket || this.right instanceof Fraction || this.right instanceof SupSub || (this.right instanceof VanillaSymbol && this.right.ctrlSeq === "'") ) ) text += ' '; } return text; }
Currently the handling of a space at the end does not occur for commands because of the
elseclause. This would make that happen. At least the unit tests still are good with this. If this change is made, then there definitely need to be unit tests added for this. Unfortunately, there really aren't enoughtextunit tests. See the comment in thetest/text-output.tsfile on line 35. Text output was not something that the original MathQuill library really cared about and only partially implemented. It is our usage that made this much more important, and there is still a lot of work needed in adding appropriate unit tests for it.I think that another possibility is to switch to using unicode for Greek letters in the text output. You would have to define the variables using those unicode letters also (I think that can be done with MathObjects), or at least define unicode alternatives. That might be better. Then you don't need to worry about spacing since it is a single character.
I have been trying to use unicode as alias for my variables, but I have a lot of older problems without that setup, so changing to unicode would break multiple problems for me. That being said, I have written a patch but never submitted it to make PG automatically add the TeX and unicode alternative for Greek letter variables. If such a patch was in PG then using unicode would be less of a problem for me.
I have it setup so Greek letters like
thetaget turned into their symbol for my course that uses them. I wanted to write a problem in which I wanted to usetheta'as a variable, but this doesn't work because MathQuill inserts a space so the parser readstheta 'and errors out on'as an undefined character. If I don't use the AutoCommands to turnthetainto its Greek letter the problem works as expected.I haven't noticed any other issues with the PG parser with this extra space being added, so this is a rare use case issue.
Unsure if removing the space being inserted could cause other issues.