diff options
author | Nicolas Goaziou <n.goaziou@gmail.com> | 2012-01-27 14:49:32 +0100 |
---|---|---|
committer | Nicolas Goaziou <n.goaziou@gmail.com> | 2012-01-27 14:49:32 +0100 |
commit | d9970d1bd9c19c2b053cdf85c9dad1efb566b3fe (patch) | |
tree | 204b3d37036112b226095efef35a7d1f8c82a63f | |
parent | 4beec074d053052695c14fb3efa9e3a6f7eb729e (diff) | |
download | org-mode-d9970d1bd9c19c2b053cdf85c9dad1efb566b3fe.tar.gz |
Implement limited headine numbering for e-latex and e-ascii back-ends
* contrib/lisp/org-export.el (org-export-with-section-numbers): Modify
doc-string to document the changes.
* EXPERIMENTAL/org-e-ascii.el (org-e-ascii--build-title): Implement
limited headline numbering.
* EXPERIMENTAL/org-e-latex.el (org-e-latex-template): Implement
limited headline numbering.
-rw-r--r-- | EXPERIMENTAL/org-e-ascii.el | 25 | ||||
-rw-r--r-- | EXPERIMENTAL/org-e-latex.el | 24 | ||||
-rw-r--r-- | contrib/lisp/org-export.el | 3 |
3 files changed, 33 insertions, 19 deletions
diff --git a/EXPERIMENTAL/org-e-ascii.el b/EXPERIMENTAL/org-e-ascii.el index 47409d4..da9650f 100644 --- a/EXPERIMENTAL/org-e-ascii.el +++ b/EXPERIMENTAL/org-e-ascii.el @@ -563,13 +563,20 @@ specifications. if optional argument NOTAGS is nil, no tags will be added to the title." (let* ((headlinep (eq (car element) 'headline)) - ;; Numbering is specific to headlines. - (numbers (and headlinep (plist-get info :section-numbers) - (concat - (mapconcat - #'number-to-string - (org-export-get-headline-number element info) ".") - " "))) + (numbers + ;; Numbering is specific to headlines. + (and headlinep + ;; Section numbering must be active, and headline's + ;; level should be above specified limit, if any. + (let ((sec-num (plist-get info :section-numbers))) + (if (not (wholenump sec-num)) sec-num + (<= (org-export-get-relative-level headline info) sec-num))) + ;; All tests passed: build numbering string. + (concat + (mapconcat + #'number-to-string + (org-export-get-headline-number element info) ".") + " "))) (text (org-export-secondary-string (org-element-get-property :title element) 'e-ascii info)) (todo @@ -593,8 +600,8 @@ title." (format " %%%ds" (max (- text-width (1+ (length first-part))) (length tags))) tags)) - ;; Maybe underline text, if ELEMENT type is `headline' and - ;; a underline character has been defined. + ;; Maybe underline text, if ELEMENT type is `headline' and an + ;; underline character has been defined. (when (and underline headlinep) (let ((under-char (nth (1- (org-export-get-relative-level element info)) diff --git a/EXPERIMENTAL/org-e-latex.el b/EXPERIMENTAL/org-e-latex.el index 4ab4081..88849a6 100644 --- a/EXPERIMENTAL/org-e-latex.el +++ b/EXPERIMENTAL/org-e-latex.el @@ -803,7 +803,11 @@ holding export options." (plist-get info :latex-header-extra)))))) ;; 3. Define alert if not yet defined. "\\providecommand{\\alert}[1]{\\textbf{#1}}\n" - ;; 4. Author. + ;; 4. Possibly limit depth for headline numbering. + (let ((sec-num (plist-get info :section-numbers))) + (when (integerp sec-num) + (format "\\setcounter{secnumdepth}{%d}\n" sec-num))) + ;; 5. Author. (let ((author (and (plist-get info :with-author) (let ((auth (plist-get info :author))) (and auth (org-export-secondary-string @@ -815,12 +819,12 @@ holding export options." (format "\\author{%s\\thanks{%s}}\n" author email)) (author (format "\\author{%s}\n" author)) (t "\\author{}\n"))) - ;; 5. Date. + ;; 6. Date. (let ((date (plist-get info :date))) (and date (format "\\date{%s}\n" date))) - ;; 6. Title + ;; 7. Title (format "\\title{%s}\n" title) - ;; 7. Hyperref options. + ;; 8. Hyperref options. (format "\\hypersetup{\n pdfkeywords={%s},\n pdfsubject={%s},\n pdfcreator={%s}}\n" (or (plist-get info :keywords) "") (or (plist-get info :description) "") @@ -829,9 +833,9 @@ holding export options." ((not creator-info) "") ((eq creator-info 'comment) "") (t (plist-get info :creator))))) - ;; 7. Document start. + ;; 9. Document start. "\\begin{document}\n\n" - ;; 8. Title command. + ;; 10. Title command. (org-element-normalize-string (cond ((string= "" title) nil) ((not (stringp org-e-latex-title-command)) nil) @@ -839,22 +843,22 @@ holding export options." org-e-latex-title-command) (format org-e-latex-title-command title)) (t org-e-latex-title-command))) - ;; 9. Table of contents. + ;; 11. Table of contents. (let ((depth (plist-get info :with-toc))) (when depth (concat (when (wholenump depth) (format "\\setcounter{tocdepth}{%d}\n" depth)) "\\tableofcontents\n\\vspace*{1cm}\n\n"))) - ;; 10. Document's body. + ;; 12. Document's body. contents - ;; 11. Creator. + ;; 13. Creator. (let ((creator-info (plist-get info :with-creator))) (cond ((not creator-info)) ((eq creator-info 'comment) (format "%% %s\n" (plist-get info :creator))) (t (concat (plist-get info :creator) "\n")))) - ;; 12. Document end. + ;; 14. Document end. "\\end{document}"))) diff --git a/contrib/lisp/org-export.el b/contrib/lisp/org-export.el index 6910f3e..34f5356 100644 --- a/contrib/lisp/org-export.el +++ b/contrib/lisp/org-export.el @@ -394,6 +394,9 @@ When nil, remove priority cookies for export." (defcustom org-export-with-section-numbers t "Non-nil means add section numbers to headlines when exporting. +When set to an integer n, numbering will only happen for +headlines whose relative level is higher or equal to n. + This option can also be set with the #+OPTIONS line, e.g. \"num:t\"." :group 'org-export-general |