Function: org-latex--wrap-latex-matrices
org-latex--wrap-latex-matrices is a byte-compiled function defined in
ox-latex.el.gz.
Signature
(org-latex--wrap-latex-matrices DATA INFO)
Documentation
Merge contiguous tables with the same mode within a pseudo-element.
DATA is a parse tree or a secondary string. INFO is a plist containing export options. Modify DATA by side-effect and return it.
Source Code
;; Defined in /usr/src/emacs/lisp/org/ox-latex.el.gz
;;;; Pseudo Element: LaTeX Matrices
;; `latex-matrices' elements have the following properties:
;; `:caption', `:post-blank' and `:markup' (`inline', `equation' or
;; `math').
(defun org-latex--wrap-latex-matrices (data info)
"Merge contiguous tables with the same mode within a pseudo-element.
DATA is a parse tree or a secondary string. INFO is a plist
containing export options. Modify DATA by side-effect and return
it."
(org-element-map data 'table
(lambda (table)
(when (eq (org-element-property :type table) 'org)
(let ((mode (or (org-export-read-attribute :attr_latex table :mode)
(plist-get info :latex-default-table-mode))))
(when (and (member mode '("inline-math" "math"))
;; Do not wrap twice the same table.
(not (eq (org-element-type
(org-element-property :parent table))
'latex-matrices)))
(let* ((caption (and (not (string= mode "inline-math"))
(org-element-property :caption table)))
(name (and (not (string= mode "inline-math"))
(org-element-property :name table)))
(matrices
(list 'latex-matrices
;; Inherit name from the first table.
(list :name name
;; FIXME: what syntax for captions?
;;
;; :caption caption
:markup
(cond ((string= mode "inline-math") 'inline)
((or caption name) 'equation)
(t 'math)))))
(previous table)
(next (org-export-get-next-element table info)))
(org-element-insert-before matrices table)
;; Swallow all contiguous tables sharing the same mode.
(while (and
(zerop (or (org-element-property :post-blank previous) 0))
(setq next (org-export-get-next-element previous info))
(eq (org-element-type next) 'table)
(eq (org-element-property :type next) 'org)
(string= (or (org-export-read-attribute
:attr_latex next :mode)
(plist-get info :latex-default-table-mode))
mode))
(org-element-put-property table :name nil)
(org-element-put-property table :caption nil)
(org-element-extract-element previous)
(org-element-adopt-elements matrices previous)
(setq previous next))
;; Inherit `:post-blank' from the value of the last
;; swallowed table. Set the latter's `:post-blank'
;; value to 0 so as to not duplicate empty lines.
(org-element-put-property
matrices :post-blank (org-element-property :post-blank previous))
(org-element-put-property previous :post-blank 0)
(org-element-put-property table :name nil)
(org-element-put-property table :caption nil)
(org-element-extract-element previous)
(org-element-adopt-elements matrices previous))))))
info)
data)