-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
\overrightarrow TeX command implemented #524
Conversation
The appearance of the arrow part doesn't quite look right. I think it's supposed to overlay the \rightarrow command with the longer line. |
See also #402 which requested this feature. There @kevinbarabash wrote:
That width information should be available from #366, I think. #407 (comment) mentions |
Well I'm really new to the katex code, but I understood that for the dom part, everything rely on css classes (for span elements). That's probably why it's a bit more difficult to get things such arrow ends or widehats... To realize this in the dom part, I used a css class with 0px width but with borders. The result is four arrow heads (left,top,bottom,right), but each of theses arrow heads are isocèle triangles (as you can see in the example of my first post). So yes it's not as beautiful as the one you get in real LaTeX results... if someone have an idea of another css trick I could use for a better result, you're welcome ! rightarrow in katex is a unicode symbol. I didn't use this because I can't see how you could manage the stretch effect above vectors. On the other hand I implemented this overrightarrow also for the canvas version of katex (thank's Martin!), and it looks much more nice I think: With canvas everything is much easier, because you can draw things exactly the way you want... |
Another overrightarrow with better shape
A better arrow head shape
In case this is useful, applying these tips to
So TeX has a vbox containing two hboxes, one for the line and one for the letters, with some negative kerning between the two. The line consists of two occurrences of one symbol, and one occurrence of another symbol. So apparently that's not even a
Using symbols outside the KaTeX fonts has a huge risk of looking differently on different browsers. Please try to stick to the KaTeX fonts. Since they already can draw |
My first try was to use this unicode 2192 (rightarrow), but unfortunately this is not only the arrow head, but the whole arrow... So when you use it in css you have to stretch it, and it doesn't look great in some cases. I also tried to hide the line arrow behind an overline, and again the result was not so good in some cases. |
Another new design of overrightarrow, very close to LaTeX standards.
All my tries to superimpose lines and rightarrow failed depending on which browser or on which font size... So I changed radically my approach, as I saw that the \u2212 (minus) was in katex lib, and with the same vertical position characteristics than the rightarrow. I also discovered that mathjax uses this \u2212 to render the overrightarrow. |
overflow: hidden; | ||
|
||
&:before { | ||
content: "−−−−−−−−−−−−−−−−−→"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a clever solution, but it fails if the math under the arrow is too wide. Could you add a comment with the limitations of this approach and a TODO to make this better at some point? The limitations that I see here are that this won't work with \overleftrightarrow
and if the expression under the arrow is too large it won't extend far enough. Not sure how many people would use \overleftarrow
, but it seems like an easy addition.
@erichake thanks for the pull request. We require all contributors to sign our Contributor License Agreement. |
@erichake thanks for signing the CLA. Friendly ping about adding a comment about the limitations of this approach. |
Closing in preference of #670. |
I followed the \overline model to implement the \overrightarrow command. The css trick is in the static/katex.less file.