Skip to content

Conversation

@mmatera
Copy link
Contributor

@mmatera mmatera commented Jan 29, 2026

  • Improve conversion from RowBox of function call and parenthesized form to LaTeX :
    • Use \left \right when the embraced expression does not contain ^, _ or \.
    • Improve the formatting of some bracket characters, like '<|' and '|>'.
  • fix typo in documentation.


contain = rowbox_sequence(items[1:-1], **options) if len(items) > 2 else ""

if any(c in contain for c in ("\\", "^", "_")):
Copy link
Member

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.

Copy link
Contributor Author

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

  1. most of the cases are properly covered with this
  2. the cases which are not covered (expressions with escaped operators) still give expressions that compile in LaTeX
  3. 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.

Copy link
Member

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.

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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...

@mmatera mmatera mentioned this pull request Jan 29, 2026
mmatera added a commit that referenced this pull request Jan 29, 2026
This property can be used in #1663 instead of looking for specific
characters in the LaTeX representation
@mmatera mmatera force-pushed the improve_latex_form branch from 22e8ab5 to bb2f70d Compare January 30, 2026 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants