-
-
Notifications
You must be signed in to change notification settings - Fork 277
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
Unable to get exact caret position if multiple array matrix are present. #2546
Comments
Thanks for following the issue template! This is a good report. I think this is behaving correctly, but the meaning of This is a position in a tree that represents the expression. It does not correspond to an index in the LaTeX string representing this expression. The same expression can be represented in ASCII Math, and the string representation would be different, and have different indexes. The first matrix is from position 0 to position 17. |
Thank you for the response. So, how can I get the exact position of the cursor in the latex string? With a regex I am able to extract the matrix from the whole equation. After that I am trying to find where the cursor is, as in this case(
With 45 as position value I am not even able to reach to the 2nd matrix. So, What other option do I have here instead of mf.position? how to get the exact offset value? |
Yes, that is as expected. Again, the "position" and "index in a LaTeX string" are completely unrelated values. Just like "position" and "index in an ASCIIMath string" or "position" and "horizontal coordinate on the screen of the cursor". Could you explain what you are trying to do? That's not very clear from what you've described so far. If you're trying to get the LaTeX representation from the start of the expression to the current position, you can use If you're trying to "understand" the input in the mathfield, you can use |
My requirement is to align the matrix column based on user requirement("left", "right", "centre"). For instance, I have a angular popup like contextual balloon which will be taking input("left", "right", "centre") from the user for aligning the specific matrix column where the user has placed their cursor. After taking input I am just changing the format in the matrix array {lcr}. So, for that I need the cursor position of the according to the full latex.
Here, in the above method I am extracting the matrix from the equation. And iterating the matrices until I found the matrix where the user cursor is.
Here, I am focusing on the target matrix and after that getting the column. And at the end updating the column alignment of the target matrix. The walkaround:
Full latex: output from Here, why the second matrix is not coming with the full latex?
I am trying to get the position based on the full latex. |
OK, thanks for the explanation. I now understand what you're trying to do. Something important to understand is that the math-field is not a LaTeX editor. It's a math equation editor. Internally, the equation is represented as a tree. It is possible to convert LaTeX into that tree, and the tree into LaTeX or MathML or ASCIIMath. However, the editing state (position, etc...) are relative to the tree structure, not to the LaTeX, which is only generated on demand. There is a |
Thank you for the clarity. I will try to find a walkaround. Thanks for the support. |
Issue
Not getting the exact caret position using mf.position.
Steps that are specific and repeatable
My cursor at "4^" in the second matrix
\begin{array}{cc}d & x+y\\ p-q & 4\end{array}
.With this code if you see the output. It is very confusing.
In this
console.log(mf.getValue(0, 45, "latex"))
what happened to second matrix array?dx+yp-q4
why this output?Expected Behavior
Code pen
https://codepen.io/devraj112/pen/LYwgJOO
if this link does not work:
###This is my first post here, Sorry, If I missed following any guidelines.
The text was updated successfully, but these errors were encountered: