From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: Export tables as matrices (change tbl-export function on the fly) Date: Wed, 14 Nov 2012 19:05:08 +0100 Message-ID: <87txssm563.fsf@pank.iue.private> References: <877gpojl2s.fsf@pank.iue.private> <87y5i4yx2w.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([208.118.235.92]:53889) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TYhL7-0006rf-5R for emacs-orgmode@gnu.org; Wed, 14 Nov 2012 13:05:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TYhL4-0005B1-2v for emacs-orgmode@gnu.org; Wed, 14 Nov 2012 13:05:29 -0500 Received: from mailout-eu.gmx.com ([213.165.64.43]:50053) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1TYhL3-00059l-Q8 for emacs-orgmode@gnu.org; Wed, 14 Nov 2012 13:05:26 -0500 In-Reply-To: <87y5i4yx2w.fsf@gmail.com> (Nicolas Goaziou's message of "Wed, 14 Nov 2012 17:21:27 +0100") 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: n.goaziou@gmail.com Cc: emacs-orgmode@gnu.org Nicolas Goaziou writes: > Hello, > > Rasmus writes: > >> I'm doing some stuff where the natural output of my tables are >> matrices. I found a decent translation function here=C2=A0=C2=B9. Howe= ver, >> I'm not very successful in making org use it.=20 > > Using the new exporter, something like should replace any table using > default environment (i.e. no special attribute) and without horizontal > rules with bmatrix environment. It should also insert it in math mode > automatically. this one seems to work better for me, but might be more ugly . . . #+begin_src emacs-lisp (defun my-latex-table-to-matrix (table backend info) (when (and (memq backend '(e-latex e-beamer)) (not (string-match "\\\\^[A-Za-z]+$" table)) (not (string-match "\\begin{\\(table*\\|sidewaystable\\)}" tab= le))) (let ((default-env (format "\\\\\\(begin\\|end\\){\\(%s\\)}.*" org-e-latex-default-table-environment))) (when (string-match default-env table) (concat "\\[\n" (org-trim (replace-regexp-in-string "\n\n" "\n" (replace-regexp-in-string "\\\\\\(begin\\|end\\){\\(center\\|table\\)}\\|\\\\toprul= e\\|\\\\bottomrule\\|\[[htbH]+?\]" "" (replace-regexp-in-string default-env "\\\\\\1{bmatrix}" table)))) "\n\\]\n"))))) (add-to-list 'org-export-filter-table-functions 'my-latex-table-to-matrix) #+end_src --=20 Dung makes an excellent fertilizer