From: Tak Kunihiro <tak.kunihiro@gmail.com>
To: emacs-orgmode@gnu.org
Cc: tak.kunihiro@gmail.com
Subject: Re: Create a longtable in LaTeX from orgtbl
Date: Sat, 11 Oct 2014 15:25:40 +0900 (JST) [thread overview]
Message-ID: <20141011.152540.499262102.tak.kunihiro@gmail.com> (raw)
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))))
next reply other threads:[~2014-10-11 6:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-11 6:25 Tak Kunihiro [this message]
-- strict thread matches above, loose matches on Subject: below --
2014-06-17 23:11 Create a longtable in LaTeX from orgtbl Tak Kunihiro
2014-06-18 12:58 ` Oliver Kappel
2014-06-18 13:55 ` Oliver Kappel
2014-06-18 14:33 ` Nick Dokos
2014-06-18 17:40 ` Oliver Kappel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20141011.152540.499262102.tak.kunihiro@gmail.com \
--to=tak.kunihiro@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).