【问题标题】:Correct use of append and Alignat from pylatex while pdf creating (python)在创建pdf时正确使用pylatex中的append和Alignat(python)
【发布时间】:2020-11-02 10:36:45
【问题描述】:

我想将乳胶中的一些公式保存在 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

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

【问题讨论】:

    标签: pdf latex pdf-generation pylatex


    【解决方案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')
    

    输出:

    【讨论】:

      猜你喜欢
      • 2015-08-06
      • 2013-11-12
      • 2014-06-25
      • 1970-01-01
      • 1970-01-01
      • 2015-08-11
      • 1970-01-01
      • 1970-01-01
      • 2020-02-25
      相关资源
      最近更新 更多