1

I have created a document base on this example. But I want to use only table part rather than whole document. I have spent plenty of time libraries of PyLaTeX. I could not find how I can do.

2

The LongTable class has the generate_tex method, so you can do

from pylatex import LongTable, MultiColumn    

# Generate data table
data_table = LongTable('lll')
data_table.add_hline()
data_table.add_row(["header 1", "header 2", "header 3"])
data_table.add_hline()
data_table.end_table_header()
data_table.add_hline()
data_table.add_row((MultiColumn(3, align='r',
                    data='Containued on Next Page'),))
data_table.add_hline()
data_table.end_table_footer()
data_table.add_hline()
data_table.add_row((MultiColumn(3, align='r',
                    data='Not Containued on Next Page'),))
data_table.add_hline()
data_table.end_table_last_footer()
row = ["Content1", "9", "Longer String"]
for i in range(150):
    data_table.add_row(row)

data_table.generate_tex('tablefile')

to create a file tablefile.tex containing only the longtable environment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.