Python pylatex:以字符串形式传递的数量

Python pylatex:以字符串形式传递的数量,python,latex,pylatex,quantities,Python,Latex,Pylatex,Quantities,我正在使用pylatex和python数量包创建一个格式化的pdf,并希望能够编写如下内容: doc.append("My custom text and the math: {}".format(math)) doc.append("My custom text and the math: {}".format(math)) 我的自定义文本和数学:F=1.982×10^20 N 我可以使用pylatex的doc.append()添加文本,也可以使用它添加“数量”值,但我不知道如何将这两个值

我正在使用pylatex和python数量包创建一个格式化的pdf,并希望能够编写如下内容:

doc.append("My custom text and the math: {}".format(math))
doc.append("My custom text and the math: {}".format(math))
我的自定义文本和数学:F=1.982×10^20 N

我可以使用pylatex的doc.append()添加文本,也可以使用它添加“数量”值,但我不知道如何将这两个值放在同一个字符串中。i、 e.能够做以下事情:

doc.append("My custom text and the math: {}".format(math))
doc.append("My custom text and the math: {}".format(math))
doc.append似乎包含一个noescape命令,导致输出为:

My custom text and the math: Math([’F=’, Quantity(array(1.98201661e+20) * N)])
而不是:

My custom text and the math: F = 1.982 × 10^20 N
这是pylatex Quantilities exmaple的示例代码,后面是我自己的一行代码

G = pq.constants.Newtonian_constant_of_gravitation
moon_earth_distance = 384400 * pq.km
moon_mass = 7.34767309e22 * pq.kg
earth_mass = 5.972e24 * pq.kg
moon_earth_force = G * moon_mass * earth_mass / moon_earth_distance**2
q1 = Quantity(moon_earth_force.rescale(pq.newton),
              options={'round-precision': 4, 'round-mode': 'figures'})
math = Math(data=['F=', q1])

doc.append("My custom text and the math: {}".format(math))
我发现我可以通过更改为手动执行某些操作:

math = Math(data=['F=', q1], inline=True)
然后做:

doc.append("Test text")
doc.append(math)
doc.append("and moretext")
但我想要一些不那么麻烦的东西,让我这样写: