reddit / emacs
How do I deal with long lines on org-mode tables?
ahopefullycuterrobot · 2022-06-13 16:58
I want to be able to use tables to organise qualitative material. E.g. Book and article names, the types of properties that different primates have, lecture titles, and links to the notes, homework, and readings for that particular lecture. These types of materials often have relatively long lines.
When I try to use tables in Org Mode, the results are unreadable.
Before I hit tab, the results are fine if a bit basic.
https://preview.redd.it/hzoxzaxb5f591.png?width=1319&format=png&auto=webp&s=b993d4c1dbd59e2d9beee8a62427278e9551ff76
But when I tab or hit enter, the columns are out of alignment to the point where one column is under the next.
https://preview.redd.it/jjbonp3g5f591.png?width=1336&format=png&auto=webp&s=49d3fb66573f1444df01bbbbdf17f2a6da32530d
I tried [setting the width for each cell by making a row at the top](https://orgmode.org/worg/org-tutorials/tables.html), but that didn't seem to change anything.
Is there some setting in Org Mode I can toggle to change this? Some attribute I need to set for each table? I have visual line mode and wordwrap enabled. Do I need to turn those off? Is there another package I should be using? Is there some error in my formatting?
Taloth · 2022-06-13 17:14
AFAIK your only options are to turn off line wrapping for the whole document (`M-x toggle-truncate-lines`) or decrease text size. You could use `M-x text-scale-adjust` or customize the height for org tables (e.g. set it to `0.75`).
ahopefullycuterrobot · 2022-06-13 17:23
> turn off line wrapping for the whole document
Is there a way to set that on a per document basis? Like how I can set visibility as a property.
I don't want to have to remember to toggle each time, but I want line wrapping for some documents (pretty much anything without tables) and then no line wrapping for any document with tables.
Also, I'm not too committed to using org mode for tables. Is there another (simple) package that deals with tables so I can make a table and just link to it in org mode?
EDIT: Also, thank you!
paretoOptimalDev · 2022-06-13 17:27
Maybe it was a dream or related package, but I could have sworn there were *vertical* org tables and a function to convert a normal table to it.
There's also tabel.el, but i'm guessing it might not work for you.
Edit: here was the transpose function: https://pragmaticemacs.wordpress.com/2016/10/09/transpose-a-table-in-org-mode/
paretoOptimalDev · 2022-06-13 17:50
Another solution:
https://emacsnotes.wordpress.com/2020/04/26/create-tables-with-paragraph-like-content-in-org-mode-with-the-least-amount-of-hassle/
ahopefullycuterrobot · 2022-06-13 17:55
>There's also tabel.el, but i'm guessing it might not work for you.
What would be the issue with tabel.el? I'm pretty open to trying anything lol.
Actually, I found an example of [using tabel.el from Stack Exchange](https://emacs.stackexchange.com/questions/38135/wrap-cell-content-in-an-org-mode-table). I just tried it out and it seems to work fine. The table is now much more readable.
paretoOptimalDev · 2022-06-13 18:37
Great to hear it worked. Just a guess based on having frustration with it at some point, but I probably misunderstood it.
organic-bookworm · 2022-06-13 20:34
>I tried setting the width for each cell by making a row at the top, but that didn't seem to change anything.
See [`org-table-toggle-column-width`](https://orgmode.org/manual/Column-Width-and-Alignment.html#Column-Width-and-Alignment) command and friends.
organic-bookworm · 2022-06-13 20:38
>I'm pretty open to trying anything lol.
Welp, how about [`columnview`](https://orgmode.org/manual/Capturing-column-view.html#Capturing-column-view) block?
Here's an example
#+begin: columnview :id global :format "%item(category) %long %short"
| category | long | short |
|----------+-------+--------|
| Topic 1 | long | short |
| Topic 2 | long1 | short1 |
#+end
* Topic 1
:PROPERTIES:
:long: long
:short: short
:END:
* Topic 2
:PROPERTIES:
:long: long1
:short: short1
:END:
7890yuiop · 2022-06-13 23:20
I suggest binding `toggle-truncate-lines` to some key sequence for convenience. I have it on `s-\`
vfclists · 2022-06-13 23:32
How about the `<20>`, `<10>` widgets placed under the headers to set the width for viewing then you can use `C-c tab` to toggle between showing the truncated column and the whole column when necessary?
What are the called, slugs?
Taloth · 2022-06-14 02:09
You can use Local Variables to set file-specific settings. Place this at the top of the org file:
# -*- truncate-lines: t -*-
The `# ` isn't actually necessary, but makes it look nicer in org-mode.
Not sure about another table package unfortunately, but I would be surprised if anything came close to org-mode tables for use within emacs.
I would also recommend /u/vfclists' solution, I actually had no idea that was possible but I'll definitely be using it now!
ElCondorHerido · 2022-06-14 02:38
It has some problems (a.k.a. it freezes emacs on specific events), but https://github.com/misohena/phscroll is what I use for this
variably_random · 2022-06-14 06:40
Second this. phscroll has always worked great for me.
otnememento · 2022-06-14 06:56
Oh, that‘s looks nice. Thanks!