Org-mode中的章节摘要

3

我经常使用Emacs中的org-mode来写长文章和论文章节,但我发现自己在大纲视图和全文之间没有中间视图而感到沮丧。有没有人知道一种好的方法来包含某种摘要(比如点形式或段落文本),可以轻松地显示和隐藏?

我尝试过使用抽屉来存放概要信息,例如:

#+TITLE: My article
#+DRAWERS: SUMMARY

* Introduction
* Data and hypotheses
* Results
** First attempt
:SUMMARY:
My first attempt didn't work so well.
:END:

The text of the section goes here...
** Second attempt
:SUMMARY:
I still haven't started my second attempt.
:END:

我发现这种方式非常好,因为大部分摘要是隐藏的,只有当我想看的时候才会显示。问题是,这样我仍然无法得到摘要概述,即我可以看到每个部分的摘要并隐藏全文。

也许在org-mode中没有明显的解决方案,如果是这样,我不介意自己写一个,但肯定还有其他人有同样的需求,所以我想先问一下是否有人已经找到了解决方案。

2个回答

2
在这里,您将找到与问题中的:SUMMARY:解决方案相关的快速而简单的扩展。
编辑:我已经添加了更好的帮助和一种将org-summary包含到org-shifttab操作中的方法。但是,您也可以将某些键绑定到org-summary
(defun org-summary ()
  "Include :SUMMARY: drawer into heading if present.
You can use this drawer to write a summary.
As a pre-requisite you should include :SUMMARY: in `org-drawers':

\'(add-to-list 'org-drawers \"SUMMARY\")

 1. In your org-document put a line only containing :SUMMARY: on the line following the header.
 2. End the summary by a line starting with :END:.
 3. Leading indentation for :SUMMARY: and :END: is fine.
 4. The last line in the summary block must not be a blank line.
 5. The first non-blank character within summary lines must not be a colon `:'.

Example:

* I am the header
  :SUMMARY:
    And I am the summary.

    Spanning several lines including newlines.
    In this chapter the following topics are discussed:
    1. The world turns fast.
    2. We cannot always read everything we have written once.
    3. We need a summary.
  :END: Now, we will explain everything in full..."
  (interactive)
  (show-all)
  (let ((outline-heading-end-regexp "
\\([[:blank:]]*:SUMMARY:\\(
[[:blank:]]*[^:[:blank:]].*\\)*
[[:blank:]]*:END:\\)?"))
    (hide-body)
    ))

(add-to-list 'org-drawers "SUMMARY")

;; You can insert org-summary into org-cycle:
(defadvice org-shifttab (around summary activate)
  (if (and (boundp 'org-summary-cycle)
       (null org-summary-cycle)
       (eq org-cycle-global-status 'all))
      (progn
    (org-summary)
    (setq-local org-summary-cycle t)
    (message "SUMMARY")
    )
    ad-do-it
    (setq-local org-summary-cycle nil)))

0

我找到了一篇邮件列表帖子,其中描述了一个“概要视图”,听起来它可以做你想要的事情。这似乎非常简单:只需使用SYNOPSIS抽屉,然后使用此函数显示“概要视图”:

(defun k-synopsis-view ()
  "Show all headings (contents view) and, if any, their synopsis."
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (hide-sublevels 1)
    (while (re-search-forward "\\(^[ \t]*:SYNOPSIS:[. \t]*$\\)" nil t)
      (org-flag-drawer nil)
      (re-search-forward "^[ \t]*:END:[ \t]*" nil t)
      (outline-flag-region (match-beginning 0) (match-end 0) t))
    (org-content)))

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接