From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Bug: Export to Latex - Incorrect output for list items starting with left bracket [8.2.3c (8.2.3c-elpa @ /Users/jdegenhardt/.emacs.d/elpa/org-20131115/)] Date: Mon, 13 Jan 2014 17:51:05 +0100 Message-ID: <87sisrkepy.fsf@gmail.com> References: <1389475109.23348.YahooMailNeo@web184706.mail.ne1.yahoo.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35206) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2kj2-0002VB-PD for emacs-orgmode@gnu.org; Mon, 13 Jan 2014 11:51:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W2kiu-0006tt-Bd for emacs-orgmode@gnu.org; Mon, 13 Jan 2014 11:50:56 -0500 Received: from mail-wg0-x234.google.com ([2a00:1450:400c:c00::234]:63846) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2kit-0006ta-SQ for emacs-orgmode@gnu.org; Mon, 13 Jan 2014 11:50:48 -0500 Received: by mail-wg0-f52.google.com with SMTP id b13so6627607wgh.19 for ; Mon, 13 Jan 2014 08:50:46 -0800 (PST) In-Reply-To: <1389475109.23348.YahooMailNeo@web184706.mail.ne1.yahoo.com> (Jon Degenhardt's message of "Sat, 11 Jan 2014 13:18:29 -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: Jon Degenhardt Cc: "emacs-orgmode@gnu.org" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello, Jon Degenhardt writes: > Export to Latex (org-latex-export-to-pdf) generates incorrect latex when > list items start with a left square bracket. This occurs because the > \item command interprets the left square bracket as the start of an > argument list. An example: > > =C2=A0=C2=A0 An item list: > =C2=A0=C2=A0 - abc def > =C2=A0=C2=A0 - [def] ghi > =C2=A0=C2=A0 - [jkl m n o] > =C2=A0=C2=A0 - pqr > > This produces the latex fragment: > > =C2=A0=C2=A0 An item list: > =C2=A0=C2=A0 \begin{itemize} > =C2=A0=C2=A0 \item abc def > =C2=A0=C2=A0 \item [def] ghi > =C2=A0=C2=A0 \item [jkl m n o] > =C2=A0=C2=A0 \item pqr > =C2=A0=C2=A0 \end{itemize} > > The pdf output renders the second and third items incorrectly. If there > is no right bracket to terminate the argument, then pdf generation may > fail with message: > =C2=A0=20 > =C2=A0=C2=A0 org-latex-compile: PDF file ./example.pdf wasn't produced: R= unaway > argument Thank you for the report. Would the following patch solves the problem? Regards, --=20 Nicolas Goaziou --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-ox-latex-Fix-items-starting-with-a-square-bracket.patch >From 64a5290bd6b7b8d29e9b77ecc3fe7c29619e37e0 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Mon, 13 Jan 2014 17:48:19 +0100 Subject: [PATCH] ox-latex: Fix items starting with a square bracket * lisp/ox-latex.el (org-latex-headline, org-latex-item): Fix items starting with a square bracket Thanks to Jon Degenhardt for reporting it. --- lisp/ox-latex.el | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 8294938..f695dfc 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -1374,7 +1374,12 @@ holding contextual information." (when (org-export-first-sibling-p headline info) (format "\\begin{%s}\n" (if numberedp 'enumerate 'itemize))) ;; Itemize headline - "\\item " full-text "\n" headline-label pre-blanks contents))) + "\\item " + (replace-regexp-in-string "\\`[ \t]*\\[" "{\\[}" full-text) + "\n" + headline-label + pre-blanks + contents))) ;; If headline is not the last sibling simply return ;; LOW-LEVEL-BODY. Otherwise, also close the list, before ;; any blank line. @@ -1565,7 +1570,12 @@ contextual information." (concat checkbox (org-export-data tag info))))))) (concat counter "\\item" (or tag (concat " " checkbox)) - (and contents (org-trim contents)) + (cond ((not contents) nil) + ((or tag + checkbox + (not (string-match "\\`[ \t]*\\[" contents))) + (org-trim contents)) + (t (replace-match "{[}" nil nil contents))) ;; If there are footnotes references in tag, be sure to ;; add their definition at the end of the item. This ;; workaround is necessary since "\footnote{}" command is -- 1.8.5.2 --=-=-=--