From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: adding attributes to tables in results Date: Sat, 21 Nov 2015 13:52:27 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34284) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a0DH1-0004Ew-SA for emacs-orgmode@gnu.org; Sat, 21 Nov 2015 13:52:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a0DGw-00053z-Nz for emacs-orgmode@gnu.org; Sat, 21 Nov 2015 13:52:35 -0500 Received: from mail-qg0-x232.google.com ([2607:f8b0:400d:c04::232]:35879) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a0DGw-00053v-JC for emacs-orgmode@gnu.org; Sat, 21 Nov 2015 13:52:30 -0500 Received: by qgcc31 with SMTP id c31so50043229qgc.3 for ; Sat, 21 Nov 2015 10:52:30 -0800 (PST) In-reply-to: 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: Vikas Rawal Cc: org-mode mailing list , "Charles C. Berry" I am running a search committee of 5 people. As applications come in, an org heading is created for each application, and I run a command to send one of the committee an email with a review rubric in it, and this command creates a subheading to put their review. We have 275 applications so far, so I am using code to aggregate results into tables. Now, I am generating reports that show what each person has reviewed. In the report, I make a table for each person in a code block that constructs the data for that person. I don't want to manually modify the results because there will be a lot of tables, and I have to update this reasonably often. HEre is what generates the table, it is a function that returns a list of results which on its own renders as a table just fine. #+BEGIN_SRC emacs-lisp :exports results (happ-reviewer-table "jkitchin@andrew.cmu.edu") #+END_SRC would ideally output something like: #+RESULTS: #+tblname: kitchin-reviews #+attr_latex: :environment longtable #+caption: Reviews by Kitchin | the | table | I | generated| from a data result from my function that looked like: (table '("#+tblname: kitchin-reviews" "#+attr_latex: :environment longtable" "#+caption: Reviews by Kitchin") '(the table I generated)) i.e. of the form (table attrs data) And even better, on rerunning the code it would correctly replace it. I usually accomplish this with :results raw and some tedious printing to get what I want. That way is annoying to rerun because of the manual removal of the output. I just made up the syntax, and no doubt there are many other ways to achieve it. That is what I had in mind though. The tip Charles gave works for export, but the tables do not look too good for me in the org-document unless I run C-c ' on them to get them in org, and I also want them functional in the org-buffer too. Vikas Rawal writes: > John, > > Just curious. What advantage do you see in adding these attributes to the code block, and not directly to the result? > > Vikas > > > >> On 21-Nov-2015, at 11:34 pm, John Kitchin wrote: >> >> Thanks. That gets me pretty close to what I want. >> >> Charles C. Berry writes: >> >>> On Sat, 21 Nov 2015, John Kitchin wrote: >>> >>>> Hi everyone, >>>> >>>> I am trying to figure out a way to automatically add some attributes to >>>> tables generated from code blocks. >>>> >>> >>> With ob-org loaded: >>> >>> #+BEGIN_SRC emacs-lisp >>> (require 'ob-org) >>> #+END_SRC >>> >>> this src block (n.b. there is a backslash escaped n in the #+HEADER line >>> just before the #+ATTR - I hope it doesn't linewrap in email or gnus >>> readers) >>> >>> --8<---------------cut here---------------start------------->8--- >>> #+HEADER: :wrap "src org :exports results :results replace \n#+ATTR_LATEX: :environment longtable" >>> #+BEGIN_SRC emacs-lisp :exports results >>> (list (+ 2 4) 4 5) >>> #+END_SRC >>> --8<---------------cut here---------------end--------------->8--- >>> >>> exports as >>> >>> --8<---------------cut here---------------start------------->8--- >>> >>> \begin{longtable}{rrr} >>> 6 & 4 & 5\\ >>> \end{longtable} >>> \end{document} >>> >>> --8<---------------cut here---------------end--------------->8--- >>> >>> >>> HTH, >>> >>> Chuck >> >> -- >> Professor John Kitchin >> Doherty Hall A207F >> Department of Chemical Engineering >> Carnegie Mellon University >> Pittsburgh, PA 15213 >> 412-268-7803 >> @johnkitchin >> http://kitchingroup.cheme.cmu.edu >> -- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu