From ff2635d43509481ea4b72596a325a6f155dc0cfe Mon Sep 17 00:00:00 2001 From: Eric Abrahamsen 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