From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Eglen Subject: Re: Bug: possible bug in latex export [7.01trans (release_6.36.735.g15ca.dirty)] Date: Tue, 27 Jul 2010 16:04:42 +0100 Message-ID: <22496.1280243082@maps> References: <14025.1279898870@maps> <87fwz77fw8.wl%dmaus@ictsoc.de> Return-path: Received: from [140.186.70.92] (port=33270 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Odli2-0002Rd-Ib for emacs-orgmode@gnu.org; Tue, 27 Jul 2010 11:04:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Odli1-0001Bs-0X for emacs-orgmode@gnu.org; Tue, 27 Jul 2010 11:04:46 -0400 Received: from ppsw-31.csi.cam.ac.uk ([131.111.8.131]:41705) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Odli0-0001BM-Po for emacs-orgmode@gnu.org; Tue, 27 Jul 2010 11:04:44 -0400 In-reply-to: <87fwz77fw8.wl%dmaus@ictsoc.de> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: David Maus Cc: emacs-orgmode@gnu.org, Stephen Eglen > FYI: This is a know limitation of the LaTeX exporter[1] and the > current state of this issue (dealing with skipped levels) is that > patches for the problem are welcome. I agree that even if > skipped-level-headlines are not allowed, they shouldn't be silently > droped neither. > > Best, > -- David > > [1] http://thread.gmane.org/gmane.emacs.orgmode/26413 I think I have a patch for this, see below. I've tested it briefly to see that it works with both oddeven and odd level headings, but I would appreciate other people taking a closer look/checking that it doesn't break other things. I think I found the problem, in that if you have a structure like * A *** B (i.e. a level one and a level 3) after it has found the level 1 content, it expects to find a level 2 subtree, whereas in fact there could be a level 2+ tree. See the comment in the code for the change I made. Stephen diff --git a/lisp/org-latex.el b/lisp/org-latex.el index 24dd8c1..8530723 100644 --- a/lisp/org-latex.el +++ b/lisp/org-latex.el @@ -937,13 +937,28 @@ Return a list reflecting the document structure." (defun org-export-latex-parse-subcontent (level odd) "Extract the subcontent of a section at LEVEL. If ODD Is non-nil, assume subcontent only contains odd sections." - (if (not (org-re-search-forward-unprotected - (concat "^\\(\\(?:\\*\\)\\{" - (number-to-string (+ (if odd 4 2) level)) - "\\}\\) \\(.*\\)$") - nil t)) - nil ; subcontent is nil - (org-export-latex-parse-global (+ (if odd 2 1) level) odd))) + + (let (nstars new-level) + ;; In the search, we should not assume there will be exactly + ;; LEVEL+1 stars in the next heading, as there may be more than + ;; that number of stars. hence the regexp should be \\*{N,} + ;; rather than just \\*{N} (i.e. no upper bound, but N is minimum + ;; number of stars to expect.) + ;; We then have to check how many stars were found, rather than + ;; assuming there were exactly N. + (when (org-re-search-forward-unprotected + (concat "^\\(\\(?:\\*\\)\\{" + (number-to-string (+ (if odd 4 2) level)) + ",\\}\\) \\(.*\\)$") + nil t) + (setq nstars (1- (- (match-end 1) (match-beginning 1)))) + (setq new-level (if odd + (/ (+ 3 nstars) 2);; not entirely sure why +3! + nstars))) + (if nstars + (org-export-latex-parse-global new-level odd) + nil) ; subcontent is nil + )) ;;; Rendering functions: (defun org-export-latex-global (content)