-1

I am using PyLaTex to create a pdf document. I'm facing some issues with compilers.

I am running my program on MacOS-High Sierra, and have installed basic version of MacTeX Mactex Download and latexmk is also installed using

sudo tlmgr install latexmk

For the following starter code, I'm getting error in compilers loop. Here's the error log attached after code.

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

Error code:

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

Please help me understand the error and fix the same Regards,

Itachi
  • 2,817
  • 27
  • 35

1 Answers1

0

Looks like a confusion between the compiler keyword argument, which accepts a string and compiler_args which accepts a list. Maybe something like this is what you're after:

doc.generate_pdf('full', clean_tex=False, compiler='latexmk', compiler_args=['-c'])
jackw11111
  • 1,457
  • 1
  • 17
  • 34