From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tak Kunihiro Subject: Create a longtable in LaTeX from orgtbl Date: Wed, 18 Jun 2014 08:11:32 +0900 (JST) Message-ID: <20140618.081132.282414798.tkk@misasa.okayama-u.ac.jp> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:44478) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wx2Xd-0008BR-TY for emacs-orgmode@gnu.org; Tue, 17 Jun 2014 19:11:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wx2XX-0001vI-Sc for emacs-orgmode@gnu.org; Tue, 17 Jun 2014 19:11:49 -0400 Received: from msmail2.misasa.okayama-u.ac.jp ([150.46.245.7]:53892 helo=msmail.misasa.okayama-u.ac.jp) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wx2XW-0001l9-Tc for emacs-orgmode@gnu.org; Tue, 17 Jun 2014 19:11:43 -0400 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Cc: tkk@misasa.okayama-u.ac.jp 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