From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jon Degenhardt Subject: 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: Sat, 11 Jan 2014 13:18:29 -0800 (PST) Message-ID: <1389475109.23348.YahooMailNeo@web184706.mail.ne1.yahoo.com> Reply-To: Jon Degenhardt Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="814484595-1114081212-1389475109=:23348" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51532) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W25ze-0001XE-8k for emacs-orgmode@gnu.org; Sat, 11 Jan 2014 16:21:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W25zW-00051d-Rz for emacs-orgmode@gnu.org; Sat, 11 Jan 2014 16:21:22 -0500 Received: from nm31.bullet.mail.ne1.yahoo.com ([98.138.229.24]:45447) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W25zW-00051Z-GA for emacs-orgmode@gnu.org; Sat, 11 Jan 2014 16:21:14 -0500 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" --814484595-1114081212-1389475109=:23348 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Export to Latex (org-latex-export-to-pdf) generates incorrect latex when=0A= list items start with a left square bracket. This occurs because the=0A\ite= m command interprets the left square bracket as the start of an=0Aargument = list. An example:=0A=0A=A0=A0 An item list:=0A=A0=A0 - abc def=0A=A0=A0 - [= def] ghi=0A=A0=A0 - [jkl m n o]=0A=A0=A0 - pqr=0A=0AThis produces the latex= fragment:=0A=0A=A0=A0 An item list:=0A=A0=A0 \begin{itemize}=0A=A0=A0 \ite= m abc def=0A=A0=A0 \item [def] ghi=0A=A0=A0 \item [jkl m n o]=0A=A0=A0 \ite= m pqr=0A=A0=A0 \end{itemize}=0A=0AThe pdf output renders the second and thi= rd items incorrectly. If there=0Ais no right bracket to terminate the argum= ent, then pdf generation may=0Afail with message:=0A=A0 =0A=A0=A0 org-latex= -compile: PDF file ./example.pdf wasn't produced: Runaway argument=0A=0AI f= ixed these cases in my local environment using defadvise on org-latex-item= =0Ato wrap an initial left square bracket in braces. I used this form:=0A= =0A=A0=A0 (eval-after-load "ox-latex"=0A=A0=A0=A0=A0 '(progn=0A=A0=A0=A0=A0= =A0=A0=A0 (defadvice org-latex-item (after escape-initial-bracket activate)= =0A=A0=A0=A0=A0=A0=A0=A0=A0=A0 (setq ad-return-value=0A=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0 (replace-regexp-in-string =0A=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 "\\\\item \\[" =0A=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 "\\\\item {[}" =0A=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ad-return-value)))))=0A=0AThi= s changes the latex fragment for the above example to:=0A=0A=A0=A0 An item = list:=0A=A0=A0 \begin{itemize}=0A=A0=A0 \item abc def=0A=A0=A0 \item {[}def= ] ghi=0A=A0=A0 \item {[}jkl m n o]=0A=A0=A0 \item pqr=0A=A0=A0 \end{itemize= }=0A=0AThis form renders PDF correctly. My knowledge of latex is very limit= ed,=0AI don't know if this is a reasonable approach or not. There appears t= o=0Abe one other function in the ox-latex.el generating the \item command:= =0A(org-latex-headline). I did not try to reproduce this case.=0A=0A-------= -----------------------------------------------------------------=0A=0AEmac= s=A0 : GNU Emacs 24.2.1 (x86_64-apple-darwin, NS apple-appkit-1038.36)=0A= =A0of 2012-08-27 on bob.porkrind.org=0APackage: Org-mode version 8.2.3c (8.= 2.3c-elpa @ /Users/jdegenhardt/.emacs.d/elpa/org-20131115/)=0A=0Acurrent st= ate:=0A=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A(setq=0A=A0org-tab-firs= t-hook '(org-hide-block-toggle-maybe=0A=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0 org-src-native-tab-command-maybe=0A=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 org-babel-hide-result-t= oggle-maybe=0A=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0 org-babel-header-arg-expand)=0A=A0org-speed-command-hook '(org-speed-co= mmand-default-hook=0A=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0 org-babel-speed-command-hook)=0A=A0org-occur-hook '(o= rg-first-headline-recenter)=0A=A0org-metaup-hook '(org-babel-load-in-sessio= n-maybe)=0A=A0org-log-done 'time=0A=A0org-confirm-shell-link-function 'yes-= or-no-p=0A=A0org-use-sub-superscripts '{}=0A=A0org-startup-indented t=0A=A0= org-after-todo-state-change-hook '(org-clock-out-if-current)=0A=A0org-src-m= ode-hook '(org-src-babel-configure-edit-buffer=0A=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 org-src-mode-configure-edit-buffer)=0A= =A0org-agenda-before-write-hook '(org-agenda-add-entry-text)=0A=A0org-babel= -pre-tangle-hook '(save-buffer)=0A=A0org-mode-hook '(#[nil "\300\301\302\30= 3\304$\207"=0A=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 [org-a= dd-hook change-major-mode-hook org-show-block-all=0A=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 append local]=0A=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 5]=0A=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0 #[nil "\300\301\302\303\304$\207"=0A=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 [org-add-hook change-major-mode-hook=0A=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 org-babel-show-resul= t-all append local]=0A=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0 5]=0A=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 org-babel-result-= hide-spec org-babel-hide-all-hashes=0A=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0 (lambda nil (turn-on-visual-line-mode) (turn-off-auto-fill)))= =0A=A0org-ctrl-c-ctrl-c-hook '(org-babel-hash-at-point=0A=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 org-babel-execute= -safely-maybe)=0A=A0org-cycle-hook '(org-cycle-hide-archived-subtrees org-c= ycle-hide-drawers=0A=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 org= -cycle-hide-inline-tasks org-cycle-show-empty-lines=0A=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 org-optimize-window-after-visibility-change)= =0A=A0org-todo-keywords '((sequence "TODO" "STARTED" "ONHOLD" "|" "DONE" "C= ANCELED")=0A=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 )= =0A=A0org-latex-packages-alist '(("margin=3D0.75in" "geometry" nil))=0A=A0o= rg-confirm-elisp-link-function 'yes-or-no-p=0A=A0org-metadown-hook '(org-ba= bel-pop-to-session-maybe)=0A=A0org-agenda-files '("~/Notes/General-Ongoing.= org")=0A=A0org-clock-out-hook '(org-clock-remove-empty-clock-drawer)=0A=A0) --814484595-1114081212-1389475109=:23348 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable
Export to Latex (org-lat= ex-export-to-pdf) generates incorrect latex when
list items start with a= left square bracket. This occurs because the
\item command interprets t= he 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 p= roduces the latex fragment:

   An item list:
 &nbs= p; \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 ite= ms incorrectly. If there
is no right bracket to terminate the argument, then pdf generation may
fail with message:
 
&nbs= p;  org-latex-compile: PDF file ./example.pdf wasn't produced: Runaway= argument

I fixed these cases in my local environment using defadvis= e on org-latex-item
to wrap an initial left square bracket in braces. I = used this form:

   (eval-after-load "ox-latex"
 &n= bsp;   '(progn
        (def= advice org-latex-item (after escape-initial-bracket activate)
 &nbs= p;        (setq ad-return-value
 = ;            &n= bsp;  (replace-regexp-in-string
     &nbs= p;            &= nbsp; "\\\\item \\["
        &n= bsp;           "\\\\item {[}"
         &= nbsp;          ad-return-value= )))))

This changes the latex fragment for the above example to:
<= br>   An item list:
   \begin{itemize}
 &nbs= p; \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
b= e one other function in the ox-latex.el generating the \item command:
(o= rg-latex-headline). I did not try to reproduce this case.

----------= --------------------------------------------------------------

Emacs=   : GNU Emacs 24.2.1 (x86_64-apple-darwin, NS apple-appkit-1038.36) of 2012-08-27 on bob.porkrind.org
Package: Org-mode version 8.2.3c (8.2.3c-elpa @ /Users/jdegenhardt/.emacs.d/elpa/org-2013111= 5/)

current state:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
= (setq
 org-tab-first-hook '(org-hide-block-toggle-maybe
 &n= bsp;            = ;        org-src-native-tab-command-mayb= e
           &nbs= p;          org-babel-hide-res= ult-toggle-maybe
         &= nbsp;            org= -babel-header-arg-expand)
 org-speed-command-hook '(org-speed-comma= nd-default-hook
         &n= bsp;            = ;    org-babel-speed-command-hook)
 org-occur-hook '(org-first-headline-recenter)
 org-metaup-hook '(org-babel-load-i= n-session-maybe)
 org-log-done 'time
 org-confirm-shell-lin= k-function 'yes-or-no-p
 org-use-sub-superscripts '{}
 org-= startup-indented t
 org-after-todo-state-change-hook '(org-clock-ou= t-if-current)
 org-src-mode-hook '(org-src-babel-configure-edit-buf= fer
           &n= bsp;         org-src-mode-configure= -edit-buffer)
 org-agenda-before-write-hook '(org-agenda-add-entry-= text)
 org-babel-pre-tangle-hook '(save-buffer)
 org-mode-h= ook '(#[nil "\300\301\302\303\304$\207"
     &n= bsp;            = ; [org-add-hook change-major-mode-hook org-show-block-all
        &nbs= p;           append local= ]
           &nbs= p;       5]
     =             #[nil "\= 300\301\302\303\304$\207"
       &nbs= p;           [org-add-hoo= k change-major-mode-hook
        = ;            org-bab= el-show-result-all append local]
      &nb= sp;            5]            &n= bsp;    org-babel-result-hide-spec org-babel-hide-all-hashes
       &nb= sp;         (lambda nil (turn-on-vi= sual-line-mode) (turn-off-auto-fill)))
 org-ctrl-c-ctrl-c-hook '(or= g-babel-hash-at-point
        &n= bsp;            = ;     org-babel-execute-safely-maybe)
 org-cycl= e-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawers
 &= nbsp;           &nbs= p;    org-cycle-hide-inline-tasks org-cycle-show-empty-lines=
            = ;      org-optimize-window-after-visibility-change= )
 org-todo-keywords '((sequence "TODO" "STARTED" "ONHOLD" "|" "DON= E" "CANCELED")
          = ;           )
 or= g-latex-packages-alist '(("margin=3D0.75in" "geometry" nil))
 org-c= onfirm-elisp-link-function 'yes-or-no-p
 org-metadown-hook '(org-ba= bel-pop-to-session-maybe)
 org-agenda-files '("~/Notes/General-Ongo= ing.org")
 org-clock-out-hook '(org-clock-remove-empty-clock-drawer= )
 )
--814484595-1114081212-1389475109=:23348--