emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Vladimir Lomov <lomov.vl@gmail.com>
To: Jon Degenhardt <jondegenhardt@yahoo.com>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
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	[thread overview]
Message-ID: <20140113002634.GA912@smoon> (raw)
In-Reply-To: <1389475109.23348.YahooMailNeo@web184706.mail.ne1.yahoo.com>

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

  reply	other threads:[~2014-01-13  0:26 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-11 21:18 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/)] Jon Degenhardt
2014-01-13  0:26 ` Vladimir Lomov [this message]
2014-01-13 16:51 ` Nicolas Goaziou
2014-01-13 23:56   ` Vladimir Lomov
2014-01-14 16:39   ` Eric S Fraga
2014-01-14 18:42     ` Nicolas Goaziou
2014-01-14 19:54       ` Eric S Fraga
2014-01-14 20:52         ` Nicolas Goaziou
2014-01-15  8:35           ` Eric S Fraga
2014-01-15 13:18             ` Nicolas Goaziou
2014-01-16  9:55               ` Eric S Fraga
2014-01-16 12:03                 ` Sebastien Vauban
2014-01-16 15:10                   ` Eric S Fraga
2014-01-16 15:15                     ` Nicolas Goaziou
     [not found]                       ` <87ha94vtyj.fsf-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-01-16 15:24                         ` Sebastien Vauban
2014-01-16 16:42                           ` Eric S Fraga
2014-08-03  7:57                             ` Nicolas Goaziou
2014-01-16 14:54                 ` Nicolas Goaziou
2014-01-18 20:06                   ` Jon Degenhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140113002634.GA912@smoon \
    --to=lomov.vl@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=jondegenhardt@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).