使用sympy的latex()函数而不计算输入 [英] Using sympy's latex() function without calculating the input

查看:732
本文介绍了使用sympy的latex()函数而不计算输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从sympy表达式获取乳胶输出而不计算该表达式.例如,如果我做Latex((2 + 3)/7),输出将是5/7(使用乳胶),但是我要的是只用乳胶输出(2 + 3)/7.像这样:\ frac {2 + 3} {7}

I want to get latex output from a sympy expression without calculating the expression. For instance if I do latex((2+3)/7) the output would be 5/7 (with latex), but what I am after is for it to just output (2+3)/7 with latex. Like this: \frac{2+3}{7}

推荐答案

您可以手动调整long_frac_ratio

You can manually adjust the long_frac_ratio

long_frac_ratio:分子的宽度与所允许的分子宽度之比 分母的宽度,然后再开始分解长分数. 默认值为2.

long_frac_ratio: The allowed ratio of the width of the numerator to the width of the denominator before we start breaking off long fractions. The default value is 2.

>>> latex(e,long_frac_ratio=3)
'\\frac{2 + 3}{7}'

这篇关于使用sympy的latex()函数而不计算输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆