From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: Library of Babel function Date: Sun, 28 Aug 2011 08:44:52 -0600 Message-ID: <87aaatbmq2.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([140.186.70.92]:44981) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QxgvY-0006jr-UC for emacs-orgmode@gnu.org; Sun, 28 Aug 2011 11:05:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QxgvT-0000d6-TN for emacs-orgmode@gnu.org; Sun, 28 Aug 2011 11:05:36 -0400 Received: from mail-pz0-f44.google.com ([209.85.210.44]:63499) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QxgvT-0000d0-E8 for emacs-orgmode@gnu.org; Sun, 28 Aug 2011 11:05:31 -0400 Received: by pzk36 with SMTP id 36so8205361pzk.17 for ; Sun, 28 Aug 2011 08:05:30 -0700 (PDT) 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: "Thomas S. Dye" Cc: Org-mode Hi Tom, This sounds great, would you mind submitting this as a patch to the library-of-babel.org file in the git repository, with some included usage instructions in the same subtree as the code block? Thanks! -- Eric tsd@tsdye.com (Thomas S. Dye) writes: > 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 -- Eric Schulte http://cs.unm.edu/~eschulte/