我正在使用org-mode编写文档。是否有可能使用计数器来为分布在整个文档中的练习题进行编号,而不是手动编号?我会将此导出为HTML和PDF(通过LaTeX)。例如:
* First chapter
Blabla.
Exercise 1.
* Second chapter.
Blabla
Exercise 2.
* Third chapter.
Exercise 3.
Exercise 4.
(setf exercise-counter 0)
(defun org-dblock-write:reset-exercise-counter (params)
(setf exercise-counter 0))
(defun org-dblock-write:exercise (params)
(incf exercise-counter)
(insert (concat "Exercise " (int-to-string exercise-counter) ".")))
#+BEGIN: reset-counter
#+END
现在我可以将这个内容分散到整个文档中:
#+BEGIN: exercise
#+END
Blablabla.
#+BEGIN: exercise
#+END
Blablabla.
org-update-all-dblocks
之后,正确的数字将被插入。
org-update-all-dblocks
?
回答:像这样:(add-hook 'org-export-first-hook 'org-update-all-dblocks)