Skip to content
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

Extra \cdot in LaTeX output for Mul between a numeric power and a polynomial with numeric coefficient since SymPy 1.10 #26540

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion sympy/printing/latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,14 @@ def convert_args(args) -> str:

_tex += term_tex
last_term_tex = term_tex
return _tex

# Debug output before modification
# print("Original LaTeX:", _tex)
pattern = r'(\^\{[\d]+?\})\s*\\cdot\s*(\\left\(.+?\\right\))'
modified_latex = re.sub(pattern, r'\1 \2', _tex)
# print("Modified LaTeX:", modified_latex)
return modified_latex
Comment on lines +562 to +567
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The erroneous code should not be generated in the first place. Attempting to fix it afterwards with a regex is not the right fix.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oscarbenjamin How do you propose to fix it properly?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You would need to find the source of the incorrect \cdot and fix it.



# Check for unevaluated Mul. In this case we need to make sure the
# identities are visible, multiple Rational factors are not combined
Expand Down