* How to align all tables at once?
@ 2022-11-03 8:19 Jean Louis
2022-11-04 4:50 ` Ihor Radchenko
0 siblings, 1 reply; 4+ messages in thread
From: Jean Louis @ 2022-11-03 8:19 UTC (permalink / raw)
To: Org Mode
I am using Org mode for presentation and would like to use it's tables
for presentation only.
In particular I need the function org-table-align to align the table
in presentation mode.
The Org buffer is updated with results of the below embedded
functions. I can't use Org mode directly as many various expenses are
connected to together.
If it is possible to "jump backwards to Org table" and invoke
org-table-align, I could do that with subsequent function, is it?
This is what is being processed:
------------- snippet
⟦ (ignore (setq my-total 0)) ⟧
⟦ (ignore (defun my-add (n) (setq my-total (+ my-total n)) n)) ⟧
** Monthly Expenses
| Description | Value |
|------------------------------------------+----------------------|
| Communications and Reporting Officer I/C | ⟦ (my-add 600000) ⟧ |
| Prospecting Staff member | ⟦ (my-add 450000) ⟧ |
| Prospecting Staff member | ⟦ (my-add 450000) ⟧ |
| Food for workers on project | ⟦ (my-add 900000) ⟧ |
| Transport Expenses | ⟦ (my-add 1000000) ⟧ |
| Rental | ⟦ (my-add 300000) ⟧ |
|------------------------------------------+----------------------|
| TOTAL | ⟦ my-total ⟧ |
------------- snippet
This is what I get in presentation:
| Description | Value |
|------------------------------------------+----------------------|
| Communications and Reporting Officer I/C | 600000 |
| Prospecting Staff member | 450000 |
| Prospecting Staff member | 450000 |
| Food for workers on project | 900000 |
| Transport Expenses | 1000000 |
| Rental | 300000 |
|------------------------------------------+----------------------|
| TOTAL | 3700000 |
other solution could be to iterate over Org tables to align them.
Anything that exists currently?
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to align all tables at once?
2022-11-03 8:19 How to align all tables at once? Jean Louis
@ 2022-11-04 4:50 ` Ihor Radchenko
2022-11-04 5:49 ` Jean Louis
0 siblings, 1 reply; 4+ messages in thread
From: Ihor Radchenko @ 2022-11-04 4:50 UTC (permalink / raw)
To: Jean Louis; +Cc: Org Mode
Jean Louis <bugs@gnu.support> writes:
> I am using Org mode for presentation and would like to use it's tables
> for presentation only.
>
> In particular I need the function org-table-align to align the table
> in presentation mode.
I am not sure if I understand your use-case, but you may consider
looking at 3.2 Column Width and Alignment section of the manual.
#+STARTUP: align
will align all the tables when opening an Org file.
Babel also auto-aligns tables in results.
Or you can call org-table-align manually.
Also, see org-table-map-tables.
> If it is possible to "jump backwards to Org table" and invoke
> org-table-align, I could do that with subsequent function, is it?
Indeed.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to align all tables at once?
2022-11-04 4:50 ` Ihor Radchenko
@ 2022-11-04 5:49 ` Jean Louis
2022-11-04 8:52 ` Ihor Radchenko
0 siblings, 1 reply; 4+ messages in thread
From: Jean Louis @ 2022-11-04 5:49 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: Org Mode
* Ihor Radchenko <yantar92@posteo.net> [2022-11-04 07:50]:
> Jean Louis <bugs@gnu.support> writes:
>
> > I am using Org mode for presentation and would like to use it's tables
> > for presentation only.
> >
> > In particular I need the function org-table-align to align the table
> > in presentation mode.
>
> I am not sure if I understand your use-case, but you may consider
> looking at 3.2 Column Width and Alignment section of the manual.
Yes, I look inside.
My use case is that Org buffer is used for presentation purpose, it is
not a file, it is generated buffer. This means tables cannot be
aligned before, but after, as the Org buffer does not exist before, it
exists only after rendering.
Then I look in the code by searching for variable
`org-startup-align-all-tables', and I find this within `define-derived-mode':
(unless org-inhibit-startup
(org-unmodified
(when org-startup-with-beamer-mode (org-beamer-mode))
(when (or org-startup-align-all-tables org-startup-shrink-all-tables)
(org-table-map-tables
(cond ((and org-startup-align-all-tables
org-startup-shrink-all-tables)
(lambda () (org-table-align) (org-table-shrink)))
(org-startup-align-all-tables #'org-table-align)
(t #'org-table-shrink))
t))
And I think such larger definitions shall rather be split into smaller
useful functions.
For myself I have made this, which I need to additonally invoke via M-x then it works:
(defun rcd-org-table-align-all ()
(interactive)
(read-only-mode 0)
(org-table-map-tables
(lambda () (org-table-align) (org-table-shrink))
t)
(read-only-mode 1))
> #+STARTUP: align
> will align all the tables when opening an Org file.
And in this case I would like it on the end initialization, not
before. But problem is temporarily solved for Org mode by using M-x
rcd-org-table-align-all as my presentation buffer is in read only mode.
Org has nicer table in its source. Asciidoctor does not have, but then
Asciidoctor renders better PDF tables. So I am now using both
versions, Org and Asciidoctor.
⟦ (ignore (setq my-total 0)) ⟧
⟦ (ignore (defun my-add (n) (setq my-total (+ my-total n))
(format "UGX %s" n))) ⟧
== Monthly Expenses
[cols="4,>1"]
|===
| Description | Value
| Communications and Reporting Officer I/C | ⟦ (my-add 600000) ⟧
| Prospecting Staff member | ⟦ (my-add 450000) ⟧
| Prospecting Staff member | ⟦ (my-add 450000) ⟧
| Food for workers on project | ⟦ (my-add 900000) ⟧
| Transport Expenses | ⟦ (my-add 1000000) ⟧
| Rental | ⟦ (my-add 300000) ⟧
| 500 Prospecting Checks with mapping | ⟦ (my-add (pct-plus 5000000 .30)) ⟧
>| *TOTAL*: | *⟦ (format "UGX %s" my-total) ⟧*
|===
> Babel also auto-aligns tables in results.
Would it be possible to put Org as Babel source, so that I have Org
table inside of Babel and cause Babel to render automatically on the
end of buffer rendering and invocation of org derived mode?
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to align all tables at once?
2022-11-04 5:49 ` Jean Louis
@ 2022-11-04 8:52 ` Ihor Radchenko
0 siblings, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2022-11-04 8:52 UTC (permalink / raw)
To: Jean Louis; +Cc: Org Mode
Jean Louis <bugs@gnu.support> writes:
> Then I look in the code by searching for variable
> `org-startup-align-all-tables', and I find this within `define-derived-mode':
>
> (unless org-inhibit-startup
> (org-unmodified
> (when org-startup-with-beamer-mode (org-beamer-mode))
> (when (or org-startup-align-all-tables org-startup-shrink-all-tables)
> (org-table-map-tables
> (cond ((and org-startup-align-all-tables
> org-startup-shrink-all-tables)
> (lambda () (org-table-align) (org-table-shrink)))
> (org-startup-align-all-tables #'org-table-align)
> (t #'org-table-shrink))
> t))
>
> And I think such larger definitions shall rather be split into smaller
> useful functions.
You are, indeed, right. Patches welcome :)
>> Babel also auto-aligns tables in results.
>
> Would it be possible to put Org as Babel source, so that I have Org
> table inside of Babel and cause Babel to render automatically on the
> end of buffer rendering and invocation of org derived mode?
Yes.
#+begin_src org :results replace
| this | is | table |
| 1 | 2 | 3 |
| laskjdlsakjdsaldjk | | |
#+end_src
#+RESULTS[9f13490e4a64c55f86c49e2839d6c1b34f234a9e]:
| this | is | table |
| 1 | 2 | 3 |
| laskjdlsakjdsaldjk | | |
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-11-04 8:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-03 8:19 How to align all tables at once? Jean Louis
2022-11-04 4:50 ` Ihor Radchenko
2022-11-04 5:49 ` Jean Louis
2022-11-04 8:52 ` Ihor Radchenko
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.