[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] [PATCH] Re: Latex Export: Place Caption Below Table
From: |
Thomas S. Dye |
Subject: |
[O] [PATCH] Re: Latex Export: Place Caption Below Table |
Date: |
Sun, 02 Oct 2011 06:26:36 -1000 |
Nick Dokos <address@hidden> writes:
> Thomas S. Dye <address@hidden> wrote:
>
>> Eric S Fraga <address@hidden> writes:
>>
>> > Jakob Lombacher <address@hidden> writes:
>> >
>> >> Hi,
>> >>
>> >> if I export a document to latex, the caption of a table is always on the
>> >> top.
>> >>
>> >> How can I place it at the bottom? Is there a parameter to config it?
>> >
>> > No, the placement is (currently) fixed to come before the tabular (or
>> > alternative) environment. Line 1970 or thereabouts in
>> > org-latex.el. Should be straightforward to modify although it is a
>> > quite common convention to have the caption above the table...
>>
>> Hi Eric,
>>
>> Are you able to propose a patch? This came up in my work recently with
>> a journal that puts captions below a table (and ends them with a
>> period!).
>>
>
> It's just a matter of emitting the \caption after the contents of the
> table, rather than before:
>
> ,----
> | \begin{table}[htb]
> | \begin{center}
> | \begin{tabular}{rr}
> | ...
> | \end{tabular}
> | \end{center}
> | \caption{Squares}
> | \end{table}
> `----
>
> instead of
>
> ,----
> | \begin{table}[htb]
> | \caption{Squares}
> | \begin{center}
> | \begin{tabular}{rr}
> | ...
> | \end{tabular}
> | \end{center}
> | \end{table}
> `----
>
>
> The following patch (deliberately hidden as a binary octet-stream to keep it
> out of patchwork) will do that - but IMO, it would be better to have yet
> another
> user-settable option to control the placement.
>
> Nick
>
>
Aloha all,
The inlined patch introduces a variable
org-export-latex-table-caption-above to control the placement of table
captions. Thanks to Nick Dokos for leading the way on this.
Tom
>From 3809f751afb8fffab1e07f7f4d6e607ed5a77b5b Mon Sep 17 00:00:00 2001
From: Tom Dye <address@hidden>
Date: Sun, 2 Oct 2011 05:49:52 -1000
Subject: [PATCH] * lisp/org-latex.el: added variable to toggle captions below
tables
---
lisp/org-latex.el | 15 +++++++++++----
1 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/lisp/org-latex.el b/lisp/org-latex.el
index 17626b5..f91b93e 100644
--- a/lisp/org-latex.el
+++ b/lisp/org-latex.el
@@ -73,7 +73,7 @@
org-deadline-string "\\|"
org-closed-string"\\)")
"Regexp matching special time planning keywords plus the time after it.")
-
+(defvar org-export-latex-table-caption-above t)
(defvar org-re-quote) ; dynamically scoped from org.el
(defvar org-commentsp) ; dynamically scoped from org.el
@@ -1965,13 +1965,13 @@ The conversion is made depending of STRING-BEFORE and
STRING-AFTER."
(concat "\\begin{longtable}{" align "}\n")
(if floatp
(format "\\begin{%s}%s\n" tblenv placement)))
- (if floatp
+ (if (and floatp org-export-latex-table-caption-above)
(format
"\\caption%s{%s} %s"
(if shortn (concat "[" shortn "]") "")
(or caption "")
(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))
"\\begin{center}\n")
(if (not longtblp)
@@ -1993,6 +1993,12 @@ The conversion is made depending of STRING-BEFORE and
STRING-AFTER."
(if (not longtblp) (format "\n\\end{%s}" tabular-env))
(if longtblp "\n" (if org-export-latex-tables-centered
"\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
"\\end{longtable}"
(if floatp (format "\\end{%s}" tblenv)))))
@@ -2042,11 +2048,12 @@ The conversion is made depending of STRING-BEFORE and
STRING-AFTER."
(setq tbl (concat "\\begin{center}\n" tbl "\\end{center}")))
(when floatp
(setq tbl (concat "\\begin{table}\n"
+ (if (not org-export-latex-table-caption-above) tbl)
(format "\\caption%s{%s%s}\n"
(if shortn (format "[%s]" shortn) "")
(if label (format "\\label{%s}" label) "")
(or caption ""))
- tbl
+ (if org-export-latex-table-caption-above tbl)
"\n\\end{table}\n")))
(insert (org-export-latex-protect-string tbl))))
--
1.7.1
--
Thomas S. Dye
http://www.tsdye.com
- [O] [PATCH] Re: Latex Export: Place Caption Below Table,
Thomas S. Dye <=