From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aaron Ecay Subject: Re: Help with fixing an org-mode multicolumn implementation - LaTeX special characters Date: Mon, 22 Feb 2016 15:48:41 +0000 Message-ID: <87h9h0hhk6.fsf@gmail.com> References: <56C9915D.7080408@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37076) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXsj9-0004HB-CX for emacs-orgmode@gnu.org; Mon, 22 Feb 2016 10:48:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aXsj6-00079o-Mc for emacs-orgmode@gnu.org; Mon, 22 Feb 2016 10:48:47 -0500 Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]:33534) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXsj6-00079d-FG for emacs-orgmode@gnu.org; Mon, 22 Feb 2016 10:48:44 -0500 Received: by mail-wm0-x22c.google.com with SMTP id g62so162793274wme.0 for ; Mon, 22 Feb 2016 07:48:44 -0800 (PST) In-Reply-To: <56C9915D.7080408@gmail.com> 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: mcg , emacs-orgmode@gnu.org Hi mcg, 2016ko otsailak 21an, mcg-ek idatzi zuen: >=20 > I found a very nice implementation of LaTeX multicolumn functionality in= =20 > this thread: > https://lists.gnu.org/archive/html/emacs-orgmode/2013-02/msg00736.html [...] > However, using any of the characters of the left column of my example=20 > table in the merged <2colc> column, I get: > "setq: Invalid use of `\' in replacement text" I think the function should be written (untested): (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-s= tring 4 row))) (algn (or (match-string 3 row) "l"))) (setq row (replace-match (format "\\multicolumn{%d}{%s}{%s}" columns algn content= s) nil t row 1)) (while (and (> columns 1) (string-match "&" row start)) (setq row (replace-match "" nil nil row)) (decf columns)))) row)) The change is setting the third argument (=E2=80=98literal=E2=80=99) to =E2= =80=98replace-match=E2=80=99 to t, and deleting an extra backslash in the "\\multicolumn..." string. >=20 >=20 > Questions: > - How to escape the special characters in the left column properly to be= =20 > able to use them? (tried everything I could think of) > or > - How to modify the code above so that it allows for such characters. >=20 > - If anyone likes the implementation and is more capable than I am, then= =20 > the same for multirow would be really nice... Unfortunately I think that=E2=80=99s more complicated, since it would neces= sitate examining/modifying the whole table in one go, rather than operating one row at a time. --=20 Aaron Ecay