I assume what you are trying to do is a radio table: define a table under an #+ORGTBL:
keyword that can be translated into LaTeX and inserted where the placeholders BEGIN RECEIVE ORGTBL <table name> ...
and END RECEIVE ORGTBL <table name>
indicate.
For example, in a LaTeX mode buffer, you enable this capability (and also the capabilities of editing the source table as if you were in an Org mode buffer) by turning on orgtbl-mode
. Then C-c C-c
on the #+ORGTBL: SEND ...
line translates the table and inserts it between the placeholders. The idea is that you keep the table "hidden" from whatever processor (latex
, pdflatex
, xelatex
, lualatex
) will munge the LaTeX file by e.g. putting it in a block comment.[1]
In an Org mode buffer, you cannot turn on orgtbl-mode
: if you do M-x orgtbl-mode
, it will actually do nothing except produce the message Orgtbl mode is not useful in Org mode, command ignored
. It is true that orgtbl-mode
is mostly useless in an Org mode file: Org mode already provides all of the capabilities of editing tables e.g. so it does not need orgtbl-mode
to let you do that. What orgtbl-mode
does in other buffers is to set up a keymap that will allow you access to all the functions that are needed to edit/navigate/realign/etc the table as IF you were in an Org mode buffer. But the orgtbl-mode
keymap also has a binding for C-c C-c
which does the special processing for sending a radio table to its destination as described above: plain vanilla Org mode does not.
But so what? Plain vanilla Org mode still knows about all the commands and functions that orgtbl-mode
uses. So you can still call the appropriate orgtbl-mode
command from an Org mode file, even though you cannot activate the minor mode. All you have to do is find out which command that is: if you open a LaTeX buffer, enable orgbl-mode
and ask what C-c C-c
is bound to (i.e. C-h c C-c C-c
) you'll find out that it is bound to a command called orgtbl-ctrl-c-ctrl-c
. So all you have to do in an Org mode buffer to send a radio table wherever you want is to invoke that command: M-x orgtbl-ctrl-c-ctrl-c
- that's all. That's the only thing that orgtbl-mode
provides to other major modes that Org mode does not have: a convenient key binding to orgtbl-ctrl-c-ctrl-c
.
Here is a complete example Org mode file:
* Test with latex fragment getting radio table from this same file
Here's a latex fragment:
\begin{equation}
% BEGIN RECEIVE ORGTBL matrix
% END RECEIVE ORGTBL matrix
\end{equation}
that is going to receive the radio table below:
#+ORGTBL: SEND matrix orgtbl-to-latex :tstart "\\begin{matrix}" :tend "\\end{matrix}"
| a | b | c |
| d | e | f |
With point
on the #+ORGTBL: SEND ...
line, do M-x orgtbl-ctrl-ctrl-c
and you will get this:
* Test with latex fragment getting radio table from this same file
Here's a latex fragment:
\begin{equation}
% BEGIN RECEIVE ORGTBL matrix
\begin{matrix}
a & b & c\\[0pt]
d & e & f\\[0pt]
\end{matrix}
% END RECEIVE ORGTBL matrix
\end{equation}
that is going to receive the radio table below:
#+ORGTBL: SEND matrix orgtbl-to-latex :tstart "\\begin{matrix}" :tend "\\end{matrix}"
| a | b | c |
| d | e | f |
Note that we "hide" the placeholders in the LaTeX fragment by commenting them out with %
, the LaTeX commend marker.
You can of course either bind orgtbl-ctrl-c-ctrl-c
to some key in the Org mode keymap, or modify the Org mode command that is invoked by C-c C-c
(the command's name is org-ctrl-c-ctrl-c
) to recognize that it is being called on an #+ORGTBL: SEND
line and then does the appropriate action.
Footnotes:
[1] Although LaTeX doesn't provide block comments so another strategy is needed. Check the section of the manual I linked above (as well as the LaTeX example in the next section).
orgtbl-mode
to convert Org mode tables to LaTeX tables inside an Org file?" ?