all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [patch] ox-latex.el: add `:options' LaTeX attribute to tables
@ 2021-10-26 16:05 Juan Manuel Macías
  2021-10-27  3:44 ` Vikas Rawal
  2021-11-03 16:32 ` Nicolas Goaziou
  0 siblings, 2 replies; 14+ messages in thread
From: Juan Manuel Macías @ 2021-10-26 16:05 UTC (permalink / raw)
  To: orgmode; +Cc: Vikas Rawal

[-- Attachment #1: Type: text/plain, Size: 652 bytes --]

Hi,

The `:options' attr. allows adding an optional argument with various
table options (between brackets in LaTeX export), since certain tabular
environments, such as `longtblr' of the `tabularray' LaTeX package,
provides this structure (see:
https://list.orgmode.org/CALtzAB1yM+uG_xHghCxTLRX5mgbzNvT5+PO=DuaBB28nCsVqEA@mail.gmail.com/#r)

Example:

#+ATTR_LATEX: :environment longtblr
#+ATTR_LATEX: :align colspec = {XXX}, width = 0.85\linewidth
#+ATTR_LATEX: :options remark{Note} = {Lorem ipsum dolor sit amet}

==> \begin{longtblr}[remark{Note} = {Lorem ipsum dolor sit amet}]{colspec = {XXX}, width = 0.85\linewidth}

Best regards,

Juan Manuel


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox-latex.el-add-options-latex-attribute-to-tables.patch --]
[-- Type: text/x-patch, Size: 1495 bytes --]

From 9b51d999029f91adc93a6009bc3ddf56bba7ba4a Mon Sep 17 00:00:00 2001
From: Juan Manuel Macias <maciaschain@posteo.net>
Date: Tue, 26 Oct 2021 12:29:55 +0200
Subject: [PATCH] ox-latex.el: add `options' latex attribute to tables

* lisp/ox-latex.el (org-latex--org-table): The `:options' LaTeX
attribute allows adding an optional argument (\begin{env}[opt]), since
certain tabular environments, such as longtblr, accept optional
arguments.
---
 lisp/ox-latex.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 3e3967033..409d92164 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -3314,6 +3314,7 @@ This function assumes TABLE has `org' as its `:type' property and
 `table' as its `:mode' attribute."
   (let* ((attr (org-export-read-attribute :attr_latex table))
 	 (alignment (org-latex--align-string table info))
+         (opt (org-export-read-attribute :attr_latex table :options))
 	 (table-env (or (plist-get attr :environment)
 			(plist-get info :latex-default-table-environment)))
 	 (width
@@ -3343,8 +3344,9 @@ This function assumes TABLE has `org' as its `:type' property and
 		(format "\\end{%s}" table-env)
 		(and fontsize "}"))))
      (t
-      (let ((output (format "\\begin{%s}%s{%s}\n%s\\end{%s}"
+      (let ((output (format "\\begin{%s}%s%s{%s}\n%s\\end{%s}"
 			    table-env
+                            (if opt (format "[%s]" opt) "")
 			    width
 			    alignment
 			    contents
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-11-06 13:52 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-26 16:05 [patch] ox-latex.el: add `:options' LaTeX attribute to tables Juan Manuel Macías
2021-10-27  3:44 ` Vikas Rawal
2021-10-27 15:52   ` Juan Manuel Macías
2021-10-28 16:10     ` Vikas Rawal
2021-10-28 18:02       ` Juan Manuel Macías
2021-10-28 19:39         ` Juan Manuel Macías
2021-10-29  1:13           ` Vikas Rawal
2021-10-29  1:07         ` Vikas Rawal
2021-10-29  1:08         ` Vikas Rawal
2021-11-03 16:32 ` Nicolas Goaziou
2021-11-03 17:38   ` Juan Manuel Macías
2021-11-03 18:33     ` Nicolas Goaziou
2021-11-04 20:59       ` Juan Manuel Macías
2021-11-06 13:51         ` Nicolas Goaziou

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.