RefTeX 找不到參考書目文件

RefTeX 找不到參考書目文件

我在 MacOS 上使用最新的 Aquamacs(我想知道為什麼所有這些與 emacs 相關的問題都發佈在 tex.stackexchange.com 而不是 emacs.stackexchange.com 中)。

我希望我的 Emacs 配置正確。至少,這是以下的相關定義.emacs

(setq reftex-extra-bindings t)
(require 'reftex)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTeX t)
(require 'bibtex)
(bibtex-set-dialect 'biblatex)
(setq LaTeX-biblatex-use-Biber t)
(setq TeX-command-BibTeX "Biber")
(setq reftex-bibliography-commands
      '("bibliography" "nobibliography" "addbibresource")) 
(setq reftex-bibpath-environment-variables
      '(".:~/lib/texmf/bibtex/bib//:/usr/local/texlive/texmf-local/bibtex/bib//:/usr/local/texlive/2018/texmf-dist/bibtex/bib//"))
; (reftex-use-external-file-finders t)
(setq reftex-external-file-finders
      '(("tex" . "kpsewhich -format=.tex %f")
    ("bib" . "kpsewhich -format=.bib %f")))

Emacs 毫無怨言地啟動。

接下來,我將此 MWE 設定為檔案test.tex

\documentclass{scrbook}

\usepackage[T1]{fontenc}
\usepackage[backend=biber,style=numeric]{biblatex}

\addbibresource{computer.bib}

\begin{document}

% Waiting to insert \cite{} here

\end{document}

\addbibresource{computer.bib}我以通常的方式添加了這一行: C-cRET addbi TABRET。此時,透過按TAB,Emacs 完成命令\addbibresource並將該 LaTeX 命令插入到緩衝區中,同時仍在迷你緩衝區中,系統會要求我提供選項。我再次按了一下,跳過了這個問題RET。現在,Emacs 請求(仍在迷你緩衝區中)要使用的參考書目檔案。我輸入後,Emacs 再次補全了我插入的comTAB完整檔名。computer.bibRET

我懷疑,Emacs 知道 的存在~/lib/texmf/bibtex/bib/JB/computer.bib,因此能夠完成其檔案名,因為我定義了reftex-bibpath-environment-variables(如上所示)。

Emacs 也被指示自動掃描 LaTeX 檔案。因此,此時自動產生的文件auto/test.el顯示:

(TeX-add-style-hook
 "test"
 (lambda ()
   (TeX-add-to-alist 'LaTeX-provided-package-options
                     '(("fontenc" "T1") ("biblatex" "backend=biber" "style=numeric")))
   (add-to-list 'LaTeX-verbatim-environments-local "semiverbatim")
   (add-to-list 'LaTeX-verbatim-environments-local "minted")
   (add-to-list 'LaTeX-verbatim-environments-local "Verbatim")
   (add-to-list 'LaTeX-verbatim-environments-local "Verbatim*")
   (add-to-list 'LaTeX-verbatim-environments-local "BVerbatim")
   (add-to-list 'LaTeX-verbatim-environments-local "BVerbatim*")
   (add-to-list 'LaTeX-verbatim-environments-local "LVerbatim")
   (add-to-list 'LaTeX-verbatim-environments-local "LVerbatim*")
   (add-to-list 'LaTeX-verbatim-environments-local "SaveVerbatim")
   (add-to-list 'LaTeX-verbatim-environments-local "VerbatimOut")
   (add-to-list 'LaTeX-verbatim-macros-with-braces-local "hyperref")
   (add-to-list 'LaTeX-verbatim-macros-with-braces-local "hyperimage")
   (add-to-list 'LaTeX-verbatim-macros-with-braces-local "hyperbaseurl")
   (add-to-list 'LaTeX-verbatim-macros-with-braces-local "nolinkurl")
   (add-to-list 'LaTeX-verbatim-macros-with-braces-local "path")
   (add-to-list 'LaTeX-verbatim-macros-with-braces-local "url")
   (add-to-list 'LaTeX-verbatim-macros-with-delims-local "path")
   (add-to-list 'LaTeX-verbatim-macros-with-delims-local "Verb")
   (add-to-list 'LaTeX-verbatim-macros-with-delims-local "url")
   (TeX-run-style-hooks
    "latex2e"
    "scrbook"
    "scrbook10"
    "fontenc"
    "biblatex")
   (LaTeX-add-bibliographies
    "computer"))
 :latex)

我很幸運,倒數第二個條目顯示了正確的參考書目文件"computer"。在終端/外殼中進行快速測試給出

<funnyprompt>:~$ kpsewhich bib computer.bib
/Users/tmjb/Library/texmf/bibtex/bib/JB/computer.bib
<funnyprompt>:~$ grep texstudio `kpsewhich bib computer.bib`
@Online{texstudio, 
                 url = {http://texstudio.sourceforge.net/manual/current/usermanual_en.html},

這應該證明該檔案存在並且包含具有所需鍵“texstudio”的條目。


編輯:~/lib/在我的情況下擴展到/Users/tmjb/Library/.


接下來,我將遊標移到下面\begin{document}並開始插入\cite- 命令(再次以通常的方式):(C-cc這對我來說是一個快捷方式,與 相同C-c[)。在迷你緩衝區中時,RefTeX 要求我插入正規表示式。我插入texstudio,我碰巧知道它存在於給定的參考書目文件中。按RETEmacs 後抱怨Sorry, no matches found。遊標離開Minibuffer並仍在主緩衝區中等待,但沒有插入任何文本,甚至沒有插入已經定義的命令\cite

-緩衝區*Message*說:

Making completion list...
   (?=Help)

Scanning bibliography database test.bib
Sorry, no matches found

Emacs 到底為什麼要掃描test.bib?該文件在任何地方都不存在。它也沒有在任何地方定義(包括 LaTeX 檔案或 emacs 設定檔)!

我的配置中遺漏了什麼,讓 Emacs 掃描參考書目文件,它能夠完成其文件名。


更新

按照 Arash Esbati 的建議,我替換~為擴展路徑/Users/tmjb,最後我甚至重新啟動了我的 emacs,結果成功了!

我刪除了\addbibliography{...}文件中的條目,然後重新輸入參考書目文件,或添加一大行\bibliography{tuc-thesis,latex-base,typographie,computer}(列出的每個文件都在小型緩衝區中完成),然後\addbibresource{}再添加四行。我輸入C-cC-n重新掃描 LaTeX 檔案。然後我檢查了自動文件。令人驚訝的是,它只包含四個參考書目文件中的三個。無論我如何設定文件,只有那些不在本地目錄中的參考書目文件才會在自動文件中列出。

我能夠\cite{}在主文件中插入命令。到目前為止,這是朝著正確方向邁出的一步:-)

成功將 a 插入\cite主文件後,我還能夠將\cites 插入子文件中。

功能仍然不正確的是,標籤的自動完成功能不適用於不在本機目錄中的參考書目。但我想,我暫時可以忍受!

相關內容