TL;DR:
使用包org-ref
。
使用内部链接标记章节,如<<sec:section-name>>
为图像、表格和源代码使用名称,如#+name: fig:my-fig
使用命令M-x org-ref-insert-ref-link
插入内部链接
详情
如果您使用Org-Ref (此处有使用链接),我强烈推荐它用于技术写作,以及良好的引用实践,在其用户友好界面下管理内部引用(内部链接)。
使用内部链接格式<<link-name>>
和#+name: another-name
格式创建标签。使用键序列M-x org-ref-insert-ref-link
使用completing-read
界面插入链接,这取决于您的设置,可能会增加Icicles、Ido、Helm、Company等功能。
例如,在以下情况下:
* Section with labels
<<sec:sec-w-labels>>
[...] My story here [...]
file:my-screenshot.png
* Section with links
I can refer to the section with labels (see \S <I>)
containing an explanatory figure here (see Fig. <I>)
当我的光标在标记为
<I>
的任一位置时,我使用一个命令
M-x org-ref-insert-ref-link
,该命令已绑定到
C-c C-x )
。然后,emacs会显示所有内部链接的完整候选列表,这种情况下,它们分别是
sec:sec-w-labels
和
fig:my-screenshot
。
完成后,该部分应如下所示,具有
ref:
链接:
* Section with links
I can refer to the section with labels (see \S
ref:sec:sec-w-labels) containing an explanatory figure
here (see Fig. ref:fig:my-screenshot)
安装方法:将以下内容插入到你的Emacs初始化文件中,并重新启动。或者只是想尝试的话,将以下内容插入到你的*Scratch*
缓冲区并执行C-M-x
。
(use-package org-ref
:ensure t
:after ob-http
:hook (org-mode . ref-link-keymap)
:config
(defun ref-link-keymap ()
(define-key org-mode-map (kbd "C-c C-x )")
#'org-ref-insert-ref-link)))
限制
ref:
链接在所有导出器中都被导出为具有相同文本和 href 值的另一个链接。因此,在 HTML 导出的情况下,该链接将呈现为:
<a href="sec:bfm">sec:bfm</a>
对于Latex,编译器会将此内部链接翻译成章节编号。
\labels{}
。 - Clément