Search code examples
emacslatexorg-modeorg-table

Converting an org-mode table to LaTeX


IS there a way to 'texify' an ASCII table written with Emacs' orgtabl-mode. Creating tables in this mode is extremely simple.

E.g. suppose I have this table

|------+-----+-----|
|    A |   B |   C |
|------+-----+-----|
| 2.34 | 2.7 | 8.9 |
| 3.67 | 4.5 | 8.9 |
|------+-----+-----|

If in EMACS, I could highlight this region and do soething like M-x texify or whatver to generate the latex code for that table that would save me a lot of pain.

Any non-emacs suggestion is also welcome.


Solution

  • You could use orgtbl-mode. In your latex buffer, do M-xorgtbl-mode, add

    % BEGIN RECEIVE ORGTBL thenameofthetable
    % END RECEIVE ORGTBL thenameofthetable
    

    where you want the table to be.

    add

    #+ORGTBL: SEND thenameofthetable orgtbl-to-latex :splice nil :skip 0
    |------+-----+-----|
    |    A |   B |   C |
    |------+-----+-----|
    | 2.34 | 2.7 | 8.9 |
    | 3.67 | 4.5 | 8.9 |
    |------+-----+-----|
    

    after the \end{document}

    and do C-cC-c on the org-mode table

    The other solution is already given by Michael Hoffman: use org-mode export capability with C-cC-el