简体   繁体   中英

How to re-align column of text table in emacs?

When I insert a table using Mx 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 |   |   |
|          |   |   |
+-----+-----+-----+
|     |     |     |
+-----+-----+-----+
|     |     |     |
+-----+-----+-----+

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 Mx org-table-create ) and then you can split long lines over multiple lines within the same cell by calling Mx org-table-wrap-region at the point where you want the split.

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 Mx table-widen-cell and Mx 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 Mx table-unrecognize-table , manually edit the table, then do Mx table-recognize-table . It's not ideal, but sometimes is easiest.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM