- publishing free software manuals
The Org Mode 7 Reference Manual
by Carsten Dominik and others
Paperback (6"x9"), 282 pages
ISBN 9781906966089
RRP £9.95 ($14.95)

Sales of this book support the Org project! Get a printed copy>>>

16.15.2 A LaTeX example of radio tables

The best way to wrap the source table in LaTeX is to use the comment environment provided by ‘comment.sty’. It has to be activated by placing \usepackage{comment} into the document header. Orgtbl mode can insert a radio table skeleton(145) with the command M-x orgtbl-insert-radio-table. You will be prompted for a table name, let's say we use ‘salesfigures’. You will then get the following template:

% BEGIN RECEIVE ORGTBL salesfigures
% END RECEIVE ORGTBL salesfigures
\begin{comment}
#+ORGTBL: SEND salesfigures orgtbl-to-latex
| | |
\end{comment}

The #+ORGTBL: SEND line tells Orgtbl mode to use the function orgtbl-to-latex to convert the table into LaTeX and to put it into the receiver location with name salesfigures. You may now fill in the table--feel free to use the spreadsheet features:(146)

% BEGIN RECEIVE ORGTBL salesfigures
% END RECEIVE ORGTBL salesfigures
\begin{comment}
#+ORGTBL: SEND salesfigures orgtbl-to-latex
| Month | Days | Nr sold | per day |
|-------+------+---------+---------|
| Jan   |   23 |      55 |     2.4 |
| Feb   |   21 |      16 |     0.8 |
| March |   22 |     278 |    12.6 |
#+TBLFM: $4=$3/$2;%.1f
% $ (optional extra dollar to keep font-lock happy, see footnote)
\end{comment}

When you are done, press C-c C-c in the table to get the converted table inserted between the two marker lines.

Now let's assume you want to make the table header by hand, because you want to control how columns are aligned, etc. In this case we make sure that the table translator skips the first 2 lines of the source table, and tell the command to work as a splice, i.e. to not produce header and footer commands of the target table:

\begin{tabular}{lrrr}
Month & \multicolumn{1}{c}{Days} & Nr.\ sold & per day\\
% BEGIN RECEIVE ORGTBL salesfigures
% END RECEIVE ORGTBL salesfigures
\end{tabular}
%
\begin{comment}
#+ORGTBL: SEND salesfigures orgtbl-to-latex :splice t :skip 2
| Month | Days | Nr sold | per day |
|-------+------+---------+---------|
| Jan   |   23 |      55 |     2.4 |
| Feb   |   21 |      16 |     0.8 |
| March |   22 |     278 |    12.6 |
#+TBLFM: $4=$3/$2;%.1f
\end{comment}

The LaTeX translator function orgtbl-to-latex is already part of Orgtbl mode. It uses a tabular environment to typeset the table and marks horizontal lines with \hline. Furthermore, it interprets the following parameters (see also see section 16.15.3 Translator functions):

:splice nil/t
When set to t, return only table body lines, don't wrap them into a tabular environment. Default is nil.
:fmt fmt
A format to be used to wrap each field, it should contain %s for the original field value. For example, to wrap each field value in dollars, you could use :fmt "$%s$". This may also be a property list with column numbers and formats. for example :fmt (2 "$%s$" 4 "%s\\%%"). A function of one argument can be used in place of the strings; the function must return a formatted string.
:efmt efmt
Use this format to print numbers with exponentials. The format should have %s twice for inserting mantissa and exponent, for example "%s\\times10^{%s}". The default is "%s\\,(%s)". This may also be a property list with column numbers and formats, for example :efmt (2 "$%s\\times10^{%s}$" 4 "$%s\\cdot10^{%s}$"). After efmt has been applied to a value, fmt will also be applied. Similar to fmt, functions of two arguments can be supplied instead of strings.
ISBN 9781906966089The Org Mode 7 Reference ManualSee the print edition