From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: [patch] latex export: org preprocesses code inside #+begin/end_latex block Date: Tue, 06 Oct 2009 18:02:45 -0600 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MvJzw-0005IU-Eu for emacs-orgmode@gnu.org; Tue, 06 Oct 2009 20:03:16 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MvJzs-0005Hu-S3 for emacs-orgmode@gnu.org; Tue, 06 Oct 2009 20:03:16 -0400 Received: from [199.232.76.173] (port=39307 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MvJzs-0005Hr-Lu for emacs-orgmode@gnu.org; Tue, 06 Oct 2009 20:03:12 -0400 Received: from mail-pz0-f181.google.com ([209.85.222.181]:33424) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MvJzr-0003j1-Ud for emacs-orgmode@gnu.org; Tue, 06 Oct 2009 20:03:12 -0400 Received: by pzk11 with SMTP id 11so2794373pzk.14 for ; Tue, 06 Oct 2009 17:03:10 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Org Mode --=-=-= Hi, I just wanted to share the following bug and potential patch. When code inside of a #+begin/end_latex block looks like a table, org-mode processes it as a table on latex export. For example given the following Org-mode --8<---------------cut here---------------start------------->8--- The following latex isn't exported correctly #+begin_latex \begin{code} data BTree = Leaf a | Node Tree Tree \end{code} #+end_latex --8<---------------cut here---------------end--------------->8--- org exports to the following LaTeX --8<---------------cut here---------------start------------->8--- The following latex isn't exported correctly \begin{code} data BTree = Leaf a \begin{center} \begin{tabular}{l} Node Tree Tree \\ \end{tabular} \end{center} \end{code} --8<---------------cut here---------------end--------------->8--- The attached patch [1] appears to fix this bug, however as I don't know the latex exporter that well there is the chance this could introduce many other problems. (Note that although the patch looks big, all it does is wrap part of org-export-latex-tables in an unless block) Thanks -- Eric Footnotes: [1] --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=protecting-tables.patch diff --git a/lisp/org-latex.el b/lisp/org-latex.el index c50f87e..8c50e4d 100644 --- a/lisp/org-latex.el +++ b/lisp/org-latex.el @@ -1336,114 +1336,115 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER." "Convert tables to LaTeX and INSERT it." (goto-char (point-min)) (while (re-search-forward "^\\([ \t]*\\)|" nil t) - (org-table-align) - (let* ((beg (org-table-begin)) - (end (org-table-end)) - (raw-table (buffer-substring beg end)) - (org-table-last-alignment (copy-sequence org-table-last-alignment)) - (org-table-last-column-widths (copy-sequence - org-table-last-column-widths)) - fnum fields line lines olines gr colgropen line-fmt align - caption label attr floatp longtblp) - (if org-export-latex-tables-verbatim - (let* ((tbl (concat "\\begin{verbatim}\n" raw-table - "\\end{verbatim}\n"))) - (apply 'delete-region (list beg end)) - (insert (org-export-latex-protect-string tbl))) - (progn - (setq caption (org-find-text-property-in-string - 'org-caption raw-table) - attr (org-find-text-property-in-string - 'org-attributes raw-table) - label (org-find-text-property-in-string - 'org-label raw-table) - longtblp (and attr (stringp attr) - (string-match "\\" attr)) - align (and attr (stringp attr) - (string-match "\\" attr)) + align (and attr (stringp attr) + (string-match "\\