all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Exporting tables with cell borders to Latex/PDF
@ 2024-10-18 21:31 jman
  2024-10-18 23:37 ` Mark Barton
  0 siblings, 1 reply; 4+ messages in thread
From: jman @ 2024-10-18 21:31 UTC (permalink / raw)
  To: Emacs Orgmode


Hello,

When export to Latex/PDF I'd like /all/ table cells to have borders, so also vertical column
separators.
After looking around a bit, I learned about column groups:
https://orgmode.org/manual/Column-Groups.html

I think the only way to accomplish what I want is the following trick, adding a "cosmetic" column
just to be able to have a border at the beginning of the table:

|---+---+-----+-----+-----+---------+------------|
|   | N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
|---+---+-----+-----+-----+---------+------------|
| / | < |   < |   < |   < |       < |         <> |
|   | 1 |   1 |   1 |   1 |       1 |          1 |
|   | 2 |   4 |   8 |  16 |  1.4142 |     1.1892 |
|   | 3 |   9 |  27 |  81 |  1.7321 |     1.3161 |
|---+---+-----+-----+-----+---------+------------|
#+TBLFM: $2=$1^2::$3=$1^3::$4=$1^4::$5=sqrt($1)::$6=sqrt(sqrt(($1)))

Am I missing a better solution?

Thanks



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

* Re: Exporting tables with cell borders to Latex/PDF
  2024-10-18 21:31 Exporting tables with cell borders to Latex/PDF jman
@ 2024-10-18 23:37 ` Mark Barton
  2024-10-19 12:25   ` jman
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Barton @ 2024-10-18 23:37 UTC (permalink / raw)
  To: jman; +Cc: Org Mode List

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



> On Oct 18, 2024, at 2:31 PM, jman <emacs-orgmode@city17.xyz> wrote:
> 
> 
> Hello,
> 
> When export to Latex/PDF I'd like /all/ table cells to have borders, so also vertical column
> separators.
> After looking around a bit, I learned about column groups:
> https://orgmode.org/manual/Column-Groups.html
> 
> I think the only way to accomplish what I want is the following trick, adding a "cosmetic" column
> just to be able to have a border at the beginning of the table:
> 
> |---+---+-----+-----+-----+---------+------------|
> |   | N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
> |---+---+-----+-----+-----+---------+------------|
> | / | < |   < |   < |   < |       < |         <> |
> |   | 1 |   1 |   1 |   1 |       1 |          1 |
> |   | 2 |   4 |   8 |  16 |  1.4142 |     1.1892 |
> |   | 3 |   9 |  27 |  81 |  1.7321 |     1.3161 |
> |---+---+-----+-----+-----+---------+------------|
> #+TBLFM: $2=$1^2::$3=$1^3::$4=$1^4::$5=sqrt($1)::$6=sqrt(sqrt(($1)))
> 
> Am I missing a better solution?
> 
> Thanks
> 
> 

Here is an example of using the #+ATTR_LaTeX: line to pass parameters to the LaTeX process that creates the pdf.

#+ATTR_LaTeX: :environment tabular :align |l|l|l|
|-----+-----+-------|
| one | two | three |
|-----+-----+-------|
|   1 |   2 |     3 |
|-----+-----+-------|

Mark

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

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

* Re: Exporting tables with cell borders to Latex/PDF
  2024-10-18 23:37 ` Mark Barton
@ 2024-10-19 12:25   ` jman
  2024-10-21  9:13     ` Rens Oliemans
  0 siblings, 1 reply; 4+ messages in thread
From: jman @ 2024-10-19 12:25 UTC (permalink / raw)
  To: Mark Barton; +Cc: Org Mode List

Mark Barton <mbarton98@gmail.com> writes:

> Here is an example of using the #+ATTR_LaTeX: line to pass parameters to the LaTeX process that 
> creates the pdf.
>
> #+ATTR_LaTeX: :environment tabular :align |l|l|l|
> |-----+-----+-------|
> | one | two | three |
> |-----+-----+-------|
> |   1 |   2 |     3 |
> |-----+-----+-------|

Oh thank you for the tip! Now I've found a mention in the documentation:
https://orgmode.org/manual/Tables-in-LaTeX-export.html

I'll try unpacking the solution for clarity: `l` means align to the left, the pipe (`|`) means add a 
vertical separator.
Here a bit more documentation about the tabular package:
https://www.overleaf.com/learn/latex/Tables

Note: I think it also works without setting `:environment tabular`, why?

Cheers,


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

* Re: Exporting tables with cell borders to Latex/PDF
  2024-10-19 12:25   ` jman
@ 2024-10-21  9:13     ` Rens Oliemans
  0 siblings, 0 replies; 4+ messages in thread
From: Rens Oliemans @ 2024-10-21  9:13 UTC (permalink / raw)
  To: jman, Mark Barton; +Cc: Org Mode List

jman <emacs-orgmode@city17.xyz> writes:

> Note: I think it also works without setting `:environment tabular`, why?

The `:environment` attribute sets the LaTeX table environment, in this case tabular. If
you omit it, it uses `org-latex-default-table-enviroment', which defaults to "tabular", so
that wouldn't make a difference in this case.

Check out section "13.10.5 Tables in LaTeX export" of the Org manual:

    (info "(org) Tables in LaTeX export")

    ‘:environment’
         Set the default LaTeX table environment for the LaTeX export
         backend to use when exporting Org tables.  Common LaTeX table
         environments are provided by these packages: tabularx, longtable,
         array, tabu, and bmatrix.  [...]

For example, try this out:

#+ATTR_LATEX: :environment longtable :align |l|l|l|
|-----+-----+-------|
| one | two | three |
|-----+-----+-------|
|   1 |   2 |     3 |
|-----+-----+-------|


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

end of thread, other threads:[~2024-10-21  9:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-18 21:31 Exporting tables with cell borders to Latex/PDF jman
2024-10-18 23:37 ` Mark Barton
2024-10-19 12:25   ` jman
2024-10-21  9:13     ` Rens Oliemans

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.