emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] [babel] Passing an org table block to Eric Schulte's booktabs


From: Jeff Horn
Subject: [Orgmode] [babel] Passing an org table block to Eric Schulte's booktabs function
Date: Mon, 21 Feb 2011 14:34:23 -0500

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}
     <<es-booktabs(table=tab-example)>>
   \end{tabular}
 \end{table}
#+end_src

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]