emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Vikas Rawal <vikasrawal@gmail.com>
To: "Juan Manuel Macías" <maciaschain@posteo.net>
Cc: orgmode <emacs-orgmode@gnu.org>
Subject: Re: Support for tabularray in LaTeX export
Date: Thu, 2 Sep 2021 15:38:43 +0530	[thread overview]
Message-ID: <CALtzAB17d-ca3jS49Pk3vuW9EJFxv3hoc3tsFvJNZooCUvdy_A@mail.gmail.com> (raw)
In-Reply-To: <87ilzjgyqg.fsf@posteo.net>

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

This is perfect. Thank you, Juan Manuel.

Vikas

On Thu, 2 Sept 2021 at 14:06, Juan Manuel Macías <maciaschain@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
> >
>

[-- Attachment #2: Type: text/html, Size: 5197 bytes --]

  reply	other threads:[~2021-09-02 10:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-02  0:42 Support for tabularray in LaTeX export Vikas Rawal
2021-09-02  8:36 ` Juan Manuel Macías
2021-09-02 10:08   ` Vikas Rawal [this message]
2021-10-25 14:04     ` Vikas Rawal
2021-10-25 14:18       ` Juan Manuel Macías
2021-10-25 17:25         ` Thomas Dye

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CALtzAB17d-ca3jS49Pk3vuW9EJFxv3hoc3tsFvJNZooCUvdy_A@mail.gmail.com \
    --to=vikasrawal@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=maciaschain@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).