From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vladimir Lomov 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 09:26:34 +0900 Message-ID: <20140113002634.GA912@smoon> References: <1389475109.23348.YahooMailNeo@web184706.mail.ne1.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55298) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2VMf-000705-44 for emacs-orgmode@gnu.org; Sun, 12 Jan 2014 19:26:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W2VMW-0002B4-LK for emacs-orgmode@gnu.org; Sun, 12 Jan 2014 19:26:49 -0500 Received: from mail-lb0-x230.google.com ([2a00:1450:4010:c04::230]:44091) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2VMW-0002Ay-DG for emacs-orgmode@gnu.org; Sun, 12 Jan 2014 19:26:40 -0500 Received: by mail-lb0-f176.google.com with SMTP id l4so4760937lbv.21 for ; Sun, 12 Jan 2014 16:26:38 -0800 (PST) Content-Disposition: inline In-Reply-To: <1389475109.23348.YahooMailNeo@web184706.mail.ne1.yahoo.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: Jon Degenhardt Cc: "emacs-orgmode@gnu.org" Hello, ** Jon Degenhardt [2014-01-11 13:18:29 -0800]: > 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: >    An item list: >    - abc def >    - [def] ghi >    - [jkl m n o] >    - pqr > This produces the latex fragment: >    An item list: >    \begin{itemize} >    \item abc def >    \item [def] ghi >    \item [jkl m n o] >    \item pqr >    \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: >   >    org-latex-compile: PDF file ./example.pdf wasn't produced: Runaway argument This is (mis-)feature of LaTeX itemize and enumerate environments. The most simple way to "correct" output is to put '\relax' right after '\item' or output for these environments '\item[]' instead of solely '\item'. > I fixed these cases in my local environment using defadvise on org-latex-item > to wrap an initial left square bracket in braces. I used this form: >    (eval-after-load "ox-latex" >      '(progn >         (defadvice org-latex-item (after escape-initial-bracket activate) >           (setq ad-return-value >                 (replace-regexp-in-string >                     "\\\\item \\[" >                     "\\\\item {[}" >                     ad-return-value))))) > This changes the latex fragment for the above example to: >    An item list: >    \begin{itemize} >    \item abc def >    \item {[}def] ghi >    \item {[}jkl m n o] >    \item pqr >    \end{itemize} > This form renders PDF correctly. My knowledge of latex is very limited, > I don't know if this is a reasonable approach or not. There appears to > be one other function in the ox-latex.el generating the \item command: > (org-latex-headline). I did not try to reproduce this case. [...] FWIW, itemize and enumerate environments are built on top of \list command, as well as 'description' environment. But only last environment uses 'optional' arguments for '\item', the first two shouldn't have such option. Unfortunately, there is only one '\item' command, that is used in all three environments. It is impossible to redefine "kernel" environments itemize and enumerate to work properly with '[]' after item, but some LaTeX packages could 'patch' standard environments to 'fix' the issue, for example, 'enumitem' package. --- WBR, Vladimir Lomov -- In an age when the fashion is to be in love with yourself, confessing to be in love with somebody else is an admission of unfaithfulness to one's beloved. -- Russell Baker