避免\ printbibliography被Org-mode标题吞噬

N.N*_*.N. 9 emacs bibtex org-mode biblatex

当使用Org-mode及其LaTeX导出时,BibTeX或Biblatex通常用于处理引用.在这种情况下,LaTeX命令\printbibliography通常包含在组织文件中.\printbibliography放在orTe文件中,LaTeX应该写出引用列表.什么\printbibliography是插入LaTeX标头和引用列表.在大多数情况下\printbibliography,放置在组织文件的末尾只是因为在大多数文档中,引用列表将放在最后.这意味着\printbibliography它将包含在组织文件的最后一个标题下,例如

* Heading

  \printbibliography
Run Code Online (Sandbox Code Playgroud)

这也意味着当该标题被折叠时,\printbibliography将被吞下:

* Heading...
Run Code Online (Sandbox Code Playgroud)

但这违背了意义,\printbibliography因为它在输出中包含了自己的标题.此外,\printbibliography吞下并在其后放置新标题会很困惑,因为参考列表将不再出现在文档的最后.

如何使它\printbibliography不被Org-mode中的部分吞噬?一个额外的问题:我怎么能这样做,以便Org-mode不会创建标题,\printbibliography除非C-Ret在光标在它之后按下?

在寻找这个问题的解决方案时,我找到了http://comments.gmane.org/gmane.emacs.orgmode/49545.

Iva*_*rus 1

以下内容经过了轻微测试,但对我来说适用,使用 tab 和 shift-tab 来隐藏和显示内容。这些是我使用的唯一隐藏和显示命令,因此如果您使用其他命令,可能需要以其他方式建议或修复它们。

您当然可以更改org-footer-regexp为您想要的任何内容。我希望不必使用任何建议,但在没有建议的情况下,org-end-of-subtree最后一个标题永远不会与选项卡循环,因为它认为它没有隐藏,所以它隐藏它然后org-cycle-hook取消隐藏它。它org-end-of-subtree在运行之前调用org-pre-cycle-hook,所以这也不是一个选择。

(defvar org-footer-regexp "^\\\\printbibliography\\[.*\\]$"
  "Regexp to match the whole line of the first line of the footer which should always be shown.")

(defun show-org-footer (&rest ignore)
  (save-excursion
    (goto-char (point-max))
    (when (re-search-backward org-footer-regexp nil t)
      (outline-flag-region (1- (point)) (point-max) nil))))

(add-hook 'org-cycle-hook 'show-org-footer)
(add-hook 'org-occur-hook 'show-org-footer)

(defadvice org-end-of-subtree (after always-show-org-footer
                                     ()
                                     activate)
  (when (>= (point) (1- (point-max)))
    (re-search-backward org-footer-regexp nil t)
    (setq ad-return-value (point))))
Run Code Online (Sandbox Code Playgroud)