Discussion:
[Orgmode] export table html centered
henry atting
2009-08-15 16:57:19 UTC
Permalink
That is what I am searching for: Is there a markup rule that puts org
tables centered on the resulting page when exported as html.
Seems that #+BEGIN_CENTER – #+END_CENTER does not do this, marking a
table like that solely leads to an error message:

progn: Args out of range: 84, 906


henry
Nick Dokos
2009-08-15 19:50:19 UTC
Permalink
Post by henry atting
That is what I am searching for: Is there a markup rule that puts org
tables centered on the resulting page when exported as html.
Seems that #+BEGIN_CENTER – #+END_CENTER does not do this, marking a
progn: Args out of range: 84, 906
Version info: Org-mode version 6.29trans
GNU Emacs 23.1.50.1 (i686-pc-linux-gnu, GTK+ Version 2.12.9) of 2009-08-09 on gamaville.dokosmarshall.org

I don't get an error using #+BEGIN_CENTER/#+END_CENTER, but otoh I also
don't get a centered table: it's meant for centered paragraphs I think.

The align= attribute for a table is deprecated and I don't know what
the currently recommended method is (probably CSS - but I don't know much
about that). But if you don't mind using deprecated attributes, and assuming
you want *every* table centered, then customizing

org-export-table-header-tags

to add

align="center"

should do it. You can also use #+BIND to do it per-file:

,----
| #+BIND: org-export-html-table-tag "<table align=\"center\" border=\"2\" cellspacing=\"0\" cellpadding=\"6\" rules=\"groups\" frame=\"hsides\">"
| | foo | bar |
| |-----+-----|
| | 1 | 2 |
| | 2 | 5 |
| | 3 | 10 |
`----

HTH,
Nick
Nick Dokos
2009-08-16 01:13:50 UTC
Permalink
... But if you don't mind using deprecated attributes, and assuming
you want *every* table centered, then customizing
org-export-table-header-tags
...
Correction: that should be

org-export-html-table-tag

Sorry about that - the BIND version below is correct.
,----
| #+BIND: org-export-html-table-tag "<table align=\"center\" border=\"2\" cellspacing=\"0\" cellpadding=\"6\" rules=\"groups\" frame=\"hsides\">"
| | foo | bar |
| |-----+-----|
| | 1 | 2 |
| | 2 | 5 |
| | 3 | 10 |
`----
Thanks,
Nick
Carsten Dominik
2009-08-16 05:06:26 UTC
Permalink
Hi Henry, Nick,

another way would be this:

#+STYLE: <style>table.center {margin-left:auto; margin-
right:auto;}</style>

* A centered table

#+ATTR_HTML: class="center"
| a | b | c |
|---+---+---|
| 1 | 2 | 3 |

* An uncentered table

| a | b | c |
|---+---+---|
| 1 | 2 | 3 |


You can also configure org-export-html-table-tag to add the
class="center"
if you want to center all tables.

HTH

- Carsten
Post by Nick Dokos
... But if you don't mind using deprecated attributes, and assuming
you want *every* table centered, then customizing
org-export-table-header-tags
...
Correction: that should be
org-export-html-table-tag
Sorry about that - the BIND version below is correct.
,----
| #+BIND: org-export-html-table-tag "<table align=\"center\"
border=\"2\" cellspacing=\"0\" cellpadding=\"6\" rules=\"groups\"
frame=\"hsides\">"
| | foo | bar |
| |-----+-----|
| | 1 | 2 |
| | 2 | 5 |
| | 3 | 10 |
`----
Thanks,
Nick
_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
henry atting
2009-08-16 10:22:42 UTC
Permalink
Post by Carsten Dominik
Hi Henry, Nick,
#+STYLE: <style>table.center {margin-left:auto; margin-
right:auto;}</style>
* A centered table
#+ATTR_HTML: class="center"
| a | b | c |
|---+---+---|
| 1 | 2 | 3 |
* An uncentered table
| a | b | c |
|---+---+---|
| 1 | 2 | 3 |
You can also configure org-export-html-table-tag to add the
class="center"
if you want to center all tables.
HTH
- Carsten
Post by Nick Dokos
... But if you don't mind using deprecated attributes, and assuming
you want *every* table centered, then customizing
org-export-table-header-tags
...
Correction: that should be
org-export-html-table-tag
Sorry about that - the BIND version below is correct.
,----
| #+BIND: org-export-html-table-tag "<table align=\"center\"
border=\"2\" cellspacing=\"0\" cellpadding=\"6\" rules=\"groups\"
frame=\"hsides\">"
| | foo | bar |
| |-----+-----|
| | 1 | 2 |
| | 2 | 5 |
| | 3 | 10 |
`----
Thanks,
Nick
Hi Nick, hi Dominik,

as I have my own stylesheet I did not deal with the #+STYLE option to
much. But it's very helpful, great.

Many thanks
henry

Continue reading on narkive:
Loading...