0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-07-16 12:16:27 +00:00

Make it possible to place table captions below the table

* lisp/org-latex.el (org-export-latex-tables): Honor
`org-export-latex-table-caption-above'
(org-export-latex-table-caption-above): New option.

Patch by Thomas Dye.
This commit is contained in:
Carsten Dominik 2011-10-10 21:05:03 +02:00
parent 968313f113
commit 54d7df6774

View file

@ -73,7 +73,6 @@
org-deadline-string "\\|" org-deadline-string "\\|"
org-closed-string"\\)") org-closed-string"\\)")
"Regexp matching special time planning keywords plus the time after it.") "Regexp matching special time planning keywords plus the time after it.")
(defvar org-re-quote) ; dynamically scoped from org.el (defvar org-re-quote) ; dynamically scoped from org.el
(defvar org-commentsp) ; dynamically scoped from org.el (defvar org-commentsp) ; dynamically scoped from org.el
@ -358,6 +357,12 @@ string defines the replacement string for this quote."
:group 'org-export-latex :group 'org-export-latex
:type 'boolean) :type 'boolean)
(defcustom org-export-latex-table-caption-above t
"When non-nil, the caption is set above the table. When nil,
the caption is set below the table."
:group 'org-export-latex
:type 'boolean)
(defcustom org-export-latex-tables-column-borders nil (defcustom org-export-latex-tables-column-borders nil
"When non-nil, grouping columns can cause outer vertical lines in tables. "When non-nil, grouping columns can cause outer vertical lines in tables.
When nil, grouping causes only separation lines between groups." When nil, grouping causes only separation lines between groups."
@ -1965,13 +1970,13 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
(concat "\\begin{longtable}{" align "}\n") (concat "\\begin{longtable}{" align "}\n")
(if floatp (if floatp
(format "\\begin{%s}%s\n" tblenv placement))) (format "\\begin{%s}%s\n" tblenv placement)))
(if floatp (if (and floatp org-export-latex-table-caption-above)
(format (format
"\\caption%s{%s} %s" "\\caption%s{%s} %s"
(if shortn (concat "[" shortn "]") "") (if shortn (concat "[" shortn "]") "")
(or caption "") (or caption "")
(if label (format "\\label{%s}" label) ""))) (if label (format "\\label{%s}" label) "")))
(if (and longtblp caption) "\\\\\n" "\n") (if (and longtblp caption) "\\\\\n" "\n")
(if (and org-export-latex-tables-centered (not longtblp)) (if (and org-export-latex-tables-centered (not longtblp))
"\\begin{center}\n") "\\begin{center}\n")
(if (not longtblp) (if (not longtblp)
@ -1993,6 +1998,12 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
(if (not longtblp) (format "\n\\end{%s}" tabular-env)) (if (not longtblp) (format "\n\\end{%s}" tabular-env))
(if longtblp "\n" (if org-export-latex-tables-centered (if longtblp "\n" (if org-export-latex-tables-centered
"\n\\end{center}\n" "\n")) "\n\\end{center}\n" "\n"))
(if (and floatp (not org-export-latex-table-caption-above))
(format
"\\caption%s{%s} %s"
(if shortn (concat "[" shortn "]") "")
(or caption "")
(if label (format "\\label{%s}" label) "")))
(if longtblp (if longtblp
"\\end{longtable}" "\\end{longtable}"
(if floatp (format "\\end{%s}" tblenv))))) (if floatp (format "\\end{%s}" tblenv)))))
@ -2042,11 +2053,12 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
(setq tbl (concat "\\begin{center}\n" tbl "\\end{center}"))) (setq tbl (concat "\\begin{center}\n" tbl "\\end{center}")))
(when floatp (when floatp
(setq tbl (concat "\\begin{table}\n" (setq tbl (concat "\\begin{table}\n"
(if (not org-export-latex-table-caption-above) tbl)
(format "\\caption%s{%s%s}\n" (format "\\caption%s{%s%s}\n"
(if shortn (format "[%s]" shortn) "") (if shortn (format "[%s]" shortn) "")
(if label (format "\\label{%s}" label) "") (if label (format "\\label{%s}" label) "")
(or caption "")) (or caption ""))
tbl (if org-export-latex-table-caption-above tbl)
"\n\\end{table}\n"))) "\n\\end{table}\n")))
(insert (org-export-latex-protect-string tbl)))) (insert (org-export-latex-protect-string tbl))))