From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Orgtbl-mode in latex: escaped braces and dollars, and other arbitrary transformations Date: Thu, 26 Jun 2014 15:17:30 +0200 Message-ID: <871tuboln9.fsf@nicolasgoaziou.fr> References: <878uoknegl.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58754) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X09Xy-0007xO-9o for emacs-orgmode@gnu.org; Thu, 26 Jun 2014 09:17:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X09Xo-00088E-5j for emacs-orgmode@gnu.org; Thu, 26 Jun 2014 09:17:02 -0400 Received: from relay4-d.mail.gandi.net ([2001:4b98:c:538::196]:47565) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X09Xo-000885-0F for emacs-orgmode@gnu.org; Thu, 26 Jun 2014 09:16:52 -0400 In-Reply-To: (Thibaut Verron's message of "Thu, 26 Jun 2014 14:22:13 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: thibaut.verron@gmail.com Cc: emacs-orgmode Thibaut Verron 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). 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)))) Regards, -- Nicolas Goaziou