From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Ulrich G. Wortmann" Subject: Re: Bug: org export table.el [9.1.9 (release_9.1.9-65-g5e4542 @ /usr/share/emacs/26.1/lisp/org/)] Date: Wed, 28 Nov 2018 12:10:34 -0500 Message-ID: References: <87a7ly3jg0.fsf@nicolasgoaziou.fr> <87woozwo1d.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000943daf057bbca5ac" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53663) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gS3MS-0007sN-En for emacs-orgmode@gnu.org; Wed, 28 Nov 2018 12:10:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gS3MO-00022H-Sh for emacs-orgmode@gnu.org; Wed, 28 Nov 2018 12:10:52 -0500 Received: from mail-pf1-f175.google.com ([209.85.210.175]:36632) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gS3MO-0001yC-Af for emacs-orgmode@gnu.org; Wed, 28 Nov 2018 12:10:48 -0500 Received: by mail-pf1-f175.google.com with SMTP id b85so10474757pfc.3 for ; Wed, 28 Nov 2018 09:10:47 -0800 (PST) In-Reply-To: <87woozwo1d.fsf@nicolasgoaziou.fr> 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" To: emacs-orgmode@gnu.org --000000000000943daf057bbca5ac Content-Type: text/plain; charset="UTF-8" Hi Nicolas, I know nothing about lisp, but I think I understand enough of the structure to propose the following changes: In my testfile, this preserves the current behavior if no #+CAPTION is present. However, if the #+CAPTION is not empty, the table will be exported as float with the proper caption and label. The code needs probably some cleanup, but I don't understand enough lisp to know what's save to drop. Hope this can be merged Cheers Uli --- org-mode/lisp/ox-latex.el 2018-11-28 11:58:15.234232222 -0500 +++ org-mode-uliw/ox-latex.el.uliw 2018-11-28 11:57:09.057281230 -0500 @@ -3305,6 +3310,21 @@ This function assumes TABLE has `table.el' as its `:type' property." + (let* ((caption (org-latex--caption/label-string table info)) + (attr (org-export-read-attribute :attr_latex table)) + ;; Determine alignment string. + (alignment (org-latex--align-string table info)) + ;; Determine environment for the table: longtable, tabular... + (table-env (or (plist-get attr :environment) + (plist-get info :latex-default-table-environment))) + ;; If table is a float, determine environment: table, table* + ;; or sidewaystable. + (placement + (or (plist-get attr :placement) + (format "[%s]" (plist-get info :latex-default-figure-position)))) + (centerp (if (plist-member attr :center) (plist-get attr :center) + (plist-get info :latex-tables-centered))) + (caption-above-p (org-latex--caption-above-p table info))) (require 'table) ;; Ensure "*org-export-table*" buffer is empty. (with-current-buffer (get-buffer-create "*org-export-table*") @@ -3332,7 +3352,16 @@ (let ((centerp (if (plist-member attr :center) (plist-get attr :center) (plist-get info :latex-tables-centered)))) (if (not centerp) output - (format "\\begin{center}\n%s\n\\end{center}" output)))))) + (if (string= "" caption) + (format (concat "\\begin{center}\n" + "%s\n" + "\\end{center}\n") output) + (format (concat "\\begin{table}\n" + caption + "\\centering\n" + "%s\n" + "\\end{table}\n") output)) + )))))) (defun org-latex--math-table (table info) "Return appropriate LaTeX code for a matrix. On Mon, 26 Nov 2018 at 16:02 Nicolas Goaziou wrote: > Hello, > > "Ulrich G. Wortmann" writes: > > > I had a quick look at table.el > > > > It exports only a tabular command, not a table. Is there a way to make > org > > wrap the > > > > \begin{tabular} > > \end{tabular} > > > > into a regular > > > > \begin{table} > > \end{table} > > > > This would be perfectly correct latex, and keep the export mechanism, > > neatly separated > > You may want to look at `org-latex--table.el-table' and see what can be > done. > > Regards, > > -- > Nicolas Goaziou > -- Ulrich Wortmann 416 978 7084 Associate Chair Undergraduate Affairs Department of Earth Sciences University of Toronto 22 Russel St., Toronto, ON, Canada, M5S 3B1 --000000000000943daf057bbca5ac Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Nicolas,

I know nothing about lisp, = but I think I understand enough of the structure to propose the following c= hanges:

In my testfile, this preserves the current= behavior if no #+CAPTION is present. However, if the=C2=A0=C2=A0#+CAPTION = is not empty, the table will be exported as float with the proper caption a= nd label. The code needs probably some cleanup, but I don't understand = enough lisp to know what's save to drop.

Hope = this can be merged=C2=A0

Cheers

Uli

--- org-mode/lisp/ox-latex.el=C2= =A0 =C2=A02018-11-28 11:58:15.234232222 -0500
+++ org-mode-uliw/o= x-latex.el.uliw=C2=A0 =C2=A0 =C2=A0 2018-11-28 11:57:09.057281230 -0500

@@ -3305,6 +3310,21 @@

=
=C2=A0This function assumes TABLE has `table.el' as its `:ty= pe'
=C2=A0property."
+=C2=A0 (let* ((caption (= org-latex--caption/label-string table info))
+=C2=A0 =C2=A0 =C2= =A0 =C2=A0 (attr (org-export-read-attribute :attr_latex table))
+= =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; Determine alignment string.
+=C2= =A0 =C2=A0 =C2=A0 =C2=A0 (alignment (org-latex--align-string table info))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; Determine environment for the tabl= e: longtable, tabular...
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 (table-env = (or (plist-get attr :environment)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(plist-get info :lat= ex-default-table-environment)))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; I= f table is a float, determine environment: table, table*
+=C2=A0 = =C2=A0 =C2=A0 =C2=A0 ;; or sidewaystable.
+=C2=A0 =C2=A0 =C2=A0 = =C2=A0 (placement
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(or (plist-g= et attr :placement)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0(format "[%s]" (plist-get info :latex-default-figure-positi= on))))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 (centerp (if (plist-member at= tr :center) (plist-get attr :center)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(plist-get info :latex-tables-cen= tered)))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 (caption-above-p (org-latex= --caption-above-p table info)))
=C2=A0 =C2=A0(require 'table)=
=C2=A0 =C2=A0;; Ensure "*org-export-table*" buffer is = empty.
=C2=A0 =C2=A0(with-current-buffer (get-buffer-create "= ;*org-export-table*")
@@ -3332,7 +3352,16 @@
=C2= =A0 =C2=A0 =C2=A0 =C2=A0(let ((centerp (if (plist-member attr :center) (pli= st-get attr :center)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(plist-get info :latex-tables-cent= ered))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (if (not centerp) output
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(format "\\begin{center}\n%s= \n\\end{center}" output))))))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0(if (string=3D "" caption)
+=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0(format (concat "\\begin{center}\n"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"%s\n"
+=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0"\\end{center}\n") output)
+=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(format (concat "\\begin{table}\= n"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0caption
+=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0"\\centering\n"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"= %s\n"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"\\end{table}\n") ou= tput))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0))))))

=C2=A0(defun org-latex--math-table (table info)
=C2=A0 = =C2=A0"Return appropriate LaTeX code for a matrix.


On Mon, = 26 Nov 2018 at 16:02 Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
Hello,

"Ulrich G. Wortmann" <uli.wortmann@utoronto.ca> writes:

> I had a quick look at table.el
>
> It exports only a tabular command, not a table. Is there a way to make= org
> wrap the
>
> \begin{tabular}
> \end{tabular}
>
> into a regular
>
> \begin{table}
> \end{table}
>
> This would be perfectly correct latex, and keep the export mechanism,<= br> > neatly separated

You may want to look at `org-latex--table.el-table' and see what can be=
done.

Regards,

--
Nicolas Goaziou
--

Ulrich Wortman= n=C2=A0416 978 7084

Associate Chair Undergra= duate=C2=A0Affairs

Department of Earth Sciences

University of Toronto
22 Russel St., Toronto, ON, Canada, M5S 3B1

--000000000000943daf057bbca5ac--