From mboxrd@z Thu Jan 1 00:00:00 1970 From: azw@eml.cc (Albert Z. Wang) Subject: Re: [PATCH] Export: Override headline numbering via properties Date: Thu, 16 May 2013 23:19:49 -0400 Message-ID: <87wqqywawa.fsf@gmail.com> References: <87ppwvtnbw.fsf@gmail.com> <87hai7taj7.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([208.118.235.92]:51749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UdBWX-0007bz-Jr for emacs-orgmode@gnu.org; Thu, 16 May 2013 23:40:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UdBWW-00035s-CE for emacs-orgmode@gnu.org; Thu, 16 May 2013 23:40:05 -0400 Received: from plane.gmane.org ([80.91.229.3]:50889) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UdBWW-00031y-5W for emacs-orgmode@gnu.org; Thu, 16 May 2013 23:40:04 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UdBWU-0005dP-V0 for emacs-orgmode@gnu.org; Fri, 17 May 2013 05:40:02 +0200 Received: from c-66-30-119-71.hsd1.ma.comcast.net ([66.30.119.71]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 17 May 2013 05:40:02 +0200 Received: from azw by c-66-30-119-71.hsd1.ma.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 17 May 2013 05:40:02 +0200 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 Mark Edgington writes: >> Anyway, your patch will not work on back-ends that rely on Org to >> compute section numbers (e.g., ascii, html...) because even if you >> ignore numbering for a particular headline, it still adds up >> internally. IOW, you also need to patch >> `org-export--collect-headline-numbering'. >> >> But that's not quite it, yet. Some back-ends (e.g., html) use that >> internal number as a unique identifier for the headline. Actually, >> the "artificial restriction" you are talking about is a way to >> allow every headline to be numbered in a unique way, even if that >> number doesn't appear in the output. > > I can see what you mean here -- but it doesn't exactly "break" > anything -- it just makes the section-numbering within html, etc. > documents to be non-consecutive *if these properties are used*. If > the main intent is to use these properties in conjunction with the > LaTeX exporter, then this isn't a big problem (i.e. those who want > to use them will just need to understand that they currently only > work "correctly" with LaTeX, but that this will be fixed in the > future). > >> Since I wouldn't use this, I can hardly judge, but I would >> appreciate some feedback from other users before we go too far in >> the implementation. > > Agreed, but my (obviously biased) opinion is that it makes manual > numbering-control more "natural" within org-mode, and something > which doesn't require as much hacking with embedded LaTeX (or HTML, > etc.) code. An alternative would be to stick this into ox-latex.el, which then wouldn't interfere with other backends. I also think this functionality is good to have, since longer latex documents often have unnumbered sections (and there seem to be periodic questions on various boards on how to achieve this). While one can mess around with the latex code, it's often a hassle when the "master" document is in org and you need to recompile often. For a recent project I needed a super-simple way to turn off numbering (for intro and references), so based on the above I made the following tiny modification to ox-latex.el, which looks up the "LATEX_NUMBERED" property to decide whether to insert a numbered or unnumbered heading. Since I didn't need it, inheritance isn't in here, but it should be simple enough to add. Since this wouldn't interfere with any other backends, perhaps there will be fewer reservations about merging something like this into the repo? -- diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 41cf1d0..33a39c7 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -1369,7 +1369,11 @@ holding contextual information." (unless (org-element-property :footnote-section-p headline) (let* ((class (plist-get info :latex-class)) (level (org-export-get-relative-level headline info)) - (numberedp (org-export-numbered-headline-p headline info)) + (latex-numbered (org-export-get-node-property :LATEX_NUMBERED headline)) + (numberedp + (cond ((equal latex-numbered "n") nil) + ((equal latex-numbered "y") t) + (t (org-export-numbered-headline-p headline info)))) (class-sectionning (assoc class org-latex-classes)) ;; Section formatting will set two placeholders: one for ;; the title and the other for the contents. --