From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lawrence Mitchell Subject: [PATCH] Allow mixed export of numbered and unnumbered sections in LaTeX Date: Tue, 22 Mar 2011 14:26:14 +0000 Message-ID: References: <20110322051038.21655c80@kuru.homelinux.net> <80d3lj9wj6.fsf@somewhere.org> <20110322053134.669127e9@kuru.homelinux.net> <80fwqf5n6g.fsf@somewhere.org> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from [140.186.70.92] (port=43744 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q22fJ-0002lA-HG for emacs-orgmode@gnu.org; Tue, 22 Mar 2011 10:34:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q22fI-0003Kz-FS for emacs-orgmode@gnu.org; Tue, 22 Mar 2011 10:34:33 -0400 Received: from lo.gmane.org ([80.91.229.12]:60961) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q22fH-0003Kl-Ox for emacs-orgmode@gnu.org; Tue, 22 Mar 2011 10:34:32 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1Q22f8-0000NW-MN for emacs-orgmode@gnu.org; Tue, 22 Mar 2011 15:34:22 +0100 Received: from e4300lm.epcc.ed.ac.uk ([129.215.63.156]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 22 Mar 2011 15:34:22 +0100 Received: from wence by e4300lm.epcc.ed.ac.uk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 22 Mar 2011 15:34:22 +0100 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: emacs-orgmode@gnu.org * lisp/org-latex.el (org-export-latex-subcontent): Deal specially with the case that NUM is an integer. We would sometimes like to have numbered \sections in LaTeX export but unnumbered \subsections and so forth. That is, use the starred equivalents for all sectioning commands below a certain level. Previously, the num: option specification could only specify whether sections should be numbered or unnumbered at all levels. We now treat an integer value specially, if num:N is supplied then the highest N levels are numbered, and lower levels are exported without numbering. --- lisp/org-latex.el | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) [...] Wouldn't it be nice if #+OPTIONS: num:2 exported \section{foo} \subsection{bar} \subsubsection*{baz} It turns out the patch is relatively straightforward. I haven't included a doc update, but could do so if required. diff --git a/lisp/org-latex.el b/lisp/org-latex.el index fbdeb5e..7a3c629 100644 --- a/lisp/org-latex.el +++ b/lisp/org-latex.el @@ -1151,7 +1151,9 @@ and its content." (defun org-export-latex-subcontent (subcontent num) "Export each cell of SUBCONTENT to LaTeX. -If NUM, export sections as numerical sections." +If NUM is non-nil export numbered sections, otherwise use unnumbered +sections. If NUM is an integer, export the highest NUM levels as +numbered sections and lower levels as unnumbered sections." (let* ((heading (cdr (assoc 'heading subcontent))) (level (- (cdr (assoc 'level subcontent)) org-export-latex-add-level)) @@ -1187,6 +1189,9 @@ If NUM, export sections as numerical sections." ;; Normal conversion ((<= level depth) (let* ((sec (nth (1- level) sectioning)) + (num (if (integerp num) + (>= num level) + num)) start end) (if (consp (cdr sec)) (setq start (nth (if num 0 2) sec) -- 1.7.4.rc2.18.gb20e9