all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <n.goaziou@gmail.com>
To: Rasmus <rasmus@gmx.us>
Cc: emacs-orgmode@gnu.org
Subject: Re: Export tables as matrices (change tbl-export function on the fly)
Date: Wed, 14 Nov 2012 17:21:27 +0100	[thread overview]
Message-ID: <87y5i4yx2w.fsf@gmail.com> (raw)
In-Reply-To: <877gpojl2s.fsf@pank.iue.private> (rasmus@gmx.us's message of "Wed, 14 Nov 2012 15:49:47 +0100")

Hello,

Rasmus <rasmus@gmx.us> writes:

> I'm doing some stuff where the natural output of my tables are
> matrices.  I found a decent translation  function here ¹.  However,
> I'm not very successful in making org use it. 

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.

Untested.

#+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\\)}" table)))
    (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
                  "\\\\\\(begin\\|end\\){\\(center\\)}" ""
                  (replace-regexp-in-string
                   default-env "\\\\\\1{bmatrix}" table)))
                "\n\\]")))))

(add-to-list 'org-export-filter-table-functions 'my-latex-table-to-matrix)
#+end_src


Regards,

-- 
Nicolas Goaziou

  reply	other threads:[~2012-11-14 16:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-14 14:49 Export tables as matrices (change tbl-export function on the fly) Rasmus
2012-11-14 16:21 ` Nicolas Goaziou [this message]
2012-11-14 18:05   ` Rasmus
2012-11-17 13:26   ` Rasmus Pank Roulund
2012-11-17 15:32     ` Nicolas Goaziou
2012-11-17 18:29       ` Rasmus
2012-11-18  8:53         ` Nicolas Goaziou
2012-11-18 11:50           ` Rasmus
2012-11-18 13:20             ` Nicolas Goaziou
2012-11-18 14:05               ` Rasmus
2012-11-18 19:12                 ` Nicolas Goaziou

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y5i4yx2w.fsf@gmail.com \
    --to=n.goaziou@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=rasmus@gmx.us \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.