* Create a longtable in LaTeX from orgtbl
@ 2014-06-17 23:11 Tak Kunihiro
2014-06-18 12:58 ` Oliver Kappel
2014-06-18 13:55 ` Oliver Kappel
0 siblings, 2 replies; 6+ messages in thread
From: Tak Kunihiro @ 2014-06-17 23:11 UTC (permalink / raw)
To: emacs-orgmode; +Cc: tkk
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Create a longtable in LaTeX from orgtbl
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
1 sibling, 0 replies; 6+ messages in thread
From: Oliver Kappel @ 2014-06-18 12:58 UTC (permalink / raw)
To: Tak Kunihiro; +Cc: emacs-orgmode
Hello,
I'm just using:
#+CAPTION: Table Heading shown in listoftables
#+NAME: tab:name_for_ref_to
#+ATTR_LATEX: :environment longtable :align |l|l|l|
|-------+-------+-------|
| Col 1 | Col 2 | Col 3 |
|-------+-------+-------|
Works fine on org-version 8.2.5h spanning the table via latex export
over several pages. Using LaTex package \longtable is set in
org-export-latex-default-packages-alist per default.
Just the phrase "continued on next page" is hardcoded in ox-latex.el
line 2620 if you need a localized output.
Greetings,
Oliver
At 18.06.2014 um 01:11 Tak Kunihiro wrote:
> Dear all,
>
> Can you show how to create a longtable in LaTeX from orgtbl?
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Create a longtable in LaTeX from orgtbl
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
1 sibling, 1 reply; 6+ messages in thread
From: Oliver Kappel @ 2014-06-18 13:55 UTC (permalink / raw)
To: emacs-orgmode
Hello,
I'm just using:
#+CAPTION: Table headline shown in \listoftables
#+NAME: tab:name_for_ref_to
#+ATTR_LATEX: :environment longtable :align |l|l|l|
|-------+-------+-------|
| Col 1 | Col 2 | Col 3 |
|-------+-------+-------|
Works fine on org-version 8.2.5h spanning the table via latex export
over several pages. LaTex \usepackage{longtable} is set in
org-export-latex-default-packages-alist per default.
Just the phrase "continued on next page" is hardcoded in ox-latex.el
line 2620 if you need a localized output.
Greetings,
Oliver
At 18.06.2014 um 01:11 Tak Kunihiro wrote:
> Dear all,
>
> Can you show how to create a longtable in LaTeX from orgtbl?
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Create a longtable in LaTeX from orgtbl
2014-06-18 13:55 ` Oliver Kappel
@ 2014-06-18 14:33 ` Nick Dokos
2014-06-18 17:40 ` Oliver Kappel
0 siblings, 1 reply; 6+ messages in thread
From: Nick Dokos @ 2014-06-18 14:33 UTC (permalink / raw)
To: emacs-orgmode
Oliver Kappel <ngreply@gmx.net> writes:
> Hello,
>
> I'm just using:
>
> #+CAPTION: Table headline shown in \listoftables
> #+NAME: tab:name_for_ref_to
> #+ATTR_LATEX: :environment longtable :align |l|l|l|
> |-------+-------+-------|
> | Col 1 | Col 2 | Col 3 |
> |-------+-------+-------|
>
> Works fine on org-version 8.2.5h spanning the table via latex export
> over several pages. LaTex \usepackage{longtable} is set in
> org-export-latex-default-packages-alist per default.
>
> Just the phrase "continued on next page" is hardcoded in ox-latex.el
> line 2620 if you need a localized output.
>
>>
>> Can you show how to create a longtable in LaTeX from orgtbl?
>>
"orgtbl" is the operative word here: the OP is *not* talking about an
org file, but about a LaTeX file with a radio table. See
(info "(org) Radio tables")
for details.
Nick
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Create a longtable in LaTeX from orgtbl
2014-06-18 14:33 ` Nick Dokos
@ 2014-06-18 17:40 ` Oliver Kappel
0 siblings, 0 replies; 6+ messages in thread
From: Oliver Kappel @ 2014-06-18 17:40 UTC (permalink / raw)
To: emacs-orgmode
Am 18.06.2014 um 16:33 schrieb Nick Dokos:
> Oliver Kappel <ngreply@gmx.net> writes:
>
>>
>> I'm just using:
>>
>> #+CAPTION: Table headline shown in \listoftables
>> #+NAME: tab:name_for_ref_to
>> #+ATTR_LATEX: :environment longtable :align |l|l|l|
>> |-------+-------+-------|
>> | Col 1 | Col 2 | Col 3 |
>> |-------+-------+-------|
>>
>>
>>>
>>> Can you show how to create a longtable in LaTeX from orgtbl?
>>>
>
> "orgtbl" is the operative word here: the OP is *not* talking about an
> org file, but about a LaTeX file with a radio table. See
>
> (info "(org) Radio tables")
>
> for details.
>
> Nick
Ah, I've missed that and sorry for double posting.
Isn't pretty, but working:
#+BEGIN_SRC LaTeX
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{longtable}
\usepackage{comment}
\begin{document}
\begin{longtable}{rll}
% BEGIN RECEIVE ORGTBL my-long-table
% END RECEIVE ORGTBL my-long-table
\end{longtable}
%
\begin{comment}
#+ORGTBL: SEND my-long-table orgtbl-to-latex :splice t :escape t
|---------------------+---------+--------|
| date | session | remark |
|---------------------+---------+--------|
| \endhead 2014-06-18 | s140618 | |
\end{comment}
%
\end{document}
#+END_SRC
Regards,
Oliver
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Create a longtable in LaTeX from orgtbl
@ 2014-10-11 6:25 Tak Kunihiro
0 siblings, 0 replies; 6+ messages in thread
From: Tak Kunihiro @ 2014-10-11 6:25 UTC (permalink / raw)
To: emacs-orgmode; +Cc: tak.kunihiro
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))))
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-10-11 6:26 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
-- strict thread matches above, loose matches on Subject: below --
2014-10-11 6:25 Tak Kunihiro
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).