-
-
Notifications
You must be signed in to change notification settings - Fork 65
Improve TeXForm #1663
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
base: master
Are you sure you want to change the base?
Improve TeXForm #1663
Conversation
mathics/format/render/latex.py
Outdated
|
|
||
| contain = rowbox_sequence(items[1:-1], **options) if len(items) > 2 else "" | ||
|
|
||
| if any(c in contain for c in ("\\", "^", "_")): |
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 extremely fragile and myopic. Is there a more general principle underlying this?
I think the situation is that boxes should be noting whether their bounding box is strictly one-dimensional linear or can expand into the two-dimensional space. And that is what dictates whether \left and `\right' are 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.
One way to do it better would be to add an attribute to each BoxExpression giving information about if the expression is one-dimensional. I didn´t do that because
- most of the cases are properly covered with this
- the cases which are not covered (expressions with escaped operators) still give expressions that compile in LaTeX
- It is not too hard to change the condition to something more robust, but it requires more changes here and there.
For the last point I can do a proposal on the top of this, to make it easy to review.
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.
One way to do it better would be to add an attribute to each
BoxExpressiongiving information about if the expression is one-dimensional.
That would be fine.
I didn´t do that because...
The problem is that this represents thinking about the situation in fundamentally the wrong way. And this has to be undone later. Better, in my opinion, is not to start down the hacky path. We've seen that before.
Keeping this around as a draft so that the output changes can be compared against is a good idea, though.
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.
#1664 can be used instead of checking for characters in the encoded inner LaTeX expression.
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 should be fixed now...
This property can be used in #1663 instead of looking for specific characters in the LaTeX representation
22e8ab5 to
bb2f70d
Compare
\left\rightwhen the embraced expression does not contain^,_or\.