emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Tak Kunihiro <tkk@misasa.okayama-u.ac.jp>
To: emacs-orgmode@gnu.org
Cc: tkk@misasa.okayama-u.ac.jp
Subject: Create a longtable in LaTeX from orgtbl
Date: Wed, 18 Jun 2014 08:11:32 +0900 (JST)	[thread overview]
Message-ID: <20140618.081132.282414798.tkk@misasa.okayama-u.ac.jp> (raw)

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	other threads:[~2014-06-17 23:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-17 23:11 Tak Kunihiro [this message]
2014-06-18 12:58 ` Create a longtable in LaTeX from orgtbl Oliver Kappel
2014-06-18 13:55 ` Oliver Kappel
2014-06-18 14:33   ` Nick Dokos
2014-06-18 17:40     ` Oliver Kappel
  -- strict thread matches above, loose matches on Subject: below --
2014-10-11  6:25 Tak Kunihiro

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=20140618.081132.282414798.tkk@misasa.okayama-u.ac.jp \
    --to=tkk@misasa.okayama-u.ac.jp \
    --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).