This is perfect. Thank you, Juan Manuel.

Vikas

On Thu, 2 Sept 2021 at 14:06, Juan Manuel Macías <maciasch...@posteo.net>
wrote:

> Hi Vikas,
>
> You can define a modified version of `org-latex--org-table',
> adding a new LaTeX attribute `:options'. Something like this:
>
> #+begin_src emacs-lisp
> (defun my/org-latex--org-table (table contents info)
>   "Return appropriate LaTeX code for an Org table.
>
> 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
> `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
>           (let ((w (plist-get attr :width)))
>             (cond ((not w) "")
>                   ((member table-env '("tabular" "longtable")) "")
>                   ((member table-env '("tabu" "longtabu"))
>                    (format (if (plist-get attr :spread) " spread %s "
>                              " to %s ")
>                            w))
>                   (t (format "{%s}" w)))))
>          (caption (org-latex--caption/label-string table info))
>          (above? (org-latex--caption-above-p table info)))
>     (cond
>      ((member table-env '("longtable" "longtabu"))
>       (let ((fontsize (let ((font (plist-get attr :font)))
>                         (and font (concat font "\n")))))
>         (concat (and fontsize (concat "{" fontsize))
>                 (format "\\begin{%s}%s{%s}\n" table-env width alignment)
>                 (and above?
>                      (org-string-nw-p caption)
>                      (concat caption "\\\\\n"))
>                 contents
>                 (and (not above?)
>                      (org-string-nw-p caption)
>                      (concat caption "\\\\\n"))
>                 (format "\\end{%s}" table-env)
>                 (and fontsize "}"))))
>      (t
>       (let ((output (format "\\begin{%s}%s%s{%s}\n%s\\end{%s}"
>                             table-env
>                             (if opt opt "")
>                             width
>                             alignment
>                             contents
>                             table-env)))
>         (org-latex--decorate-table output attr caption above? info))))))
>
> (advice-add 'org-latex--org-table :override #'my/org-latex--org-table)
> #+end_src
>
> and then:
>
> #+ATTR_LATEX: :environment longtblr
> #+ATTR_LATEX: :align <align-options>
> #+ATTR_LATEX: :booktabs t
> #+ATTR_LaTeX: :options [<options>]
>
> Best regards,
>
> Juan Manuel
>
> Vikas Rawal writes:
>
> > tabularray (CTAN: Package tabularray) provides longtblr environment
> > that is called as
> >
> > ---
> > \begin{longtblr}[various-table-options]{column and row specifications}
> >
> > \end{longtblr}
> > ---
> >
> > Adding something like the following to orgmode tables makes them
> > export nicely as longtblr
> >
> > ---
> > #+ATTR_LATEX: :environment longtblr
> > #+ATTR_LATEX: :align width=0.8\textwidth,colspec={lX[2,r]X[3,r]X
> > [r,bg=gray9]}
> > #+ATTR_LATEX: :booktabs t
> > ---
> >
> > Everything seems to work very well with orgmode except that I cannot
> > figure out how to pass [various table options] from orgmode. These
> > table options include, most importantly, table notes.
> >
> > I normally use threeparttable for table notes, but longtblr does not
> > seem to work with threeparttable and has its own syntax for table
> > notes.
> >
> > Any advice on how to pass [table-options] to longtblr environment?
> >
> > Vikas
> >
>

Reply via email to