-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
I've been playing around with making a WYSIWYG mathematics editor using KaTeX for rendering, and have run into some issues with the cursor. The ideal would be something like a \cursor command that inserts a vertical line of width 1px, of sensible height, and that doesn't affect the spacing of anything around it.
Experimentally, I've tried modifying \rule (since I don't use it otherwise) by adding some lines in buildHTML.js right before // Style the rule to the right size to force the size:
rule.style.padding = "0px";
rule.style.marginRight = "-1px";
rule.style.borderLeftWidth = "1px";
With this modification, the actual TeX used for the cursor currently is \rule[-0.5ex]{0em}{0.7em}. This works acceptably, but there seem to be a few more complex interactions/margin-settings that this doesn't account for.
To see it working, go to the demo and enter 1+2+3+4 and use the arrow keys to move the cursor around. Nothing else shifts around as the cursor moves.
To see it not working as well, enter x+sin(x) and move the arrow keys between the + and the sin and see that the sin shifts to the right.
I haven't been able to chase up what is responsible for this, and various permutations of these modifications as well as attempts to use \rlap and \llap don't do as well as the above, so I figured I'd ask to see if someone who knows more about the KaTeX side knows what's up and/or whether there's any more general interest in such a feature.