-1

我正在使用 PyLaTex 创建一个 pdf 文档。我在编译器方面遇到了一些问题。

我在 MacOS-High Sierra 上运行我的程序,并安装了 MacTeX Mactex 下载的基本版本,并且还使用安装了latexmk

sudo tlmgr install latexmk

对于以下起始代码,我在编译器循环中遇到错误。这是代码后附加的错误日志。

import numpy as np

from pylatex import Document, Section, Subsection, Tabular, Math, TikZ, Axis, \
    Plot, Figure, Matrix, Alignat
from pylatex.utils import italic
import os

if __name__ == '__main__':
#     image_filename = os.path.join(os.path.dirname(__file__), 'kitten.jpg')

    geometry_options = {"tmargin": "1cm", "lmargin": "10cm"}
    doc = Document(geometry_options=geometry_options)

    with doc.create(Section('The simple stuff')):
        doc.append('Some regular text and some')
        doc.append(italic('italic text. '))
        doc.append('\nAlso some crazy characters: $&#{}')
        with doc.create(Subsection('Math that is incorrect')):
            doc.append(Math(data=['2*3', '=', 9]))

        with doc.create(Subsection('Table of something')):
            with doc.create(Tabular('rc|cl')) as table:
                table.add_hline()
                table.add_row((1, 2, 3, 4))
                table.add_hline(1, 2)
                table.add_empty_row()
                table.add_row((4, 5, 6, 7))


    doc.generate_pdf('full', clean_tex=False, compiler_args='--latexmk')

错误代码:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-10-dbe7f407e095> in <module>()
     27 
     28 
---> 29     doc.generate_pdf('full', clean_tex=False, compiler_args='--latexmk')

~/anaconda3/lib/python3.6/site-packages/pylatex/document.py in generate_pdf(self, filepath, clean, clean_tex, compiler, compiler_args, silent)
    227 
    228         for compiler, arguments in compilers:
--> 229             command = [compiler] + arguments + compiler_args + main_arguments
    230 
    231             try:

TypeError: can only concatenate list (not "str") to list

请帮助我理解错误并修复相同的问候,

4

1 回答 1

0

看起来像接受字符串和接受列表的compiler关键字参数之间的混淆。compiler_args也许这样的事情就是你所追求的:

doc.generate_pdf('full', clean_tex=False, compiler='latexmk', compiler_args=['-c'])
于 2018-04-06T23:39:14.657 回答