Rendering coefficients as fractions in sympy latex
问题 I would like to render a fraction multiplied by an integral. I tried: from sympy import * x, h = symbols("x h") (2/h) * Integral(x**2, (x, 0, 1)) The generated latex is: '\\frac{2 \\int\\limits_{0}^{h} x^{2}\\, dx}{h}' which looks wretched: Is it possible to keep the fraction as a coefficient, like so? This can be reproduced easily using sympy live. Thanks for any help. 回答1: You can, as @Stelios pointed out, use an unevaluated Mul to make the expression appear as you want it. To avoid