-
-
Notifications
You must be signed in to change notification settings - Fork 6
{Left,Right}Part -> {Left,Right}DoubleBracket and AMSLaTeX named characters #142
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
Merged
+8
−2
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Something that is going to be necessary to use this in
mathics.format.render.latexis to distinguish if the LaTeX command works onmathortextmode.Notice we have two dicts in that module:
https://github.com/Mathics3/mathics-core/blob/c5388232f77b053012f20b7fe4ab2e53932d3c16/mathics/format/render/latex.py#L48
https://github.com/Mathics3/mathics-core/blob/c5388232f77b053012f20b7fe4ab2e53932d3c16/mathics/format/render/latex.py#L67
Depending on the context,
encode_texuses one dict or the other: https://github.com/Mathics3/mathics-core/blob/c5388232f77b053012f20b7fe4ab2e53932d3c16/mathics/format/render/latex.py#L83There 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.
In what ways is this different from whether the symbol is surrounded by TeX math-mode or math-display-mode symbols
$and$$?Uh oh!
There was an error while loading. Please reload this page.
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.
I suspect what is done by rendering TeXForm hasn't been completely thought out. So while there may be additional information that needs to be added, proper changes might be different from how that code is currently working.
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.
Suppose you have this expression:
In WMA you get
In the second element, since it is an String, the output is inside a
\textblock, which contains the command\timeswhich only works in math mode. In Mathics3 we get the same, except for the irrelevant\left\rightcommands preceding the curl brackets.Now, compare with this other expression:
In WMA we get
while in Mathics3
Here, if
\[Alpha]is alone, it is considered an operator and then is picked from the mathics-scanner table, but if is inside a string, it is left alone. If we just use the replacement we would getwhich is wrong (does not compile). A solution would be to take into account that in the second case we are inside a
textblock, and just add$around.Now consider this other case:
Now we get it wrong:
which fails to compile in both occurrences. WMA returns for this case
So in some way it tracks when a symbol works on text mode or math mode.
Uh oh!
There was an error while loading. Please reload this page.
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 suggests that no changes are needed in named-characters.yml. Whether the output should use TeX's math or display math mode is not encoded in character information. Instead, that is a boxing aspect.
One purpose of boxing is to provide contextual information. In that respect, it is similar to parsing.
It shouldn't be surprising that the Mathics boxing code has been flawed at a conceptual and design level.
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.
Yes, you are correct for these symbols. I used amslatex originally, because it uses definitions that are not in LaTeX.
So to be clear, how about 3 fields: LaTeX-text-mode, LaTeX-math-mode, and AMSLaTeX-math-mode?
Also, in the back of my mind, in mathics core we should rename from op-tables.json to character-tables.json (or something like this). Here in mathics-scanner, this is called character-tables because this information is more about the named characters, rather than the operators.
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.
That could work. The only detail is that it introduces some redundancy ($\alpha$ would be in
AMSLaTeX-math-modetoo?, what is the context where it would be relevant to discriminate AMSLaTeX from plane LaTeX?)Regarding the change of name, I think it is OK.
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.
Yes, because we have to distinguish symbols that are in text-mode only, math-mode only, and in both text and math mode.
I do add this only because you point out that while some AMSLaTeX characters are exclusive to AMSLaTeX, some are not.
I'm okay with dropping LaTeX-math-mode, and adding that at some point in the future where a distinction is needed.
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.
@rocky, as you prefer. In any case, the tables are not so large. The question is how much work it would take to add these fields.
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.
I don't know. I'll try to get started on this, though.