emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] Create a longtable in LaTeX from orgtbl


From: Tak Kunihiro
Subject: [O] Create a longtable in LaTeX from orgtbl
Date: Wed, 18 Jun 2014 08:11:32 +0900 (JST)

Dear all,

Can you show how to create a longtable in LaTeX from orgtbl?

When a table in short, I create a LaTeX table in following way, as
demonstrated in manual.

https://www.gnu.org/software/emacs/manual/html_node/org/A-LaTeX-example.html

#+BEGIN_SRC LaTeX
\begin{table}[htdp]
  \begin{center}
    \caption{My great results}
    % BEGIN RECEIVE ORGTBL tbl:my-short-table
    % END RECEIVE ORGTBL tbl:my-short-table
    \iffalse
    #+ORGTBL: SEND tbl:my-short-table orgtbl-to-latex :no-escape t
    |------------+---------+--------|
    |       date | session | remark |
    |------------+---------+--------|
    | 2014-06-18 | s140618 |        |
    |------------+---------+--------|
    \fi
    \label{tbl:my-short-table}
  \end{center}
\end{table}
#+END_SRC


For longtable, I do in following way.  It barely works, but I have to
copy and paste header every time orgtbl is tossed to RECEIVE.

Can you show how to create a longtable in LaTeX from orgtbl?  Thank
you in advance.

Tak


#+BEGIN_SRC LaTeX
%% \usepackage{longtable}
\begin{center}
  \begin{longtable}{ rll }
    \caption{My great results}\\
    \hline
    % --- for 1st page ---
    date & session & remarks \\
    % --------------------
    \hline
    \endfirsthead
    \caption{Continued}\\
    \hline
    % --- for 2nd+ page --
    date & session & remarks \\
    % --------------------
    \hline
    \endhead
    % --------------------
    % BEGIN RECEIVE ORGTBL tbl:my-long-table
    % END RECEIVE ORGTBL tbl:my-long-table
    \iffalse
    #+ORGTBL: SEND tbl:my-long-table orgtbl-to-longtbl :no-escape t :splice nil 
:skip 0
    | %     date | session | remarks |
    | 2014-06-18 | s140618 | foo     |
    \fi
    % --------------------
    \hline
    \label{tbl:my-long-table}
  \end{longtable}
\end{center}
#+END_SRC

#+BEGIN_SRC emacs-lisp
(defun orgtbl-to-longtbl (table params)
  "Convert the Orgtbl mode TABLE to LaTeX."
  (let* ((alignment (mapconcat (lambda (x) (if x "r" "l"))
                               org-table-last-alignment ""))
         (params2
          (list
           :tstart (concat "%     \\begin{longtable}{ " alignment " }")
           :lstart "" :lend " \\\\" :sep " & "
           :efmt "%s\\,(%s)" :hline "\\hline")))
    (orgtbl-to-generic table (org-combine-plists params2 params))))
#+END_SRC



reply via email to

[Prev in Thread] Current Thread [Next in Thread]