举个例子, 我的习惯是从2级标题写到6级标题, 不会用1级标题. 常常只用了2,4,5,6级标题. 如何把2,4,5,6级标题映射为1,2,3,4?
也就是说, 把原本不连续的标题级别,映射成连续的, 且从1开始的. 如果用R描述, 就是headings<-rank(headings)
为什么样这样做:
- 因为latex只支持5级标题(chapter就不算在内了).
- 标题级别太低不好看. 就算是html, 如果六级标题总是用item(unordered list), 不美观. 我曾经找到过一段代码:
(defun org-promote-to-top-level ()
"Promote a single subtree to top-level."
(let ((cur-level (org-current-level)))
(loop repeat (/ (- cur-level 1) (org-level-increment))
do (org-promote-subtree))))
;; Define a function that applies "org-promote-to-top-level"
;; to each :export: subtree:
(defun org-export-trees-to-top-level (backend)
"Promote all subtrees tagged :export: to top-level.
BACKEND is the export back-end being used, as a symbol."
(org-map-entries 'org-promote-to-top-level "+export"))
;; Make org-mode run "org-export-subtrees-to-top-level" as part of the export
;; process:
(add-hook 'org-export-before-parsing-hook 'org-export-trees-to-top-level)
但不起作用. 具体来说, 2级标题的确被映射为1级标题了, 但6级标题不知怎么回事, 还是会被映射为unordered list.
关于这里的org-map-entries
这一行, 我想问, 是不是有export的entry只有level最高的那个entry? 比如说, 有2, 4,5,6级标题, 只有2级标题会被调用函数org-promote-to-top-level
?