emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Thibaut Verron <thibaut.verron@gmail.com>
To: Thibaut Verron <thibaut.verron@gmail.com>,
	emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: Orgtbl-mode in latex: escaped braces and dollars, and other arbitrary transformations
Date: Thu, 26 Jun 2014 15:53:55 +0200	[thread overview]
Message-ID: <CAFsi02RoqQWq91JkvK8oCMxV31VZB6rn9_JMDiH3XxpOW10T6Q@mail.gmail.com> (raw)
In-Reply-To: <871tuboln9.fsf@nicolasgoaziou.fr>

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

2014-06-26 15:17 GMT+02:00 Nicolas Goaziou <mail@nicolasgoaziou.fr>:

> Thibaut Verron <thibaut.verron@gmail.com> writes:
>
> >> Now, are these "limitations of Org" really preventing it from exporting
> a
> >> string verbatim? That would seem like the most logical default in this
> >> situation, wouldn't it?
>
> I disagree in the general case. The most logical default for Org is to
> treat contents as plain text and ensure that the export conforms to what
> appears in the buffer. As a bonus, it can leave LaTeX code as-is when it
> recognizes some, which depends on Org's understanding of LaTeX syntax
> (hence the limitations I'm talking about).
>

Of course, I did not mean it for org-mode buffers! ;)


>
> Now, in the context of a LaTeX buffer using orgtbl minor mode, it could
> make sense in some situations to treat cell contents verbatim. I don't
> think it should be the default, but there could be an option for that.
> Anyway, there's a solution, see below.
>
> > Apparently not, the following quick attempt seems to be doing the job
> fine
> > enough:
> >
> >   (defun tv/orgtbl-to-latex-verbatim (table params)
> >     (flet ((org-export-string-as
> >             (string backend &optional b e)
> >             string))
> >      (orgtbl-to-latex table params)))
> >
> > However, it is extra dirty, and ignoring so many parameters in a function
> > is probably not safe. :-)
>
> I think defining your own translator function is the way to go. For
> example, the following (untested) could work:
>
>   (defun my-orgtbl-to-latex-verbatim (table params)
>     (let* ((alignment (mapconcat (lambda (x) (if x "r" "l"))
>                                org-table-last-alignment ""))
>          (params2
>           (list
>            :tstart (concat "\\begin{tabular}{" alignment "}")
>            :tend "\\end{tabular}"
>            :lstart "" :lend " \\\\" :sep " & "
>            :efmt "%s\\,(%s)" :hline "\\hline")))
>       (orgtbl-to-generic table (org-combine-plists params2 params))))
>
>
Indeed it does work.

But, unless I am mistaken, this is exactly the definition given here:
http://orgmode.org/manual/Translator-functions.html#Translator-functions
and so I was not wrong, this used to work as I expected.

I suspect that this change (regression?) will cause problems to a lot of
other users when they will upgrade their org to the current version.

Would changing the last lines of `orgtbl-to-latex` to something like this
work as a long-term solution?

    (require 'ox-latex)
    (let* ((*orgtbl-verbatim* (plist-get params :verbatim))
           (backend (if *orgtbl-verbatim* nil 'latex)))
      (orgtbl-to-generic table (org-combine-plists params2 params)
backend))))

Thanks for your time,

Thibaut verron

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

  reply	other threads:[~2014-06-26 13:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-26  9:55 Orgtbl-mode in latex: escaped braces and dollars, and other arbitrary transformations Thibaut Verron
2014-06-26 10:38 ` Nicolas Goaziou
2014-06-26 11:57   ` Thibaut Verron
2014-06-26 12:22     ` Thibaut Verron
2014-06-26 13:17       ` Nicolas Goaziou
2014-06-26 13:53         ` Thibaut Verron [this message]
2014-06-26 19:07           ` 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=CAFsi02RoqQWq91JkvK8oCMxV31VZB6rn9_JMDiH3XxpOW10T6Q@mail.gmail.com \
    --to=thibaut.verron@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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).