* [patch] LaTeX export using tabu tables
@ 2013-03-23 4:26 Eric Abrahamsen
2013-03-24 0:18 ` Vikas Rawal
2013-03-24 9:26 ` Nicolas Goaziou
0 siblings, 2 replies; 13+ messages in thread
From: Eric Abrahamsen @ 2013-03-23 4:26 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1221 bytes --]
There are about forty different table environments for latex, all of
which do slightly different things, and none of them seem to do it all.
I found the "tabu" package recently, and thought "oh god another one",
but it seems to do it all: clever column alignment, longtable
functionality, all that good stuff.
Attached is a patch that lets you use the "tabu" and "longtabu" table
environments. Mostly the patch is necessary because tabu has its own
annoying syntax for table width declarations. Where everyone else does
something like:
\begin{tabular}{\textwidth}{cllr}
tabu does this:
\begin{tabu} to \textwidth {cllr}
Where you're allowed to use either "to" or "spread". Annoying, but in my
case still worth it. Since table plists can handle spaces, this works
with the attached patch:
#+ATTR_LATEX: :environment tabu :width to \textwidth :font \scriptsize :align rXrXrr
Actually I've just set `org-latex-default-table-environment' to tabu.
Dunno if this is worth it for other people, but there's the patch. If
access to the "spread" keyword isn't worth the trouble I can hard-code
"to": that would at least mean you could switch between table and tabu
without having to edit your ATTR_LATEX lines.
Yrs,
Eric
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0008-Allow-LaTeX-export-of-tables-using-the-tabu-package.patch --]
[-- Type: text/x-patch, Size: 2901 bytes --]
From ff2635d43509481ea4b72596a325a6f155dc0cfe Mon Sep 17 00:00:00 2001
From: Eric Abrahamsen <eric@ericabrahamsen.net>
Date: Sat, 23 Mar 2013 12:15:29 +0800
Subject: [PATCH 8/8] Allow LaTeX export of tables using the tabu package
---
lisp/ox-latex.el | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 310fa14..1410b49 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -2429,7 +2429,7 @@ This function assumes TABLE has `org' as its `:type' property and
org-latex-default-table-environment))
;; If table is a float, determine environment: table, table*
;; or sidewaystable.
- (float-env (unless (equal "longtable" table-env)
+ (float-env (unless (string-match-p "longtab" table-env)
(let ((float (plist-get attr :float)))
(cond
((string= float "sidewaystable") "sidewaystable")
@@ -2447,10 +2447,12 @@ This function assumes TABLE has `org' as its `:type' property and
org-latex-tables-centered)))
;; Prepare the final format string for the table.
(cond
- ;; Longtable.
- ((equal "longtable" table-env)
+ ;; Longtable or longtabu.
+ ((string-match-p "longtab" table-env)
(concat (and fontsize (concat "{" fontsize))
- (format "\\begin{longtable}{%s}\n" alignment)
+ (format "\\begin{%s}%s{%s}\n" table-env
+ (if (and width (equal "longtabu" table-env))
+ (format " %s " width) "") alignment)
(and org-latex-table-caption-above
(org-string-nw-p caption)
(concat caption "\\\\\n"))
@@ -2458,7 +2460,7 @@ This function assumes TABLE has `org' as its `:type' property and
(and (not org-latex-table-caption-above)
(org-string-nw-p caption)
(concat caption "\\\\\n"))
- "\\end{longtable}\n"
+ (format "\\end{%s}\n" table-env)
(and fontsize "}")))
;; Others.
(t (concat (cond
@@ -2471,7 +2473,10 @@ This function assumes TABLE has `org' as its `:type' property and
(fontsize (concat "{" fontsize)))
(format "\\begin{%s}%s{%s}\n%s\\end{%s}"
table-env
- (if width (format "{%s}" width) "")
+ (if width (format
+ (if (equal "tabu" table-env)
+ " %s "
+ "{%s}") width) "")
alignment
contents
table-env)
@@ -2634,9 +2639,9 @@ a communication channel."
(when (eq (org-element-property :type table-row) 'standard)
(let* ((attr (org-export-read-attribute :attr_latex
(org-export-get-parent table-row)))
- (longtablep (string= (or (plist-get attr :environment)
- org-latex-default-table-environment)
- "longtable"))
+ (longtablep (string-match-p "longtab"
+ (or (plist-get attr :environment)
+ org-latex-default-table-environment)))
(booktabsp (if (plist-member attr :booktabs)
(plist-get attr :booktabs)
org-latex-tables-booktabs))
--
1.8.2
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [patch] LaTeX export using tabu tables
2013-03-23 4:26 [patch] LaTeX export using tabu tables Eric Abrahamsen
@ 2013-03-24 0:18 ` Vikas Rawal
2013-03-24 9:26 ` Nicolas Goaziou
1 sibling, 0 replies; 13+ messages in thread
From: Vikas Rawal @ 2013-03-24 0:18 UTC (permalink / raw)
To: Eric Abrahamsen; +Cc: emacs-orgmode
>
> Attached is a patch that lets you use the "tabu" and "longtabu" table
> environments. Mostly the patch is necessary because tabu has its own
> annoying syntax for table width declarations. Where everyone else does
> something like:
Great!
> Dunno if this is worth it for other people, but there's the patch. If
> access to the "spread" keyword isn't worth the trouble I can hard-code
> "to": that would at least mean you could switch between table and tabu
> without having to edit your ATTR_LATEX lines.
>
I think that would be better. Capability to switch between different
table environments should be important from a user's perspective.
Vikas
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch] LaTeX export using tabu tables
2013-03-23 4:26 [patch] LaTeX export using tabu tables Eric Abrahamsen
2013-03-24 0:18 ` Vikas Rawal
@ 2013-03-24 9:26 ` Nicolas Goaziou
2013-03-25 5:35 ` Eric Abrahamsen
1 sibling, 1 reply; 13+ messages in thread
From: Nicolas Goaziou @ 2013-03-24 9:26 UTC (permalink / raw)
To: Eric Abrahamsen; +Cc: emacs-orgmode
Hello,
Eric Abrahamsen <eric@ericabrahamsen.net> writes:
> Attached is a patch that lets you use the "tabu" and "longtabu" table
> environments. Mostly the patch is necessary because tabu has its own
> annoying syntax for table width declarations. Where everyone else does
> something like:
>
> \begin{tabular}{\textwidth}{cllr}
>
> tabu does this:
>
> \begin{tabu} to \textwidth {cllr}
>
> Where you're allowed to use either "to" or "spread". Annoying, but in my
> case still worth it. Since table plists can handle spaces, this works
> with the attached patch:
>
> #+ATTR_LATEX: :environment tabu :width to \textwidth :font \scriptsize :align rXrXrr
>
> Actually I've just set `org-latex-default-table-environment' to tabu.
Thanks for your patch. I didn't know about "tabu" package, but it looks
interesting.
I added some comments and suggestions wrt to the patch.
> Dunno if this is worth it for other people, but there's the patch. If
> access to the "spread" keyword isn't worth the trouble I can hard-code
> "to": that would at least mean you could switch between table and tabu
> without having to edit your ATTR_LATEX lines.
You could also add another attribute, :spread, which would used "spread"
instead of "to" when non-nil. This way, users can have the best of both
worlds.
That new attribute needs to be documented in the comments at the
beginning of the library.
> Subject: [PATCH 8/8] Allow LaTeX export of tables using the tabu
> package
You need to list each modified function in the commit message.
> ---
> lisp/ox-latex.el | 23 ++++++++++++++---------
> 1 file changed, 14 insertions(+), 9 deletions(-)
>
> diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
> index 310fa14..1410b49 100644
> --- a/lisp/ox-latex.el
> +++ b/lisp/ox-latex.el
> @@ -2429,7 +2429,7 @@ This function assumes TABLE has `org' as its `:type' property and
> org-latex-default-table-environment))
> ;; If table is a float, determine environment: table, table*
> ;; or sidewaystable.
> - (float-env (unless (equal "longtable" table-env)
> + (float-env (unless (string-match-p "longtab" table-env)
IMO, it's cleaner (as in more explicit) to use:
(unless (member table-env '("longtable" "longtabu")) ...)
> - ;; Longtable.
> - ((equal "longtable" table-env)
> + ;; Longtable or longtabu.
> + ((string-match-p "longtab" table-env)
Ditto.
You may also use another branch in the `cond', in order to clearly
separate "tabu" and "longtabu" environments from other packages. It
would lead to some code duplication, but would allow for easier
development of tabu specific features (e.g. :spread keyword), if ever
needed.
> - (longtablep (string= (or (plist-get attr :environment)
> - org-latex-default-table-environment)
> - "longtable"))
> + (longtablep (string-match-p "longtab"
> + (or (plist-get attr :environment)
> + org-latex-default-table-environment)))
See remark above.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch] LaTeX export using tabu tables
2013-03-24 9:26 ` Nicolas Goaziou
@ 2013-03-25 5:35 ` Eric Abrahamsen
2013-03-25 5:54 ` Bastien
` (2 more replies)
0 siblings, 3 replies; 13+ messages in thread
From: Eric Abrahamsen @ 2013-03-25 5:35 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1129 bytes --]
Nicolas Goaziou <n.goaziou@gmail.com> writes:
> Thanks for your patch. I didn't know about "tabu" package, but it looks
> interesting.
It's definitely my new go-to table environment, though I'm struggling to
ignore the fact that it's got the ugliest documentation of any LaTeX
package I've ever seen.
> You could also add another attribute, :spread, which would used "spread"
> instead of "to" when non-nil. This way, users can have the best of both
> worlds.
[...]
> You need to list each modified function in the commit message.
[...]
> IMO, it's cleaner (as in more explicit) to use:
>
> (unless (member table-env '("longtable" "longtabu")) ...)
>
> You may also use another branch in the `cond', in order to clearly
> separate "tabu" and "longtabu" environments from other packages. It
> would lead to some code duplication, but would allow for easier
> development of tabu specific features (e.g. :spread keyword), if ever
> needed.
I was trying to be too clever! Attached is a non-clever version that
includes a :spread keyword, and a (hopefully) correctly-written commit
message.
Thanks for the pointers,
Eric
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0008-ox-latex.el-org-latex-org-table-org-latex-table-row-.patch --]
[-- Type: text/x-patch, Size: 4423 bytes --]
From d4daaff48978958b788d4dd3f7434b7db276e4ac Mon Sep 17 00:00:00 2001
From: Eric Abrahamsen <eric@ericabrahamsen.net>
Date: Mon, 25 Mar 2013 13:27:33 +0800
Subject: [PATCH 8/8] ox-latex.el (org-latex--org-table, org-latex-table-row):
Allow use of the "tabu" table environment when exporting tables to LaTeX.
* ox-latex.el (org-latex--org-table): New latex export attribute
:spread accommodates weird width specification syntax of the tabu
package.
---
lisp/ox-latex.el | 39 +++++++++++++++++++++++++++++++++------
1 file changed, 33 insertions(+), 6 deletions(-)
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 310fa14..49463ca 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -48,7 +48,7 @@
;; - The second most important attribute is `:environment'. It is the
;; environment used for the table and defaults to
;; `org-latex-default-table-environment' value. It can be set to
-;; anything, including "tabularx", "longtable", "array",
+;; anything, including "tabularx", "longtable", "array", "tabu",
;; "bmatrix"...
;;
;; - `:float' attribute defines a float environment for the table.
@@ -61,6 +61,12 @@
;; alignment string of the table, its font size and its width. They
;; only apply on regular tables.
;;
+;; - `:spread' is a boolean attribute specific to the "tabu" and
+;; "longtabu" environments, and only takes effect when used in
+;; conjunction with the `:width' attribute. When `:spread' is
+;; present, the table will be spread or shrunk by the value of
+;; `:width'.
+;;
;; - `:booktabs', `:center' and `:rmlines' values are booleans. They
;; toggle, respectively "booktabs" usage (assuming the package is
;; properly loaded), table centering and removal of every horizontal
@@ -2429,7 +2435,7 @@ This function assumes TABLE has `org' as its `:type' property and
org-latex-default-table-environment))
;; If table is a float, determine environment: table, table*
;; or sidewaystable.
- (float-env (unless (equal "longtable" table-env)
+ (float-env (unless (member table-env '("longtabu" "longtable"))
(let ((float (plist-get attr :float)))
(cond
((string= float "sidewaystable") "sidewaystable")
@@ -2441,6 +2447,7 @@ This function assumes TABLE has `org' as its `:type' property and
(fontsize (let ((font (plist-get attr :font)))
(and font (concat font "\n"))))
(width (plist-get attr :width))
+ (spread (plist-member attr :spread))
(placement (or (plist-get attr :placement)
(format "[%s]" org-latex-default-figure-position)))
(centerp (if (plist-member attr :center) (plist-get attr :center)
@@ -2460,6 +2467,23 @@ This function assumes TABLE has `org' as its `:type' property and
(concat caption "\\\\\n"))
"\\end{longtable}\n"
(and fontsize "}")))
+ ;; Longtabu
+ ((equal "longtabu" table-env)
+ (concat (and fontsize (concat "{" fontsize))
+ (format "\\begin{longtabu}%s{%s}\n"
+ (if width
+ (format " %s %s "
+ (if spread "spread" "to") width) "")
+ alignment)
+ (and org-latex-table-caption-above
+ (org-string-nw-p caption)
+ (concat caption "\\\\\n"))
+ contents
+ (and (not org-latex-table-caption-above)
+ (org-string-nw-p caption)
+ (concat caption "\\\\\n"))
+ "\\end{longtabu}\n"
+ (and fontsize "}")))
;; Others.
(t (concat (cond
(float-env
@@ -2471,7 +2495,10 @@ This function assumes TABLE has `org' as its `:type' property and
(fontsize (concat "{" fontsize)))
(format "\\begin{%s}%s{%s}\n%s\\end{%s}"
table-env
- (if width (format "{%s}" width) "")
+ (if width (format
+ (if (equal "tabu" table-env)
+ (if spread " spread %s " " to %s")
+ "{%s}") width) "")
alignment
contents
table-env)
@@ -2634,9 +2661,9 @@ a communication channel."
(when (eq (org-element-property :type table-row) 'standard)
(let* ((attr (org-export-read-attribute :attr_latex
(org-export-get-parent table-row)))
- (longtablep (string= (or (plist-get attr :environment)
- org-latex-default-table-environment)
- "longtable"))
+ (longtablep (member (or (plist-get attr :environment)
+ org-latex-default-table-environment)
+ '("longtable" "longtabu")))
(booktabsp (if (plist-member attr :booktabs)
(plist-get attr :booktabs)
org-latex-tables-booktabs))
--
1.8.2
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [patch] LaTeX export using tabu tables
2013-03-25 5:35 ` Eric Abrahamsen
@ 2013-03-25 5:54 ` Bastien
2013-03-25 6:54 ` Eric Abrahamsen
2013-03-25 19:59 ` Nicolas Goaziou
2013-03-26 20:05 ` Marcin Borkowski
2 siblings, 1 reply; 13+ messages in thread
From: Bastien @ 2013-03-25 5:54 UTC (permalink / raw)
To: Eric Abrahamsen; +Cc: emacs-orgmode
Hi Eric,
Eric Abrahamsen <eric@ericabrahamsen.net> writes:
> Attached is a non-clever version that includes a :spread keyword,
> and a (hopefully) correctly-written commit message.
Thanks!
I was surprised not to find you on the list of FSF-signed contributors
-- did you assigned your copyright to the FSF already? If not, you'll
need to go through this for the patch to be included I'm afraid...
Thanks for letting us know.
Best,
--
Bastien
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch] LaTeX export using tabu tables
2013-03-25 6:54 ` Eric Abrahamsen
@ 2013-03-25 6:51 ` Bastien
0 siblings, 0 replies; 13+ messages in thread
From: Bastien @ 2013-03-25 6:51 UTC (permalink / raw)
To: Eric Abrahamsen; +Cc: emacs-orgmode
Hi Eric,
Eric Abrahamsen <eric@ericabrahamsen.net> writes:
> Huh, that surprises me too! I looked in my files and I'm supposed to be
> RT:710483, whatever that means -- they told me it would apply to any
> emacs-related packages...
We're all set then, I added you to the page:
http://orgmode.org/worg/org-contribute.html#contributors_with_fsf_papers
Thanks for confirming!
--
Bastien
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch] LaTeX export using tabu tables
2013-03-25 5:54 ` Bastien
@ 2013-03-25 6:54 ` Eric Abrahamsen
2013-03-25 6:51 ` Bastien
0 siblings, 1 reply; 13+ messages in thread
From: Eric Abrahamsen @ 2013-03-25 6:54 UTC (permalink / raw)
To: emacs-orgmode
Bastien <bzg@altern.org> writes:
> Hi Eric,
>
> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>> Attached is a non-clever version that includes a :spread keyword,
>> and a (hopefully) correctly-written commit message.
>
> Thanks!
>
> I was surprised not to find you on the list of FSF-signed contributors
> -- did you assigned your copyright to the FSF already? If not, you'll
> need to go through this for the patch to be included I'm afraid...
Huh, that surprises me too! I looked in my files and I'm supposed to be
RT:710483, whatever that means -- they told me it would apply to any
emacs-related packages...
>
> Thanks for letting us know.
>
> Best,
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch] LaTeX export using tabu tables
2013-03-25 5:35 ` Eric Abrahamsen
2013-03-25 5:54 ` Bastien
@ 2013-03-25 19:59 ` Nicolas Goaziou
2013-03-26 2:54 ` Eric Abrahamsen
2013-03-26 20:05 ` Marcin Borkowski
2 siblings, 1 reply; 13+ messages in thread
From: Nicolas Goaziou @ 2013-03-25 19:59 UTC (permalink / raw)
To: Eric Abrahamsen; +Cc: emacs-orgmode
Hello,
Eric Abrahamsen <eric@ericabrahamsen.net> writes:
> I was trying to be too clever! Attached is a non-clever version that
> includes a :spread keyword, and a (hopefully) correctly-written commit
> message.
Nice. A few more comments follow.
> Subject: [PATCH 8/8] ox-latex.el (org-latex--org-table, org-latex-table-row):
> Allow use of the "tabu" table environment when exporting tables to
> LaTeX.
Actually the first line of the commit should be more general (and
shouldn't end with a full stop). Perhaps something like:
ox-latex: Allow use of "tabu" table environment
> * ox-latex.el (org-latex--org-table): New latex export attribute
> :spread accommodates weird width specification syntax of the tabu
> package.
I would drop a note about the "tabu" and "longtabu" support in the
description of the patch.
> +;; - `:spread' is a boolean attribute specific to the "tabu" and
> +;; "longtabu" environments, and only takes effect when used in
> +;; conjunction with the `:width' attribute. When `:spread' is
Nitpick: Emacs documentation and comments require two spaces after
a sentence.
> + (spread (plist-member attr :spread))
I think you mean (plist-get attr :spread), otherwise ":spread nil" will
still activate spread. Also, since it's a predicate, I suggest to name
the variable "spreadp".
> (placement (or (plist-get attr :placement)
> (format "[%s]" org-latex-default-figure-position)))
> (centerp (if (plist-member attr :center) (plist-get attr :center)
> @@ -2460,6 +2467,23 @@ This function assumes TABLE has `org' as its `:type' property and
> (concat caption "\\\\\n"))
> "\\end{longtable}\n"
> (and fontsize "}")))
> + ;; Longtabu
> + ((equal "longtabu" table-env)
> + (concat (and fontsize (concat "{" fontsize))
> + (format "\\begin{longtabu}%s{%s}\n"
> + (if width
> + (format " %s %s "
> + (if spread "spread" "to") width) "")
> + alignment)
> + (and org-latex-table-caption-above
> + (org-string-nw-p caption)
> + (concat caption "\\\\\n"))
> + contents
> + (and (not org-latex-table-caption-above)
> + (org-string-nw-p caption)
> + (concat caption "\\\\\n"))
> + "\\end{longtabu}\n"
> + (and fontsize "}")))
> ;; Others.
> (t (concat (cond
> (float-env
> @@ -2471,7 +2495,10 @@ This function assumes TABLE has `org' as its `:type' property and
> (fontsize (concat "{" fontsize)))
> (format "\\begin{%s}%s{%s}\n%s\\end{%s}"
> table-env
> - (if width (format "{%s}" width) "")
> + (if width (format
> + (if (equal "tabu" table-env)
> + (if spread " spread %s " " to %s")
> + "{%s}") width) "")
"longtabu" gets its own cond branch, but not "tabu". I think that
defeats the purpose of the separation, which is to be able to add
support for features of this rich table environment without cluttering
the rest of the code. Doing it partially isn't worth the code
duplication it implies.
IOW, either we separate both "tabu" and "longtabu" completely, or we
separate none of them. Your call.
Thank you again.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch] LaTeX export using tabu tables
2013-03-25 19:59 ` Nicolas Goaziou
@ 2013-03-26 2:54 ` Eric Abrahamsen
2013-03-27 14:29 ` Nicolas Goaziou
0 siblings, 1 reply; 13+ messages in thread
From: Eric Abrahamsen @ 2013-03-26 2:54 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 943 bytes --]
Nicolas Goaziou <n.goaziou@gmail.com> writes:
I'll get this right eventually...
>> + (spread (plist-member attr :spread))
>
> I think you mean (plist-get attr :spread), otherwise ":spread nil" will
> still activate spread. Also, since it's a predicate, I suggest to name
> the variable "spreadp".
Me being clever again -- I misunderstood how that would work.
[...]
> "longtabu" gets its own cond branch, but not "tabu". I think that
> defeats the purpose of the separation, which is to be able to add
> support for features of this rich table environment without cluttering
> the rest of the code. Doing it partially isn't worth the code
> duplication it implies.
>
> IOW, either we separate both "tabu" and "longtabu" completely, or we
> separate none of them. Your call.
I've kept the separation. There was no need to duplicate all the float
environment stuff, so there's not too much extra code.
Thanks for all the pointers!
Eric
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox-latex-Allow-use-of-the-tabu-and-longtabu-table-en.patch --]
[-- Type: text/x-patch, Size: 4763 bytes --]
From 675c33c7939795758ae6d1c2b33201bd25a6ac6e Mon Sep 17 00:00:00 2001
From: Eric Abrahamsen <eric@ericabrahamsen.net>
Date: Tue, 26 Mar 2013 10:45:30 +0800
Subject: [PATCH] ox-latex: Allow use of the "tabu" and "longtabu" table
environments
* lisp/ox-latex.el (org-latex--org-table, org-latex-table-row): New
table attribute :spread handles the width specification syntax of
"tabu" and "longtabu" table environments.
---
lisp/ox-latex.el | 51 +++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 41 insertions(+), 10 deletions(-)
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 310fa14..7ca1f94 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -48,7 +48,7 @@
;; - The second most important attribute is `:environment'. It is the
;; environment used for the table and defaults to
;; `org-latex-default-table-environment' value. It can be set to
-;; anything, including "tabularx", "longtable", "array",
+;; anything, including "tabularx", "longtable", "array", "tabu",
;; "bmatrix"...
;;
;; - `:float' attribute defines a float environment for the table.
@@ -61,6 +61,12 @@
;; alignment string of the table, its font size and its width. They
;; only apply on regular tables.
;;
+;; - `:spread' is a boolean attribute specific to the "tabu" and
+;; "longtabu" environments, and only takes effect when used in
+;; conjunction with the `:width' attribute. When `:spread' is
+;; present, the table will be spread or shrunk by the value of
+;; `:width'.
+;;
;; - `:booktabs', `:center' and `:rmlines' values are booleans. They
;; toggle, respectively "booktabs" usage (assuming the package is
;; properly loaded), table centering and removal of every horizontal
@@ -2429,7 +2435,7 @@ This function assumes TABLE has `org' as its `:type' property and
org-latex-default-table-environment))
;; If table is a float, determine environment: table, table*
;; or sidewaystable.
- (float-env (unless (equal "longtable" table-env)
+ (float-env (unless (member table-env '("longtable" "longtabu"))
(let ((float (plist-get attr :float)))
(cond
((string= float "sidewaystable") "sidewaystable")
@@ -2441,6 +2447,7 @@ This function assumes TABLE has `org' as its `:type' property and
(fontsize (let ((font (plist-get attr :font)))
(and font (concat font "\n"))))
(width (plist-get attr :width))
+ (spreadp (plist-get attr :spread))
(placement (or (plist-get attr :placement)
(format "[%s]" org-latex-default-figure-position)))
(centerp (if (plist-member attr :center) (plist-get attr :center)
@@ -2460,6 +2467,23 @@ This function assumes TABLE has `org' as its `:type' property and
(concat caption "\\\\\n"))
"\\end{longtable}\n"
(and fontsize "}")))
+ ;; Longtabu
+ ((equal "longtabu" table-env)
+ (concat (and fontsize (concat "{" fontsize))
+ (format "\\begin{longtabu}%s{%s}\n"
+ (if width
+ (format " %s %s "
+ (if spreadp "spread" "to") width) "")
+ alignment)
+ (and org-latex-table-caption-above
+ (org-string-nw-p caption)
+ (concat caption "\\\\\n"))
+ contents
+ (and (not org-latex-table-caption-above)
+ (org-string-nw-p caption)
+ (concat caption "\\\\\n"))
+ "\\end{longtabu}\n"
+ (and fontsize "}")))
;; Others.
(t (concat (cond
(float-env
@@ -2469,12 +2493,19 @@ This function assumes TABLE has `org' as its `:type' property and
fontsize))
(centerp (concat "\\begin{center}\n" fontsize))
(fontsize (concat "{" fontsize)))
- (format "\\begin{%s}%s{%s}\n%s\\end{%s}"
- table-env
- (if width (format "{%s}" width) "")
- alignment
- contents
- table-env)
+ (cond ((equal "tabu" table-env)
+ (format "\\begin{tabu}%s{%s}\n%s\\end{tabu}"
+ (if width (format
+ (if spreadp " spread %s " " to %s ")
+ width) "")
+ alignment
+ contents))
+ (t (format "\\begin{%s}%s{%s}\n%s\\end{%s}"
+ table-env
+ (if width (format "{%s}" width) "")
+ alignment
+ contents
+ table-env)))
(cond
(float-env
(concat (if org-latex-table-caption-above "" caption)
@@ -2634,9 +2665,9 @@ a communication channel."
(when (eq (org-element-property :type table-row) 'standard)
(let* ((attr (org-export-read-attribute :attr_latex
(org-export-get-parent table-row)))
- (longtablep (string= (or (plist-get attr :environment)
+ (longtablep (member (or (plist-get attr :environment)
org-latex-default-table-environment)
- "longtable"))
+ '("longtable" "longtabu")))
(booktabsp (if (plist-member attr :booktabs)
(plist-get attr :booktabs)
org-latex-tables-booktabs))
--
1.8.2
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [patch] LaTeX export using tabu tables
2013-03-25 5:35 ` Eric Abrahamsen
2013-03-25 5:54 ` Bastien
2013-03-25 19:59 ` Nicolas Goaziou
@ 2013-03-26 20:05 ` Marcin Borkowski
2013-03-27 1:59 ` Eric Abrahamsen
2 siblings, 1 reply; 13+ messages in thread
From: Marcin Borkowski @ 2013-03-26 20:05 UTC (permalink / raw)
To: emacs-orgmode
Dnia 2013-03-25, o godz. 13:35:08
Eric Abrahamsen <eric@ericabrahamsen.net> napisał(a):
> Nicolas Goaziou <n.goaziou@gmail.com> writes:
>
> > Thanks for your patch. I didn't know about "tabu" package, but it
> > looks interesting.
>
> It's definitely my new go-to table environment, though I'm struggling
> to ignore the fact that it's got the ugliest documentation of any
> LaTeX package I've ever seen.
Slightly off-topic: I've looked (briefly) into tabu's documentation,
and I agree;). If you want your tables /beautiful/, however, I strongly
recommend checking out the booktabs package (its manual contains also
general aesthetical/typographical advice on tables!).
Best,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch] LaTeX export using tabu tables
2013-03-26 20:05 ` Marcin Borkowski
@ 2013-03-27 1:59 ` Eric Abrahamsen
2013-04-07 13:15 ` Marcin Borkowski
0 siblings, 1 reply; 13+ messages in thread
From: Eric Abrahamsen @ 2013-03-27 1:59 UTC (permalink / raw)
To: emacs-orgmode
Marcin Borkowski <mbork@wmi.amu.edu.pl> writes:
> Dnia 2013-03-25, o godz. 13:35:08
> Eric Abrahamsen <eric@ericabrahamsen.net> napisał(a):
>
>> Nicolas Goaziou <n.goaziou@gmail.com> writes:
>>
>> > Thanks for your patch. I didn't know about "tabu" package, but it
>> > looks interesting.
>>
>> It's definitely my new go-to table environment, though I'm struggling
>> to ignore the fact that it's got the ugliest documentation of any
>> LaTeX package I've ever seen.
>
> Slightly off-topic: I've looked (briefly) into tabu's documentation,
> and I agree;). If you want your tables /beautiful/, however, I strongly
> recommend checking out the booktabs package (its manual contains also
> general aesthetical/typographical advice on tables!).
Isn't it ghastly? Works great though. I'm definitely using booktabs and
enjoying it. That's the nice thing about tabu, it does a good job of
using extend existing table packages (longtable, colortab, etc) rather
than rolling its own. I'm particularly pleased with the siunitx
integration -- it means I can get rid of a table filter that added
\num{NN} all over the place.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch] LaTeX export using tabu tables
2013-03-26 2:54 ` Eric Abrahamsen
@ 2013-03-27 14:29 ` Nicolas Goaziou
0 siblings, 0 replies; 13+ messages in thread
From: Nicolas Goaziou @ 2013-03-27 14:29 UTC (permalink / raw)
To: Eric Abrahamsen; +Cc: emacs-orgmode
Hello,
Eric Abrahamsen <eric@ericabrahamsen.net> writes:
> Nicolas Goaziou <n.goaziou@gmail.com> writes:
>
> I'll get this right eventually...
It looks good. I applied it.
Thank you for your work.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch] LaTeX export using tabu tables
2013-03-27 1:59 ` Eric Abrahamsen
@ 2013-04-07 13:15 ` Marcin Borkowski
0 siblings, 0 replies; 13+ messages in thread
From: Marcin Borkowski @ 2013-04-07 13:15 UTC (permalink / raw)
To: emacs-orgmode
Dnia 2013-03-27, o godz. 09:59:49
Eric Abrahamsen <eric@ericabrahamsen.net> napisał(a):
> Marcin Borkowski <mbork@wmi.amu.edu.pl> writes:
>
> > Dnia 2013-03-25, o godz. 13:35:08
> > Eric Abrahamsen <eric@ericabrahamsen.net> napisał(a):
> >
> >> Nicolas Goaziou <n.goaziou@gmail.com> writes:
> >>
> >> > Thanks for your patch. I didn't know about "tabu" package, but it
> >> > looks interesting.
> >>
> >> It's definitely my new go-to table environment, though I'm
> >> struggling to ignore the fact that it's got the ugliest
> >> documentation of any LaTeX package I've ever seen.
> >
> > Slightly off-topic: I've looked (briefly) into tabu's documentation,
> > and I agree;). If you want your tables /beautiful/, however, I
> > strongly recommend checking out the booktabs package (its manual
> > contains also general aesthetical/typographical advice on tables!).
>
> Isn't it ghastly? Works great though. I'm definitely using booktabs
> and enjoying it. That's the nice thing about tabu, it does a good job
> of using extend existing table packages (longtable, colortab, etc)
> rather than rolling its own. I'm particularly pleased with the siunitx
> integration -- it means I can get rid of a table filter that added
> \num{NN} all over the place.
Well, that means that I'll have to look at tabu a bit closer (despite
the appalling look of the docs). Thanks for the pointer!
Best,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2013-04-07 13:15 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-23 4:26 [patch] LaTeX export using tabu tables Eric Abrahamsen
2013-03-24 0:18 ` Vikas Rawal
2013-03-24 9:26 ` Nicolas Goaziou
2013-03-25 5:35 ` Eric Abrahamsen
2013-03-25 5:54 ` Bastien
2013-03-25 6:54 ` Eric Abrahamsen
2013-03-25 6:51 ` Bastien
2013-03-25 19:59 ` Nicolas Goaziou
2013-03-26 2:54 ` Eric Abrahamsen
2013-03-27 14:29 ` Nicolas Goaziou
2013-03-26 20:05 ` Marcin Borkowski
2013-03-27 1:59 ` Eric Abrahamsen
2013-04-07 13:15 ` Marcin Borkowski
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).