1

I want to save some formulas from latex in 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)

But I get an error:

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

How should I solve my problem?

jf_
  • 3,099
  • 2
  • 13
  • 31

1 Answers1

1

This answer comes late, but I guess there is no harm: The Alignat environment cannot be passed to append like that, instead the appended formula is enclosed in it. Also it is a math environment, so the $$ are not necessary.

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')

Output:

output

jf_
  • 3,099
  • 2
  • 13
  • 31