From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Thomas S. Dye" Subject: Re: [babel] FEATURE REQUEST: send results into file Date: Wed, 29 Sep 2010 06:02:29 -1000 Message-ID: <5AEB6EE1-152E-4DDC-BAB7-5897FE774E51@tsdye.com> References: Mime-Version: 1.0 (Apple Message framework v936) Content-Type: multipart/mixed; boundary="===============1526723970==" Return-path: Received: from [140.186.70.92] (port=45776 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P0z7B-0001w4-9w for emacs-orgmode@gnu.org; Wed, 29 Sep 2010 12:02:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1P0z79-0002Xz-9s for emacs-orgmode@gnu.org; Wed, 29 Sep 2010 12:02:40 -0400 Received: from oproxy2-pub.bluehost.com ([67.222.39.60]:41294) by eggs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1P0z78-0002XA-U2 for emacs-orgmode@gnu.org; Wed, 29 Sep 2010 12:02:39 -0400 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: Rainer M Krug Cc: emacs-orgmode --===============1526723970== Content-Type: multipart/alternative; boundary=Apple-Mail-8-378787881 --Apple-Mail-8-378787881 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Aloha Rainer, Perhaps this will work? Eric Schulte wrote a function to make a LaTeX table out of an Org-mode table. You should be able to call it from within a LaTeX source block that tangles to a suitably named file. There is an added benefit in the support for booktabs rules, so you'll need to have the booktabs package installed. hth, Tom > --8<---------------cut here---------------start------------->8--- > *** booktabs > This block can be used to wrap a table in the latex =booktabs= > environment, it takes the following arguments -- all but the first two > are optional. > | arg | description | > |-------+--------------------------------------------| > | table | a reference to the table | > | align | optional alignment string | > | env | optional environment, default to "tabular" | > | width | optional width specification string | > > #+srcname: booktabs > #+begin_src emacs-lisp :var table='((:head) hline (:body)) :var > align='() :var env="tabular" :var width='() :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 > \\end{%env}\n" > (list > (cons "env" (or env "table")) > (cons "width" (if width (format "{%s}" width) "")) > (cons "align" (if align (format "{%s}" align) "")) > (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 > --8<---------------cut here---------------end--------------->8--- > > once loaded it can be applied as here > > --8<---------------cut here---------------start------------->8--- > ** booktabs > #+tblname: months > | num | Abbrev. | > |-----+---------| > | 1 | Jan. | > | 2 | Feb. | > | 3 | Mar. | > > #+call: booktabs(table=months, align="r|l") :results latex :exports > results > --8<---------------cut here---------------end--------------->8--- On Sep 28, 2010, at 10:58 PM, Rainer M Krug wrote: > Hi > > Based on a discussion in the thread "Problem with > PROPERTIES :OPTIONS: when exporting subtree", The idea came ub by > Mathew Lundin to be able to "send the results or a source code block > (either executed code or exported org snippets) via babel to a > target in an external file.". > > The scenario or context in which the idea came up: > > I am using org babel for literate programming and I document my > parameters for simulations in a table in org. Now when writing a > paper, for which I use a different program (I use LyX), but I still > would like to include the tables from my original org file in them. > Therefore I was looking for a possibility to export ONLY the table > into a .tex file, so that it can be included in the LyX / LaTeX via > \input{theTable.tex} . Therefore I would need an export of the table > in LaTeX format, but no preamble or anything. As far as I was told, > this possibility does not exist in org. > > So Mathew's / my question is if it would be possible to include a > functionality to "send the results or a source code block (either > executed code or exported org snippets) via babel to a target in an > external file.". > > > Cheers, > > Rainer > > > -- > NEW GERMAN FAX NUMBER!!! > > Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation > Biology, UCT), Dipl. Phys. (Germany) > > Centre of Excellence for Invasion Biology > Natural Sciences Building > Office Suite 2039 > Stellenbosch University > Main Campus, Merriman Avenue > Stellenbosch > South Africa > > Cell: +27 - (0)83 9479 042 > Fax: +27 - (0)86 516 2782 > Fax: +49 - (0)321 2125 2244 > email: Rainer@krugs.de > > Skype: RMkrug > Google: R.M.Krug@gmail.com > > _______________________________________________ > 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-8-378787881 Content-Type: text/html; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Aloha = Rainer,

Perhaps this will work?  Eric Schulte = wrote a function to make a LaTeX table out of an Org-mode table. =  You should be able to call it from within a LaTeX source block = that tangles to a suitably named file.  There is an added benefit = in the support for booktabs rules, so you'll need to have the booktabs = package = installed.

hth,
Tom

--8<---------------cut = here---------------start------------->8---
*** booktabs
This = block can be used to wrap a table in the latex = =3Dbooktabs=3D
environment, it = takes the following arguments -- all but the first = two
are = optional.
| arg   | = description =             &n= bsp;           &nbs= p;      |
|-------+--------------------------------------------|
| table | a reference to the table =             &n= bsp;     |
| align | optional alignment string =             &n= bsp;    |
| = env   | optional environment, default to "tabular" = |
| width | optional width = specification string =        |

#+srcname: = booktabs
#+begin_src = emacs-lisp :var table=3D'((:head) hline (:body)) :var align=3D'() :var = env=3D"tabular" :var width=3D'() :noweb yes :results = latex
(flet ((to-tab = (tab)
          =      (orgtbl-to-generic
          =       (mapcar (lambda = (lis)
          =             &n= bsp;   (if (listp lis)
          =             &n= bsp;       (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;     lis)) tab)
          =       (list :lend " \\\\" :sep " & " = :hline "\\hline"))))
  (org-fill-template
   "
\\begin{%env}%width%align
\\toprule
%table
\\bottomrule
\\end{%env}\n"
   (list
    (cons "env" =       (or env = "table"))
    (cons "width" =     (if width (format "{%s}" width) = ""))
    (cons "align" =     (if align (format "{%s}" align) = ""))
    (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"
          =             (t= o-tab (cddr table)))
          =   (to-tab table))))))
#+end_src
--8<---------------cut = here---------------end--------------->8---

once loaded it = can be applied as here

--8<---------------cut = here---------------start------------->8---
** booktabs
#+tblname: months
| num | Abbrev. |
|-----+---------|
|   1 | Jan. =    |
| =   2 | Feb.    |
|   3 | Mar. =    |

#+call: = booktabs(table=3Dmonths, align=3D"r|l") :results latex :exports = results
--8<---------------cut = here---------------end--------------->8---

On= Sep 28, 2010, at 10:58 PM, Rainer M Krug wrote:

Hi

Based on a discussion in = the thread "Problem with PROPERTIES :OPTIONS: when exporting = subtree", The idea came ub by Mathew Lundin to be able to "send the = results or a source code block (either executed code or exported = org snippets) via babel to a target in an external file.".
=

The scenario or context in which the idea came = up:

I am using org babel for literate = programming and I document my parameters for simulations in a table in = org. Now when writing a paper, for which I use a different program (I = use LyX), but I still would like to include the tables from my original = org file in them. Therefore I was looking for a possibility to export = ONLY the table into a .tex file, so that it can be included in the LyX / = LaTeX via \input{theTable.tex} . Therefore I would need an = export of the table in LaTeX format, but no preamble or anything. As far = as I was told, this possibility does not exist in org.
=

So Mathew's / my question is if it would be possible = to include a functionality to "send the results or a source code = block (either executed code or exported org snippets) via babel to a = target in an external file.".
=


Cheers,

Rainer=


--
NEW GERMAN FAX = NUMBER!!!

Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc = (Conservation Biology, UCT), Dipl. Phys. (Germany)

Centre of = Excellence for Invasion Biology
Natural Sciences Building
Office = Suite 2039
Stellenbosch University
Main Campus, Merriman = Avenue
Stellenbosch
South Africa

Cell:      =      +27 - (0)83 9479 042
Fax:      =       +27 - (0)86 516 2782
Fax:      =       +49 - (0)321 2125 2244
email:    =       Rainer@krugs.de

Skype:      =     RMkrug
Google:         R.M.Krug@gmail.com

= _______________________________________________
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-8-378787881-- --===============1526723970== 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 --===============1526723970==--