-
Notifications
You must be signed in to change notification settings - Fork 77
Place calculus operator priority between addition/subtraction and mutiplication/division in Latexise #656
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
Conversation
…tiplication/division in Latexise
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.
Pull request overview
This PR introduces a separate LaTeX-specific priority system for calculus operators (derivative, integral, limit) to position them between addition/subtraction and multiplication/division in the operator precedence hierarchy, while maintaining their original priority for text formats. This improves LaTeX rendering by using parentheses more appropriately.
Changes:
- Added
LatexPriorityvirtual property to Entity and overridden it inCalculusOperatorto returnPriority.LatexCalculusOperation - Updated all LaTeX rendering code to use
LatexPriorityinstead ofPriorityfor parenthesization decisions - Updated test expectations to reflect the new parenthesization behavior (square brackets
[]changed to parentheses()in most cases)
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| Sources/AngouriMath/Core/Entity/Entity.Definition.cs | Added new LatexCalculusOperation priority level (30) between Sum/Minus (20) and Mul/Div (40) |
| Sources/AngouriMath/Functions/Output/Latex.Definition.cs | Added virtual LatexPriority property that defaults to Priority |
| Sources/AngouriMath/Core/Entity/Continuous/Entity.Continuous.Definition.cs | Reorganized and added CalculusOperator abstract base class |
| Sources/AngouriMath/Core/Entity/Continuous/Entity.Continuous.Calculus.Classes.cs | Changed Derivativef, Integralf, and Limitf to inherit from CalculusOperator |
| Sources/AngouriMath/Functions/Output/Latex/Latex.Calculus.Classes.cs | Overrode LatexPriority in CalculusOperator and updated LaTeX rendering logic to use it |
| Sources/AngouriMath/Functions/Output/Latex/Latex.Arithmetics.Classes.cs | Updated all LaTeX rendering to use LatexPriority instead of Priority |
| Sources/AngouriMath/Functions/Output/Latex/Latex.Discrete.Classes.cs | Updated all LaTeX rendering to use LatexPriority instead of Priority |
| Sources/AngouriMath/Functions/Output/Latex/Latex.Omni.Classes.cs | Updated all LaTeX rendering to use LatexPriority instead of Priority |
| Sources/Tests/UnitTests/Convenience/LatexTest.cs | Updated test expectations to match new parenthesization behavior and added new test cases for nested calculus operators |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| (_, Number { LatexPriority: >= Priority.Mul } or Factorialf(Number { LatexPriority: Priority.Leaf }) | ||
| or Powf(Number { LatexPriority: Priority.Leaf } or Factorialf(Number { LatexPriority: Priority.Leaf }), _)) => false, // Keep the \cdot in "f(x) \cdot -2" "f(x) \cdot 2i" "f(x) \cdot -2i" | ||
| (var left, var right) => left.LatexPriority >= right.LatexPriority && | ||
| !(left.Priority == Priority.Div && right.LatexPriority == Priority.Div) // Without \cdot, the fraction lines may appear too closely together. |
Copilot
AI
Jan 16, 2026
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.
Inconsistent use of Priority and LatexPriority in the same condition. The left side uses Priority while the right side uses LatexPriority. For consistency with the rest of this PR, left.Priority should be changed to left.LatexPriority.
| !(left.Priority == Priority.Div && right.LatexPriority == Priority.Div) // Without \cdot, the fraction lines may appear too closely together. | |
| !(left.LatexPriority == Priority.Div && right.LatexPriority == Priority.Div) // Without \cdot, the fraction lines may appear too closely together. |
| or Factorialf(Number { Priority: Priority.Leaf } or Variable { IsLatexUprightFormatted: true }), _)) => false, | ||
| or Complex { ImaginaryPart.IsZero: false, LatexPriority: >= Priority.Mul } /* don't combine upright "i" with an upright variable*/, | ||
| Variable { IsLatexUprightFormatted: true } or Number { LatexPriority: >= Priority.Mul } | ||
| or Factorialf(Number { LatexPriority: Priority.Leaf } or Variable { IsLatexUprightFormatted: true }) |
Copilot
AI
Jan 16, 2026
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.
Condition always evaluates to 'false'.
| or Factorialf(Number { LatexPriority: Priority.Leaf } or Variable { IsLatexUprightFormatted: true }) | |
| or Factorialf(Variable { IsLatexUprightFormatted: true }) |
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.
Why is this the case?
| or Powf(Number { Priority: Priority.Leaf } or Factorialf(Number { Priority: Priority.Leaf }), _)) => false, // Keep the \cdot in "f(x) \cdot -2" "f(x) \cdot 2i" "f(x) \cdot -2i" | ||
| (var left, var right) => left.Priority >= right.Priority && | ||
| !(left.Priority == Priority.Div && right.Priority == Priority.Div) // Without \cdot, the fraction lines may appear too closely together. | ||
| (Number { LatexPriority: Priority.Leaf }, { LatexPriority: Priority.Div }) => false, |
Copilot
AI
Jan 16, 2026
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.
Condition always evaluates to 'false'.
| or Powf(Number { Priority: Priority.Leaf } or Factorialf(Number { Priority: Priority.Leaf }), _)) => false, // Keep the \cdot in "f(x) \cdot -2" "f(x) \cdot 2i" "f(x) \cdot -2i" | ||
| (var left, var right) => left.Priority >= right.Priority && | ||
| !(left.Priority == Priority.Div && right.Priority == Priority.Div) // Without \cdot, the fraction lines may appear too closely together. | ||
| (Number { LatexPriority: Priority.Leaf }, { LatexPriority: Priority.Div }) => false, |
Copilot
AI
Jan 16, 2026
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.
Condition always evaluates to 'false'.
| (_, Number { LatexPriority: >= Priority.Mul } or Factorialf(Number { LatexPriority: Priority.Leaf }) | ||
| or Powf(Number { LatexPriority: Priority.Leaf } or Factorialf(Number { LatexPriority: Priority.Leaf }), _)) => false, // Keep the \cdot in "f(x) \cdot -2" "f(x) \cdot 2i" "f(x) \cdot -2i" |
Copilot
AI
Jan 16, 2026
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.
Condition always evaluates to 'false'.
| !(left.Priority == Priority.Div && right.Priority == Priority.Div) // Without \cdot, the fraction lines may appear too closely together. | ||
| (Number { LatexPriority: Priority.Leaf }, { LatexPriority: Priority.Div }) => false, | ||
| // 2 * 3 instead of 2 3 (= 23), 2 * 3^4 instead of 2 3^4 (= 23^4), but "(2+i) 2", "2 (2+i)" and "2 (2+i)^2" are fine with the parentheses - so we have the LatexPriority check. | ||
| (_, Number { LatexPriority: >= Priority.Mul } or Factorialf(Number { LatexPriority: Priority.Leaf }) |
Copilot
AI
Jan 16, 2026
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.
Condition always evaluates to 'false'.
| (_, Number { LatexPriority: >= Priority.Mul } or Factorialf(Number { LatexPriority: Priority.Leaf }) | |
| (_, Number or Factorialf(Number { LatexPriority: Priority.Leaf }) |
No description provided.