4

When I insert a table using M-x table-insert

I get the following table:

+-----+-----+-----+ | | | | +-----+-----+-----+ | | | | +-----+-----+-----+ | | | | +-----+-----+-----+ 

But When I add content the | become disaligned like this

+-----+-----+-----+ | content | | | +-----+-----+-----+ | | | | +-----+-----+-----+ | | | | +-----+-----+-----+ 

How do you realign the column?

When I press enter it just creates that:

+-----+-----+-----+ | contecnt | | | | | | | +-----+-----+-----+ | | | | +-----+-----+-----+ | | | | +-----+-----+-----+ 
3
  • Is the org-mode tag relevant? Commented Jan 22, 2018 at 21:44
  • 1
    Well I am using this feature inside an org file. I wanted to have multi-line cell in my table but org-mode table doesn't seem to have that feature. So I am trying to use table.el instead Commented Jan 23, 2018 at 1:11
  • 4
    press tab after you have entered content Commented Jan 23, 2018 at 2:03

4 Answers 4

3

You enter the corresponding cell and start editing the text with C-c' it opens the edit mode and automatically wraps the text accordingly. Once done type C-c' again and you're back in the nicely formated table.

Sign up to request clarification or add additional context in comments.

Comments

2

The table should expand as needed for words longer than the width of the column, and the entire column should widen when this happens. Multiple words will wrap appropriately when the width is reached if there is space to break the line. Remember to use tab to move from cell to cell in the table.

Column width can be changed manually with M-x table-widen-cell and M-x table-narrow-cell.

Sometimes Emacs gets confused for some reason, and something like what you describe happens. One way to fix it is to exit table mode with M-x table-unrecognize-table, manually edit the table, then do M-x table-recognize-table. It's not ideal, but sometimes is easiest.

1 Comment

I tried to press tab. emacs tells me "use C-c to edit table.el tables". and the command M-x table-unrecognize-table and M-x table-recognize-table doesn't seem to have any effect. I tried to make a table in a text file and it does to seem to work better. So I suspect something in org-mode is clashing since it has its own table type.
2

Yes, org-mode table and table-mode table functionality are interfering with one another and preventing the table from realigning properly. I'm not sure how to fix that, but you mentioned in a comment that you are using table-mode specifically because you want multi-lined cells in the table.

I suggest that instead you use an org table (with M-x org-table-create) and then you can split long lines over multiple lines within the same cell by calling M-x org-table-wrap-region at the point where you want the split.

Comments

1

Just press TAB within the table and it will autoalign.

1 Comment

This is true answer.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.