避免\printbibliography被组织模式标题吞噬 [英] Avoid \printbibliography being swallowed by Org-mode headings

查看:1936
本文介绍了避免\printbibliography被组织模式标题吞噬的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用Org模式及其LaTeX导出BibTeX或Biblatex通常用于处理引用。在这种情况下,LaTeX命令 \printbibliography 通常包含在组织文件中。 \printbibliography 放在LaTeX应写出参考列表的组织文件中。什么 \printbibliography 是将LaTeX标题与引用列表一起插入。在大多数情况下, \printbibliography 被放置在组织文件的末尾,因为在大多数文档中,引用列表将被放置在最后。这意味着 \printbibliography 将被包含在组织文件的最后一个标题下,例如

  *标题

\printbibliography

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

  *标题... 

但这违背了 \\ \\ printbibliography ,因为它在输出中包含自己的标题。此外,当 \printbibliography 被吞下并且在其后面放置一个新标题时,这将是令人困惑的,因为引用列表将不再显示在文档的最后。 >

我如何做到这一点,使得 \printbibliography 不会被Org模式的部分吞下?一个奖金问题:如何使得它可以使组织模式不会在 \printbibliography 之后创建标题,除非 C-Ret 光标在之后?



在搜索此问题的解决方案时,我发现 http://comments.gmane.org/gmane.emacs.orgmode/49545

解决方案

以下是轻微测试,但适用于我使用tab和shift-tab来隐藏和显示的东西。那些是我使用的唯一隐藏和显示命令,所以如果你使用其他命令,他们可能需要以其他方式建议或修复。



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

 (defvar org-footer-regexp^ \\\\printbibliography \\ [。* \\] $
正则表达式匹配页脚第一行的整行,应始终显示。)

(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' -org-footer)
(add-hook'org-occurrence-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无t)
(setq ad-return-value(point))))


When using Org-mode and its LaTeX export BibTeX or Biblatex is often used to handle references. In that case the LaTeX command \printbibliography is often included in the org file. \printbibliography is placed in the org file where LaTeX is supposed to write out the reference list. What \printbibliography does is to insert a LaTeX header along with the reference list. In most cases \printbibliography is placed at the end of the org file simply because in most documents the reference list is to be placed last. This means that \printbibliography will be included under the last heading in the org file, e.g.

* Heading

  \printbibliography

It also means that when that heading is folded the \printbibliography will be swallowed:

* Heading...

But this goes against the meaning of \printbibliography because it includes its own heading in the output. Also, it will be confusing when \printbibliography is swallowed and a new heading is placed after it because then the reference list will no longer appear last in the document.

How can I make it so that \printbibliography is not swallowed by sections in Org-mode? A bonus question: how can I make it so that Org-mode does not create headings after \printbibliography unless C-Ret is pressed when the cursor is after it?

In searching for a solution to this problem I found http://comments.gmane.org/gmane.emacs.orgmode/49545.

解决方案

The following is lightly tested but works for me using tab and shift-tab to hide and display things. Those are the only hiding and showing commands that I use, so if you use other commands they may have to be advised or fixed in some other way.

You can of course change org-footer-regexp to anything you want. I was hoping to not have to use any advice, but without advising org-end-of-subtree the last heading never cycles with tab because it thinks it's not hidden, so it hides it and then org-cycle-hook unhides it. It calls org-end-of-subtree before running org-pre-cycle-hook so that's not an option either.

(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))))

这篇关于避免\printbibliography被组织模式标题吞噬的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆