1 day ago · Tech · hide · 0 comments

Typesetting tables in latex is annoying. In practice, I usually have the tabular data in some programming-friendly format and need to put it in latex. I forget how to do this nicely, but it's extremely simple using the tabulate package in python. import tabulate from itertools import batched # Data A = [ 1, 2, 3, 4, 5, 6, 7, 10, 11, 14, 15, 17, 19, 21, 23, 26, 31, 34, 35, 39, 41, 47, 51, 55, 59, 71, 79, 87, 95, 111, 119, 131, 143, 159, 167, 191, 215, 231, 239, 287, 311, 359, 479, 551, 671, 719 ] print(len(A)) # 46 # We have to choose the number of columns. I choose 12 here. data = list(batched(A, 12)) print(tabulate.tabulate(data, tablefmt="latex_booktabs")) This outputs {rrrrrrrrrrrr} \toprule 1 & 2 & 3 & 4 & 5 & 6 & 7 & 10 & 11 & 14 & 15 & 17 \\ 19 & 21 & 23 & 26 & 31 & 34 & 35 & 39 & 41 & 47 & 51 & 55 \\ 59 & 71 & 79 & 87 & 95 & 111 & 119 & 131 & 143 & 159 & 167 & 191 \\ 215 & 231 & 239 & 287 & 311 & 359 & 479 & 551 & 671 & 719 & & \\ \bottomrule The point is that this can be done…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.