1

我想在 pdf 中保存一些乳胶中的公式

    from pylatex import Document, Section, Subsection, Command,Package, Alignat
    
    doc = Document(default_filepath='basic.tex', documentclass='article')
    doc.append('Solve the equation:')
    doc.append(r'$$\frac{x}{10} = 0 \\$$',Alignat(numbering=False, escape=False))
    doc.generate_pdf("test", clean_tex=True)

但我收到一个错误:

doc.append(r'$$\frac{x}{10} = 0 \\$$',Alignat(numbering=False, escape=False))
    TypeError: append() takes 2 positional arguments but 3 were given

我应该如何解决我的问题?

4

1 回答 1

1

这个答案来晚了,但我想没有什么坏处:Alignat不能append像那样传递环境,而是将附加的公式包含在其中。它也是一个数学环境,所以$$没有必要。

from pylatex import Document, Section, Subsection, Command,Package, Alignat

doc = Document(default_filepath='basic.tex', documentclass='article')
doc.append('Solve the equation:')
with doc.create(Alignat(numbering=False, escape=False)) as agn:
    agn.append(r'\frac{x}{10} = 0')

输出:

输出

于 2021-04-30T15:45:43.880 回答