From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Thomas S. Dye" Subject: Re: [babel] Passing an org table block to Eric Schulte's booktabs function Date: Mon, 21 Feb 2011 09:51:27 -1000 Message-ID: <672E9230-1995-44F2-90B6-C969897AA137@tsdye.com> References: Mime-Version: 1.0 (Apple Message framework v936) Content-Type: multipart/mixed; boundary="===============1784325416==" Return-path: Received: from [140.186.70.92] (port=39651 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PrbnE-0004Jl-Ew for emacs-orgmode@gnu.org; Mon, 21 Feb 2011 14:51:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PrbnC-0004CQ-Nh for emacs-orgmode@gnu.org; Mon, 21 Feb 2011 14:51:36 -0500 Received: from cpoproxy2-pub.bluehost.com ([67.222.39.38]:54753) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1PrbnC-0004Bf-9r for emacs-orgmode@gnu.org; Mon, 21 Feb 2011 14:51:34 -0500 In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Jeff Horn Cc: Org-mode ml --===============1784325416== Content-Type: multipart/alternative; boundary=Apple-Mail-1-35624432 --Apple-Mail-1-35624432 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Aloha Jeff, Do the instructions here work for you? http://orgmode.org/worg/org-tutorials/org-latex-export.html#sec-12_1 hth, Tom On Feb 21, 2011, at 9:34 AM, Jeff Horn wrote: > I've recently tried getting pretty tables in LaTeX export using Eric > Schulte's function from Worg: > > http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-LaTeX.html#sec-5_2 > > The problem is that passing the table to the function produces an > error, specifically "wrong type of argument: listp". > > Any ideas about what to do differently? Here's a quick example: > > * Test Table > Have a look at Table \ref{tab:example}. > #+srcname: es-booktabs > #+begin_src emacs-lisp :var table='((:head) hline (:body)) :exports > none > (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 > " > \\toprule > %table > \\bottomrule\n" > (list > (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)))))) > #+end_src > #+srcname: tab-example > #+begin_src org :results replace :exports none > ,| | | Column Player | | > ,|------------+---+---------------+-----| > ,| / | < | | > | > ,| | | A | B | > ,| Row Player | A | 1,2 | 3,4 | > ,| | B | 5,6 | 7,8 | > #+end_src > #+begin_src latex :noweb yes > \begin{table}[htb!] > \centering > \caption{A test table} > \label{tab:example} > \begin{tabular}{rl} > <> > \end{tabular} > \end{table} > #+end_src > > -- > Jeffrey Horn > http://www.failuretorefrain.com/jeff/ > > _______________________________________________ > Emacs-orgmode mailing list > Please use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode --Apple-Mail-1-35624432 Content-Type: text/html; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Aloha = Jeff,

Do the instructions here work for = you?


hth,
Tom

On Feb 21, 2011, at = 9:34 AM, Jeff Horn wrote:

I've = recently tried getting pretty tables in LaTeX export using = Eric
Schulte's function from Worg:

   http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-La= TeX.html#sec-5_2

The problem is that passing the table to the = function produces an
error, specifically "wrong type of argument: = listp".

Any ideas about what to do differently? Here's a quick = example:

* Test Table
Have a look at Table = \ref{tab:example}.
#+srcname: es-booktabs
#+begin_src emacs-lisp = :var table=3D'((:head) hline (:body)) :exports none
(flet ((to-tab = (tab)
=             &n= bsp; (orgtbl-to-generic
=             &n= bsp;  (mapcar (lambda (lis)
=             &n= bsp;           &nbs= p;(if (listp lis)
=             &n= bsp;           &nbs= p;    (mapcar (lambda (el)
=             &n= bsp;           &nbs= p;            =   (if (stringp el)
=             &n= bsp;           &nbs= p;            =       el
=             &n= bsp;           &nbs= p;            =     (format "%S" el))) lis)
=             &n= bsp;           &nbs= p;  lis)) tab)
=             &n= bsp;  (list :lend " \\\\" :sep " & " :hline = "\\hline"))))
 (org-fill-template
=   "
\\toprule
%table
\\bottomrule\n"
=   (list
   (cons "table"
=          ;; only use = \midrule if it looks like there are column headers
=          (if (equal 'hline = (second table))
=             &n= bsp;(concat (to-tab (list (first table)))
=             &n= bsp;        "\n\\midrule\n"
=             &n= bsp;        (to-tab (cddr = table)))
=            (to-tab = table))))))
#+end_src
#+srcname: tab-example
#+begin_src org = :results replace :exports none
=       ,| =            | =   | Column Player |     |
=       ,|------------+---+---------------+---= --|
      ,| / =          | < | =             &n= bsp; | >   |
=       ,| =            | =   | A =             | = B   |
      ,| Row Player | = A | 1,2           | = 3,4 |
      ,| =            | B | = 5,6           | 7,8 = |
#+end_src
#+begin_src latex :noweb yes
= \begin{table}[htb!]
  \centering
=   \caption{A test table}
=   \label{tab:example}
  \begin{tabular}{rl}
=     <<es-booktabs(table=3Dtab-example)>>   \end{tabular}
\end{table}
#+end_src

-- =
Jeffrey Horn
http://www.failuretorefrain= .com/jeff/

_______________________________________________
E= macs-orgmode mailing list
Please use `Reply All' to send replies to = the = list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/em= acs-orgmode

= --Apple-Mail-1-35624432-- --===============1784325416== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --===============1784325416==--