emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Rasmus <rasmus@gmx.us>
To: n.goaziou@gmail.com
Cc: emacs-orgmode@gnu.org
Subject: Re: Export tables as matrices (change tbl-export function on the fly)
Date: Sun, 18 Nov 2012 12:50:02 +0100	[thread overview]
Message-ID: <87ehjr6sgl.fsf@pank.eu> (raw)
In-Reply-To: <87fw48lyoj.fsf@gmail.com> (Nicolas Goaziou's message of "Sun, 18 Nov 2012 09:53:22 +0100")


Nicolas,

Thanks for your reply.


> I meant: what is the exact problem with my code (with examples and
> expected output if possible)? It shouldn't be hard to fix.

They are not caught by the regexp.  And I wasn't able to find a regexp
which could correctly identify all cases.  I have a sample in the footnote ¹ 

> Forget the lisp translation function. At this level, the function
> operates on parsed data. It doesn't use any orgtbl-to-* function. Also,
> even if the ATTR_LATEX keyword applies on the table, it also affects how
> `table-row' elements and `table-cell' objects are transcoded.

OK, thanks for pointing out.

> I suggest to use a :math-mode t. With this mode, all cells are
> treated as raw math code (no transformation is made on any cell).

Sounds good to me.  However, should $'s be stripped?  Say I have an
org-table which I'm indecisive about.  In one sell I might have a
\frac{·}{·} in a cell; so in a normal table export I'd have to insert
$'s, but in :math-mode I wouldn't.  It could thus be expensive to go
from :math mode to nil math mode.  Hence, stripping $ might be
appropriate

> A global variable can also set it `org-export-latex-table-math-mode'
> (default to nil).

Nil by default for sure.


> Then, the :environment keyword can be set to "tabular", "longtable",
> "tabularx", "tabulary", "bmatrix", "pmatrix", "vmatrix", "kbordermatrix"
> or "qbordermatrix". "bordermatrix", "array"... It would default to
> `org-e-latex-default-table-environment' (default to "tabular").

and Bmatrix ({matrix}) and Vmatrix ( ||matrix||) and matrix (no
decoration).

Array needs per column configuration. 

> What is the variable ALIGN? You mean :align keyword? Do matrix
> environments accept alignment? Also I haven't heard about starred
> version of these. What do they do?

They allow you to align a matrix to [rlc] (and maybe others?)  They
are defined in mathtools.

Here's an example (unrelated to tables):

#+BEGIN_SRC latex
\documentclass{article}
\usepackage{amsmath,mathtools}
\begin{document}
$\max_{x}f(x)\quad\text{s.t. }\left\{\begin{matrix*}[r]g(x)\geq0\\h(x)+h(y)\geq
    k\end{matrix*}\right.$
\end{document}
#+END_SRC


> From the syntax perspective, I see no difference between bordered
> matrices and the others: they just use a different environment, which
> can be provided through :environment keyword. Am I missing something?

No.  But they are typically macros.  Note the use of cr which
sometimes needs to be used in the bordermatrix (from TeX).  It's not
the case in kbordermatrix (which I use) and presumably qbordermatrix.

#+BEGIN_SRC latex
\documentclass{article}
\begin{document}
$\bordermatrix{&a&b&c\cr a&1&0&0\cr b&0&1&0\cr c&0&0&1}$
\end{document}
#+END_SRC


> The backend never adds any usepackage automatically. It is a can of
> worms (incompatibilities, order of packages...). It's the responsibility
> of the user to do so.

I agree.  

>>      - Potentially: an :inline exists s.t. if inline is t the
>>        matrix is typeset inline [i.e. with \(\)].  Perhaps, it
>>        should be smart and use the small verison of
>>        org-export-latex-tables-matrix-default-type.  I.e. if
>>        bmatrix use bsmallmatrix.  This could be set via
>>        org-export-latex-tables-matrix-inline-small.
>
> Do all matrix environments accept a small counterpart?

 amsmath provides: 
    smallmatrix from which all variants be generated using
    appropriated \left "bracket" \right "bracket"
 mathtools provides:
     smallmatrix*
     psmallmatrix 
     psmallmatrix*
     bsmallmatrix 
     bsmallmatrix*
     Bsmallmatrix 
     Bsmallmatrix*
     vsmallmatrix 
     vsmallmatrix*
     Vsmallmatrix 
     Vsmallmatrix*
     smallmatrix*

so I think it covers all variants except "small bordermatrix" and
"small arrary".

Thanks,
Rasmus

Footnotes: 
 ¹   Adding the function function in the second post, the following
examples all translates to tables

#+BEGIN_SRC org
#+NAME: t1
| my table | with rows |
|----------+-----------|
| a        | 2         |
| 5        | 3         |


matrix

| 1 | 2 |
| 3 | 4 |

#+NAME:t2
| 1 | 2 |
| 3 | 4 |
#+END_SRC

and output (note in dirty Emacs [not -q])

#+BEGIN_SRC LaTeX
\begin{table}[htb]
\label{t1}
\begin{center}
\begin{tabular}{lr}
\toprule
my table & with rows\\
\midrule
a & 2\\
5 & 3\\
\bottomrule
\end{tabular}
\end{center}
\end{table}


matrix

\begin{center}
\begin{tabular}{rr}
\toprule
1 & 2\\
3 & 4\\
\bottomrule
\end{tabular}
\end{center}

\begin{table}[htb]
\label{t2}
\begin{center}
\begin{tabular}{rr}
\toprule
1 & 2\\
3 & 4\\
\bottomrule
\end{tabular}
\end{center}
\end{table}
#+END_SRC

-- 
A page of history is worth a volume of logic

  reply	other threads:[~2012-11-18 11:50 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-14 14:49 Export tables as matrices (change tbl-export function on the fly) Rasmus
2012-11-14 16:21 ` Nicolas Goaziou
2012-11-14 18:05   ` Rasmus
2012-11-17 13:26   ` Rasmus Pank Roulund
2012-11-17 15:32     ` Nicolas Goaziou
2012-11-17 18:29       ` Rasmus
2012-11-18  8:53         ` Nicolas Goaziou
2012-11-18 11:50           ` Rasmus [this message]
2012-11-18 13:20             ` Nicolas Goaziou
2012-11-18 14:05               ` Rasmus
2012-11-18 19:12                 ` Nicolas Goaziou

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=87ehjr6sgl.fsf@pank.eu \
    --to=rasmus@gmx.us \
    --cc=emacs-orgmode@gnu.org \
    --cc=n.goaziou@gmail.com \
    /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).