On Sat, Dec 14, 2013 at 12:04 PM, Nicolas Goaziou <n.goaziou@gmail.com> wrote:
Vikas Rawal <vikaslists@agrarianresearch.org> writes:

> I do not know if I am expressing myself clearly. The table is being
> generated by an R source code. We need a way of adding notes to such a
> table.

There are two different problems:

  1. How to generate "threeparttable" environment using Org syntax and
     `latex' export back-end.
  2. How to generate Org syntax specified above from a source block.

At the moment, my only concern is point 1.


Yes, this is right.

> Unfortunately, on such matters, one has to work with the conventions in
> different disciplines. At least in social sciences, it is usually expected
> that notes are placed below Tables and Figures, and not as part of
> footnotes, which are reserved for notes to text. At least my collaborators
> and readers frown when I put table sources and notes in the footnotes.

Understood. You didn't answer to my suggestion to use special blocks,
though.


I do not know how to use special blocks. I will read the manual and see what can be done with those. I f special blocks cannot give a statisfactory solution (I do not know), other questions you raise may be relevant in exploring a better solution.

 

If my suggestion to use special blocks doesn't apply, you still need to
properly define your problem. In particular:

- How table notes are generated? Do you want to hijack footnotes in
  table to produce them?
- Should note numbers be configurable?

We should be able to add something to #+RESULTS block. I would think that the natural way would be to specify threeparttable in #+attr_latex. It would be ideal to put contents of a footer under a separate headline (tagged noexport) somewhere in the document with a custom_id property. This custom_id could be specified along with threeparttable in the above #+attr_latex. Something like the following:

#+attr_latex: threeparttable [[notes_custom_id_1]]
#+RESUlTS:
|x|y|z|
|1|2|2|

* Table notes                                       :noexport:
:PROPERTIES:
:CUSTOM_ID: notes_custom_id_1
:END:
+ first note here
+ second note here
+ third note here

- Should "threeparttable" be generated only when table contains at least
  a note and some global option is set to a non-nil value? Or should
  a user explicitly write that he requires such an environment for the
  current table?

I would think threeparttable be generated when you have something like the above specified in #+attr_latex.
 
- Can another environment than "tabular" be used within
  "threeparttable"?
- Is the "table" environment around mandatory?
- ...

I use tabulary inside threeparttable (that is, when I give raw latex code).

The code I used has table environment around it. I am no expert on latex and I must have put it together using whatever I could find on threeparttable. I cannot say whether this is mandatory. I am sure other people on this list would just know this. Otherwise, I can experiment.

I am really stretching my capabilities and knowledge of org. So, please excuse me, if what I said is nonsensical.

Vikas