emacs-orgmode
[Top][All Lists]

## Re: [O] adding attributes to tables in results

 From: John Kitchin Subject: Re: [O] adding attributes to tables in results Date: Sat, 21 Nov 2015 13:52:27 -0500 User-agent: mu4e 0.9.13; emacs 25.0.50.1

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
#+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 <address@hidden> 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.
>>>>
>>>
>>>
>>> #+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
>>>
>>> --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