9

As a graduate student, I use org-mode to keep track of articles for a lit review. I love tables for their organization, but by default org-mode spreads out tables to fit the content of its fields. How can I fix the width of a column so it doesn't expand if the content gets too long?

2 Answers 2

11

Per the org-mode manual, you can fix the width of an org-mode table column by putting <width> on a line somewhere in that table. I usually put it in its own line directly under the column headers, but anywhere in the column will work.

For example, here are the first two lines of a table:

| Citekey | Topic | Results |
| <15>    | <20>  | <40>    |

When the columns are next aligned, this will fix the width of the first column to 15 characters, the second to 20, and the third to 40. Content that exceeds the width of the column will be truncated with a => to indicate more content. Mousing over the field will show the full contents.

2
  • 1
    From the manual: To edit such a field, use the command C-c ` (that is C-c followed by the grave accent). This will open a new window with the full field. Edit it and finish with C-c C-c.
    – acorello
    Feb 22, 2018 at 21:37
  • The column widths for empty columns do not seem to make it into exported PDFs. That is, the widths of columns in the exported files seem to be determined only by the contents of the table cells.
    – Reb.Cabin
    Nov 25, 2019 at 16:10
7

As mentioned by @Ryan you can use column width cookie <width>. But to make it working in Org 9.2+ you have to put #+startup: shrink in to top of the file or set variable org-startup-align-all-tables to have this behavior in all buffers by default.

(setq org-startup-align-all-tables t)

5
  • 2
    In order for this to take effect, you will need to either revert (i.e. reload) the buffer using M-x revert-buffer or press C-c C-c on the #+startup: shrink line. Aug 16, 2019 at 18:29
  • In 2019 this is the better answer
    – vfclists
    Sep 23, 2019 at 23:42
  • 2
    There are two mistakes in this answer. 1. org-startup-align-all-table variable should be org-startup-align-all-tables (note the plural) 2. To make org-mode automatically shrink tables, you need to set org-startup-shrink-all-tables instead of org-startup-align-all-tables.
    – shouya
    Mar 11, 2021 at 10:18
  • @ShouYa thanks I amended the answer.
    – Navidot
    Mar 11, 2021 at 18:09
  • And it is documented here: gnu.org/software/emacs/manual/html_node/org/….
    – zeit
    Oct 17, 2023 at 7:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .