From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tak Kunihiro Subject: Re: Create a longtable in LaTeX from orgtbl Date: Sat, 11 Oct 2014 15:25:40 +0900 (JST) Message-ID: <20141011.152540.499262102.tak.kunihiro@gmail.com> 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]:55973) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xcq7q-0008Vu-7W for emacs-orgmode@gnu.org; Sat, 11 Oct 2014 02:26:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xcq7j-000598-2J for emacs-orgmode@gnu.org; Sat, 11 Oct 2014 02:25:58 -0400 Received: from mail-pa0-x229.google.com ([2607:f8b0:400e:c03::229]:62445) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xcq7i-00058k-QT for emacs-orgmode@gnu.org; Sat, 11 Oct 2014 02:25:50 -0400 Received: by mail-pa0-f41.google.com with SMTP id eu11so3014347pac.0 for ; Fri, 10 Oct 2014 23:25:49 -0700 (PDT) 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: tak.kunihiro@gmail.com http://lists.gnu.org/archive/html/emacs-orgmode/2014-06/msg00634.html Thank you for responses in regard to making a longtable using a radio table. I found a way and want to let you know. \begin{footnotesize} \begin{center} % BEGIN RECEIVE ORGTBL tbl:greate-results % END RECEIVE ORGTBL tbl:greate-results \iffalse #+ORGTBL: SEND tbl:greate-results orgtbl-to-latex-long :no-escape t |------------+---------+---------| | date | session | remarks | |------------+---------+---------| | 2014-10-11 | s141011 | foo | |------------+---------+---------| \fi \end{center} \end{footnotesize} (defun orgtbl-to-latex-long (table params) "Convert the orgtbl-mode TABLE to long TABLE in LaTeX." (let* ((alignment (mapconcat (lambda (x) (if x "r" "l")) org-table-last-alignment "")) (params-common (list :lstart " " :lend " \\\\" :sep " & " :efmt "%s\\,(%s)" :hline " \\hline")) (params0 (list :tstart (concat " \\begin{longtable}{ " alignment " }\n" " \\caption{" (orgtbl-util-last-latex "caption") "}\\\\ % 1ST HEADER") :tend (concat " \\endfirsthead\n" " \\caption{Continued}\\\\ % 2ND HEADER"))) (params2 (list :tstart (concat " \\endhead\n" " % ----------------") :tend (concat " % ----------------\n" " \\label{" (orgtbl-util-last-latex "label") "}\n" " \\end{longtable}"))) (table-head (list (car table))) ; store 1st row (table-body (cdr table)) head0 head1 body *table-head-rtn*) ;; look for hline as head-body separator (when (memq 'hline table-body) (setq *table-head-rtn* (reverse table-head)) ; to use `push' instead of `append' (while (not (eq 'hline (car table-body))) ; check for 2nd+ row (push (car table-body) *table-head-rtn*) (pop table-body)) (push 'hline *table-head-rtn*) (pop table-body) (setq table-head (reverse *table-head-rtn*))) ;; create text (setq head0 (orgtbl-to-generic table-head (org-combine-plists params-common params0 params))) (setq head1 (orgtbl-to-generic table-head (org-combine-plists params-common params))) (setq body (orgtbl-to-generic table-body (org-combine-plists params-common params2 params))) (concat head0 "\n" head1 "\n" body))) (defun orgtbl-util-last-latex (command) "Go backward until `begin{longtable}' or beginning of current buffer and obtain first content in curly bracket of COMMAND." (save-excursion (let* ((end (point)) (start (or (search-backward "begin{longtable}" nil t) (point-min))) (string-to-search (buffer-substring start end))) (string-match (concat "\\" command "{\\([^}]*\\)}") string-to-search) (match-string 1 string-to-search))))