emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Export tables as matrices (change tbl-export function on the fly


From: Nicolas Goaziou
Subject: Re: [O] Export tables as matrices (change tbl-export function on the fly)
Date: Wed, 14 Nov 2012 17:21:27 +0100

Hello,

Rasmus <address@hidden> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]