From mboxrd@z Thu Jan 1 00:00:00 1970 From: tsd@tsdye.com (Thomas S. Dye) Subject: Library of Babel function Date: Sat, 27 Aug 2011 08:33:26 -1000 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from eggs.gnu.org ([140.186.70.92]:59820) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QxNhF-0002Wr-Tp for emacs-orgmode@gnu.org; Sat, 27 Aug 2011 14:33:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QxNhE-0006zm-IK for emacs-orgmode@gnu.org; Sat, 27 Aug 2011 14:33:33 -0400 Received: from oproxy1-pub.bluehost.com ([66.147.249.253]:46203) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1QxNhE-0006zX-9q for emacs-orgmode@gnu.org; Sat, 27 Aug 2011 14:33:32 -0400 Received: from cpe-24-94-66-191.hawaii.res.rr.com ([24.94.66.191] helo=potofo-ou) by box472.bluehost.com with esmtpa (Exim 4.76) (envelope-from ) id 1QxNhB-0002Bk-Bt for emacs-orgmode@gnu.org; Sat, 27 Aug 2011 12:33:29 -0600 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: Org-mode Hi Eric, The booktabs-notes function, below, is based on the booktabs function in the library of Babel. It takes a second table and adds it to the bottom of the main table. I use it to add multicolumn footnotes to the bottom of the table. There is also a switch that adds a linespace between the main table and the notes table. I think the function might be a useful addition to the library of Babel. I tried to design it to be a functional replacement for the booktabs function, but don't trust my emacs-lisp (or other) programming skills. All the best, Tom #+srcname: booktabs-notes #+begin_src emacs-lisp :var table='((:head) hline (:body)) :var notes='() :var align='() :var env="tabular" :var width='() :var lspace='() :noweb yes :results latex (flet ((to-tab (tab) (orgtbl-to-generic (mapcar (lambda (lis) (if (listp lis) (mapcar (lambda (el) (if (stringp el) el (format "%S" el))) lis) lis)) tab) (list :lend " \\\\" :sep " & " :hline "\\hline")))) (org-fill-template " \\begin{%env}%width%align \\toprule %table \\bottomrule%spacer %notes \\end{%env}\n" (list (cons "env" (or env "table")) (cons "width" (if width (format "{%s}" width) "")) (cons "align" (if align (format "{%s}" align) "")) (cons "spacer" (if lspace "\\addlinespace" "")) (cons "table" ;; only use \midrule if it looks like there are column headers (if (equal 'hline (second table)) (concat (to-tab (list (first table))) "\n\\midrule\n" (to-tab (cddr table))) (to-tab table))) (cons "notes" (if notes (to-tab notes) "")) ))) #+end_src -- Thomas S. Dye http://www.tsdye.com