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

时间:2012-02-03 20:18:41

标签: emacs org-mode bibtex biblatex

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

* Heading

  \printbibliography

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

* Heading...

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

我怎样才能使Org-mode中的部分不会吞下\printbibliography?一个额外的问题:我怎样才能使组织模式在\printbibliography之后不创建标题,除非当光标在它之后按 C-Ret

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

5 个答案:

答案 0 :(得分:3)

此问题的解决方法是使\printbibliography不返回LaTeX标题,以便可以将其放置在组织模式标题下。

使用biblatex,可以通过向\printbibliography提供选项heading=none并将其置于适当的标题下来完成此操作。这是一个例子:

* Heading

* References

  \printbibliography[heading=none]

这种方式引用可以保存在自己的标题中,并且\printbibliography被标题吞没不是问题,因为它被自己的标题吞没了。

答案 1 :(得分:1)

一种解决方案如下:

#+macro: printbiblio        (add extra spaces here, but cannot add comment)

* Test 2
  This is a test

* {{{printbiblio}}}
  Test text
  \printbibliography
* 
  asdf

像这样,你最终会在文档底部显示一个空白标题。宏扩展为空白文本块,因此您最终得到

\section{Test 2}
\label{sec-1}

This is a test
\section{}

Test text
\printbibliography
\section{}

asdf

这也确保您不会在参考书目后不小心添加标题,因为它是自己的(空)标题。它可能(似乎实际上)包含在目录中,这是不幸的但我怀疑解决方案最糟糕的是运行后导出以从文件中删除空标题(或在转换为之前手动执行此操作) PDF)。

答案 2 :(得分: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))))

答案 3 :(得分:0)

另一种解决方案是将参考书目放在名为“参考文献”的标题下,如下所示:

* Heading
Some text
* References
\printbibliography

并将生成的乳胶文件中的\section{References}添加到您的emacs初始文件

(defun org-export-latex-remove-references-heading (contents backend info)
    (if (not (eq backend 'latex))
        contents
      (replace-regexp-in-string "\\\\section\\*?{References}\\s-*\\\\label{.*?}" "" contents)
      ))

(add-hook 'org-export-filter-final-output-functions 'org-export-latex-remove-references-heading)

请注意,这假设您只有一个名为“引用”的标题,因为它取代了所有出现的标题。它还假设这些部分采用以下格式:

\section{References}
\label{<any_string>}
\printbibliography

对于其他格式,您需要更改org-export-latex-remove-references-heading函数中的正则表达式。

答案 4 :(得分:0)

* References
  :PROPERTIES:
  :UNNUMBERED: t
  :END:

   \printbibliography[heading=none]

有一种更简单的方法可以解决这个问题。 只需添加&#34;无编号&#34;属性到标题,它将被导出,没有任何编号。