emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric Schulte <schulte.eric@gmail.com>
To: "Thomas S. Dye" <tsd@tsdye.com>
Cc: Org-mode <emacs-orgmode@gnu.org>
Subject: Re: Library of Babel function
Date: Sun, 28 Aug 2011 08:44:52 -0600	[thread overview]
Message-ID: <87aaatbmq2.fsf@gmail.com> (raw)
In-Reply-To: m1y5ye4scp.fsf@tsdye.com

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/

  reply	other threads:[~2011-08-28 15:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-27 18:33 Library of Babel function Thomas S. Dye
2011-08-28 14:44 ` Eric Schulte [this message]
2011-08-28 17:11   ` [PATCH] Library of Babel source block Thomas S. Dye
2011-08-28 18:16     ` Eric Schulte
2011-08-28 18:20     ` Pieter Praet
2011-08-28 19:03       ` Thomas S. Dye

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87aaatbmq2.fsf@gmail.com \
    --to=schulte.eric@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=tsd@tsdye.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).