ox-latex tabbing environment support
* lisp/ox-latex.el: New `org-latex--align-string-tabbing', `org-table--org-tabbing' functions. Modified `org-latex-table-cell' to use optional tabbing delimiters. * etc/ORG-NEWS: support in ox-latex for tabbing environment. * doc/org-manual.org: mention support for new environment. Created-by: Bob Vergauwen <emacs@vergauwen.me>
This commit is contained in:
parent
f77800c68b
commit
4a0d951c64
|
@ -13546,10 +13546,12 @@ include:
|
||||||
#+vindex: org-latex-default-table-mode
|
#+vindex: org-latex-default-table-mode
|
||||||
The LaTeX export back-end wraps the table differently depending on
|
The LaTeX export back-end wraps the table differently depending on
|
||||||
the mode for accurate rendering of math symbols. Mode is either
|
the mode for accurate rendering of math symbols. Mode is either
|
||||||
=table=, =math=, =inline-math= or =verbatim=.
|
=table=, =math=, =inline-math=, =verbatim= or =tabbing=.
|
||||||
|
|
||||||
For =math= or =inline-math= mode, LaTeX export back-end wraps the
|
For =math= or =inline-math= mode, LaTeX export back-end wraps the
|
||||||
table in a math environment, but every cell in it is exported as-is.
|
table in a math environment, but every cell in it is exported as-is.
|
||||||
|
For =tabbing= the LaTeX tabbing environment is used and the correct
|
||||||
|
tabbing delimiters =\>= are used.
|
||||||
The LaTeX export back-end determines the default mode from
|
The LaTeX export back-end determines the default mode from
|
||||||
~org-latex-default-table-mode~. The LaTeX export back-end merges
|
~org-latex-default-table-mode~. The LaTeX export back-end merges
|
||||||
contiguous tables in the same mode into a single environment.
|
contiguous tables in the same mode into a single environment.
|
||||||
|
|
12
etc/ORG-NEWS
12
etc/ORG-NEWS
|
@ -227,6 +227,18 @@ produce results superior to Minted or Listings.
|
||||||
The block type in ~org-structure-template-alist~ is not case-sensitive.
|
The block type in ~org-structure-template-alist~ is not case-sensitive.
|
||||||
When the block type starts from the upper case, structure template
|
When the block type starts from the upper case, structure template
|
||||||
will now insert =#+BEGIN_TYPE=. Previously, lower-case =#+begin_type= was inserted unconditionally.
|
will now insert =#+BEGIN_TYPE=. Previously, lower-case =#+begin_type= was inserted unconditionally.
|
||||||
|
*** New ox-latex tabbing support for tables.
|
||||||
|
|
||||||
|
Latex tables can now be exported to the latex tabbing environment
|
||||||
|
tabbing environment]].
|
||||||
|
This is done by adding =#+ATTR_LATEX: :mode tabbing= at the top
|
||||||
|
of the table.
|
||||||
|
The default column width is set to 1/n times the latex textwidth,
|
||||||
|
where n is the number of columns.
|
||||||
|
This behaviour can be changed by supplying a =:align= parameter.
|
||||||
|
|
||||||
|
The tabbing environment can be useful when generating simple tables which
|
||||||
|
can be span multiple pages and when table cells are allowed to overflow.
|
||||||
|
|
||||||
** New functions and changes in function arguments
|
** New functions and changes in function arguments
|
||||||
|
|
||||||
|
|
|
@ -3640,7 +3640,8 @@ CONTENTS is the contents of the object."
|
||||||
;; `org-latex-table' is the entry point for table transcoding. It
|
;; `org-latex-table' is the entry point for table transcoding. It
|
||||||
;; takes care of tables with a "verbatim" mode. Otherwise, it
|
;; takes care of tables with a "verbatim" mode. Otherwise, it
|
||||||
;; delegates the job to either `org-latex--table.el-table',
|
;; delegates the job to either `org-latex--table.el-table',
|
||||||
;; `org-latex--org-table' or `org-latex--math-table' functions,
|
;; `org-latex--org-table', `org-latex--math-table' or
|
||||||
|
;; `org-latex--org-tabbing' functions,
|
||||||
;; depending of the type of the table and the mode requested.
|
;; depending of the type of the table and the mode requested.
|
||||||
;;
|
;;
|
||||||
;; `org-latex--align-string' is a subroutine used to build alignment
|
;; `org-latex--align-string' is a subroutine used to build alignment
|
||||||
|
@ -3665,7 +3666,9 @@ contextual information."
|
||||||
;; Case 2: Matrix.
|
;; Case 2: Matrix.
|
||||||
((or (string= type "math") (string= type "inline-math"))
|
((or (string= type "math") (string= type "inline-math"))
|
||||||
(org-latex--math-table table info))
|
(org-latex--math-table table info))
|
||||||
;; Case 3: Standard table.
|
;; Case 3: Tabbing
|
||||||
|
((string= type "tabbing") (org-table--org-tabbing table contents info))
|
||||||
|
;; Case 4: Standard table.
|
||||||
(t (concat (org-latex--org-table table contents info)
|
(t (concat (org-latex--org-table table contents info)
|
||||||
;; When there are footnote references within the
|
;; When there are footnote references within the
|
||||||
;; table, insert their definition just after it.
|
;; table, insert their definition just after it.
|
||||||
|
@ -3702,6 +3705,34 @@ centered."
|
||||||
info)
|
info)
|
||||||
(apply 'concat (nreverse align)))))
|
(apply 'concat (nreverse align)))))
|
||||||
|
|
||||||
|
(defun org-latex--align-string-tabbing (table info)
|
||||||
|
"Return an appropriate LaTeX alignment string, for the
|
||||||
|
latex tabbing environment.
|
||||||
|
TABLE is the considered table. INFO is a plist used as
|
||||||
|
a communication channel."
|
||||||
|
(or (org-export-read-attribute :attr_latex table :align)
|
||||||
|
(let ((align "")
|
||||||
|
(count 0)
|
||||||
|
(separator ""))
|
||||||
|
;; Count the number of cells in the first row.
|
||||||
|
(setq count (length
|
||||||
|
(org-element-map
|
||||||
|
(org-element-map table 'table-row
|
||||||
|
(lambda (row)
|
||||||
|
(and (eq (org-element-property :type row) 'standard) row))
|
||||||
|
info 'first-match)
|
||||||
|
'table-cell
|
||||||
|
(lambda (cell) cell))))
|
||||||
|
;; Calculate the column width, using a proportion of the documets
|
||||||
|
;; textwidth.
|
||||||
|
(setq separator (format
|
||||||
|
"\\hspace{%s\\textwidth} \\= "
|
||||||
|
(- (/ 1.0 count) 0.01)))
|
||||||
|
(setq align (concat
|
||||||
|
(apply 'concat (make-list count separator))
|
||||||
|
"\\kill")))
|
||||||
|
))
|
||||||
|
|
||||||
(defun org-latex--decorate-table (table attributes caption above? info)
|
(defun org-latex--decorate-table (table attributes caption above? info)
|
||||||
"Decorate TABLE string with caption and float environment.
|
"Decorate TABLE string with caption and float environment.
|
||||||
|
|
||||||
|
@ -3804,6 +3835,23 @@ This function assumes TABLE has `org' as its `:type' property and
|
||||||
table-env)))
|
table-env)))
|
||||||
(org-latex--decorate-table output attr caption above? info))))))
|
(org-latex--decorate-table output attr caption above? info))))))
|
||||||
|
|
||||||
|
|
||||||
|
(defun org-table--org-tabbing (table contenst info)
|
||||||
|
"Return appropriate LaTeX code for an Org table, using the
|
||||||
|
latex tabbing syntax.
|
||||||
|
TABLE is the table type element to transcode. CONTENTS is its
|
||||||
|
contents, as a string. INFO is a plist used as a communication
|
||||||
|
channel.
|
||||||
|
This function assumes TABLE has `org' as its `:type' property and
|
||||||
|
`tabbing' as its `:mode' attribute."
|
||||||
|
(let ((output (format "\\begin{%s}\n%s\n%s\\end{%s}"
|
||||||
|
"tabbing"
|
||||||
|
(org-latex--align-string-tabbing table info )
|
||||||
|
contenst
|
||||||
|
"tabbing")))
|
||||||
|
output)
|
||||||
|
)
|
||||||
|
|
||||||
(defun org-latex--table.el-table (table info)
|
(defun org-latex--table.el-table (table info)
|
||||||
"Return appropriate LaTeX code for a table.el table.
|
"Return appropriate LaTeX code for a table.el table.
|
||||||
|
|
||||||
|
@ -3887,6 +3935,9 @@ This function assumes TABLE has `org' as its `:type' property and
|
||||||
"Transcode a TABLE-CELL element from Org to LaTeX.
|
"Transcode a TABLE-CELL element from Org to LaTeX.
|
||||||
CONTENTS is the cell contents. INFO is a plist used as
|
CONTENTS is the cell contents. INFO is a plist used as
|
||||||
a communication channel."
|
a communication channel."
|
||||||
|
(let (
|
||||||
|
(type (org-export-read-attribute :attr_latex (org-export-get-parent-table table-cell) :mode))
|
||||||
|
)
|
||||||
(concat
|
(concat
|
||||||
(let ((scientific-format (plist-get info :latex-table-scientific-notation)))
|
(let ((scientific-format (plist-get info :latex-table-scientific-notation)))
|
||||||
(if (and contents
|
(if (and contents
|
||||||
|
@ -3898,7 +3949,10 @@ a communication channel."
|
||||||
(match-string 1 contents)
|
(match-string 1 contents)
|
||||||
(match-string 2 contents))
|
(match-string 2 contents))
|
||||||
contents))
|
contents))
|
||||||
(when (org-export-get-next-element table-cell info) " & ")))
|
(when (org-export-get-next-element table-cell info)
|
||||||
|
(if (string= type "tabbing")
|
||||||
|
" \\> " " & ")
|
||||||
|
))))
|
||||||
|
|
||||||
|
|
||||||
;;;; Table Row
|
;;;; Table Row
|
||||||
|
|
Loading…
Reference in New Issue