From mboxrd@z Thu Jan 1 00:00:00 1970 From: tsd@tsdye.com (Thomas S. Dye) Subject: [PATCH] Re: Latex Export: Place Caption Below Table Date: Sun, 02 Oct 2011 06:26:36 -1000 Message-ID: References: <87zkhor9hb.fsf@ucl.ac.uk> <17486.1317238846@alphaville.dokosmarshall.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([140.186.70.92]:44095) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RAOsJ-0000OH-BA for emacs-orgmode@gnu.org; Sun, 02 Oct 2011 12:26:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RAOsH-0002CW-Tw for emacs-orgmode@gnu.org; Sun, 02 Oct 2011 12:26:47 -0400 Received: from oproxy7-pub.bluehost.com ([67.222.55.9]:52045) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1RAOsH-0002CO-KN for emacs-orgmode@gnu.org; Sun, 02 Oct 2011 12:26:45 -0400 In-Reply-To: <17486.1317238846@alphaville.dokosmarshall.org> (Nick Dokos's message of "Wed, 28 Sep 2011 15:40:46 -0400") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: nicholas.dokos@hp.com Cc: emacs-orgmode@gnu.org, Jakob Lombacher --=-=-= Nick Dokos writes: > Thomas S. Dye wrote: > >> Eric S Fraga writes: >> >> > Jakob Lombacher 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 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-lisp-org-latex.el-added-variable-to-toggle-captions-.patch Content-Description: Table caption patch >From 3809f751afb8fffab1e07f7f4d6e607ed5a77b5b Mon Sep 17 00:00:00 2001 From: Tom Dye 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 --=-=-=--