From mboxrd@z Thu Jan 1 00:00:00 1970 From: mcg Subject: Help with fixing an org-mode multicolumn implementation - LaTeX special characters Date: Sun, 21 Feb 2016 11:28:45 +0100 Message-ID: <56C9915D.7080408@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35966) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXRFz-00085s-S7 for emacs-orgmode@gnu.org; Sun, 21 Feb 2016 05:28:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aXRFw-0001Kh-LB for emacs-orgmode@gnu.org; Sun, 21 Feb 2016 05:28:51 -0500 Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]:35427) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXRFw-0001KU-Dl for emacs-orgmode@gnu.org; Sun, 21 Feb 2016 05:28:48 -0500 Received: by mail-wm0-x22b.google.com with SMTP id c200so132569111wme.0 for ; Sun, 21 Feb 2016 02:28:47 -0800 (PST) Received: from [192.168.1.106] ([84.78.15.10]) by smtp.googlemail.com with ESMTPSA id w62sm15827070wmg.21.2016.02.21.02.28.46 for (version=TLSv1/SSLv3 cipher=OTHER); Sun, 21 Feb 2016 02:28:46 -0800 (PST) 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: emacs-orgmode@gnu.org I found a very nice implementation of LaTeX multicolumn functionality in this thread: https://lists.gnu.org/archive/html/emacs-orgmode/2013-02/msg00736.html ("using export filters to emulate multi-column table cells?") #+begin_src emacs-lisp :exports none (defun my-latex-multicolumn-filter (row backend info) (when (org-export-derived-backend-p backend 'latex) (while (string-match "\\(<\\([0-9]+\\)col\\([lrc]\\)?>[[:blank:]]*\\([^&]+\\)\\)" row) (let ((columns (string-to-number (match-string 2 row))) (start (match-end 0)) (contents (replace-regexp-in-string "[[:blank:]]*$" "" (match-string 4 row))) (algn (or (match-string 3 row) "l"))) (setq row (replace-match (format "\\\\multicolumn{%d}{%s}{%s}" columns algn contents) nil nil row 1)) (while (and (> columns 1) (string-match "&" row start)) (setq row (replace-match "" nil nil row)) (decf columns)))) row)) (add-to-list 'org-export-filter-table-row-functions 'my-latex-multicolumn-filter) #+end_src #+LATEX_HEADER: \usepackage{multirow} You have to put the number of columns to span and a r / l / c option for column alignment (<2colc>) and the column contents afterwards. Nice! #+CAPTION: Example table | Characters not working | <2colc> Characters working: ! " ยง . , * + ? % | | |-------------------------------+-----------------------------------------------+------------------| | ^ % _ { } $ | The header above is merged | over two columns | | /italics/ *bold* _underline_ | | | | any, \LaTeX special character | | | | or expression requiring \ | | | However, using any of the characters of the left column of my example table in the merged <2colc> column, I get: "setq: Invalid use of `\' in replacement text" Questions: - How to escape the special characters in the left column properly to be able to use them? (tried everything I could think of) or - How to modify the code above so that it allows for such characters. - If anyone likes the implementation and is more capable than I am, then the same for multirow would be really nice... Comment: whoever read some of my questions recently will notice that I excessively use org-mode as a LaTeX frontend. I am aware that this is not what it is supposed to be in the first place - but it works so perfect 99 % of the time, so I cannot keep from asking...