[Top][All Lists]

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

[elpa] externals/org 4a0d951c64: ox-latex tabbing environment support

From: ELPA Syncer
Subject: [elpa] externals/org 4a0d951c64: ox-latex tabbing environment support
Date: Tue, 21 Jun 2022 00:57:58 -0400 (EDT)

branch: externals/org
commit 4a0d951c647fa9ddd7c2c9d896f5fb5c66fce42c
Author: Daniel Fleischer <danflscr@gmail.com>
Commit: Daniel Fleischer <danflscr@gmail.com>

    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>
 doc/org-manual.org |  4 +++-
 etc/ORG-NEWS       | 12 +++++++++++
 lisp/ox-latex.el   | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++----
 3 files changed, 73 insertions(+), 5 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 6431470dd9..4e89f0e101 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -13546,10 +13546,12 @@ include:
   #+vindex: org-latex-default-table-mode
   The LaTeX export back-end wraps the table differently depending on
   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
   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
   ~org-latex-default-table-mode~.  The LaTeX export back-end merges
   contiguous tables in the same mode into a single environment.
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 4702da9b5f..7225031ee6 100644
--- a/etc/ORG-NEWS
+++ b/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.
 When the block type starts from the upper case, structure template
 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
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 8c43fadadb..898fa34dd0 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -3640,7 +3640,8 @@ CONTENTS is the contents of the object."
 ;; `org-latex-table' is the entry point for table transcoding.  It
 ;; takes care of tables with a "verbatim" mode.  Otherwise, it
 ;; 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.
 ;; `org-latex--align-string' is a subroutine used to build alignment
@@ -3664,8 +3665,10 @@ contextual information."
                           `(table nil ,@(org-element-contents table))))))
        ;; Case 2: Matrix.
        ((or (string= type "math") (string= type "inline-math"))
-       (org-latex--math-table table info))
-       ;; Case 3: Standard table.
+        (org-latex--math-table table info))
+       ;; 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)
                  ;; When there are footnote references within the
                  ;; table, insert their definition just after it.
@@ -3702,6 +3705,34 @@ centered."
        (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) 
+                        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)
   "Decorate TABLE string with caption and float environment.
@@ -3804,6 +3835,23 @@ This function assumes TABLE has `org' as its `:type' 
property and
        (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
+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)
   "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.
 CONTENTS is the cell contents.  INFO is a plist used as
 a communication channel."
+  (let (
+        (type (org-export-read-attribute :attr_latex 
(org-export-get-parent-table table-cell) :mode))
+        )
    (let ((scientific-format (plist-get info :latex-table-scientific-notation)))
      (if (and contents
@@ -3898,7 +3949,10 @@ a communication channel."
                 (match-string 1 contents)
                 (match-string 2 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

reply via email to

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