I want to create a LaTeX table as follows in python:
duck small dog small
medium medium
large large
how would I do that?
The list I have looks like:
lis=['dog',['small','medium','large],'duck',['small','medium','large']]
I figured this out.
The idea is not to treat this as nested tables but as one table. In this case a table with 4 columns, so you reformat your list as:
lis=[('dog','small','duck','small'),('','medium','','medium'),('','large','','large)]
then use the tabulate package:
from tabulate import tabulate
print(tabulate(lis))
voila:
--- ------ ---- ------
dog small duck small
medium medium
large large
--- ------ ---- ------
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With