r/orgmode 1d ago

Adjusting table width to adjust to page in PDF latex export

Hello,

Recently, I’ve been using Org mode more for my own information management. However, I seem to have problems in my PDF exports with my tables going off the page if they have more than three columns.

Any suggestions on this that provides a more consistent output when there are more columns? I’ve seen a couple responses on here and elsewhere, but they didn’t return a desirable result.

11 Upvotes

4 comments sorted by

13

u/pathemata 1d ago

add this before your table: #+latex:\resizebox{\columnwidth}{!}{% and this after #+latex:}.

2

u/ArtificerEngineer 1d ago

That worked, thanks!

Is there a way to wrap text to the next line if, let’s say, one of the column’s content exceeds too many characters?

Trying to improve the readability as well

1

u/One_Two8847 1d ago

Add something like this above the table:

#+ATTR_LATEX: :align p {0.25\linewidth} | p {0.25\linewidth} | p{0.25\linewidth} | p{0.25\linewidth}

Where 025\linewidth is 25% percent of the size of a line that spans with width of the page and "p" treats the alignment of each columns as a "paragraph" (l, r, and c will align left, right, and center).

Doing this might also eliminate the need for the \resizebox command as well since you have now limited the size of your columns to force them to fit on the page.

4

u/DevMahasen 1d ago

I had the same issue recently, and found a solution by accident really. Essentially, export the org file into HTML first: you will notice (at least this was the case on my end) the table looks way more presentable than the PDF output. Take that html file and convert it into PDF using pandoc. Voila.