
假設我有一個cats.bib
和 ,hats.bib
我想在一篇關於戴帽子的貓的文章中使用它。已經有一個現有的相關論文(嗯,有點),我在兩個文件中都有。
現在,我做不是想要合併這些文件(與這個問題和這個)。我是願意允許我使用的任何工具忽略條目之間差異的可能性,只選擇牠喜歡的任何一個(甚至不一致;我的意思是,我願意保證它們確實是同一條目的副本)。在這些條件下,我該怎麼做才能在我的 LaTeX 文件中使用這兩個參考書目而不會出現任何錯誤?
如果您建議暫時合併它們只是為了編譯文檔,請建議一些可以集成到,例如,中的東西,latexmk
這樣我就不必重複手動執行此操作,並且希望無論使用什麼工具都能做到這一點參考書目名稱來自.tex
文件本身而不是先驗的。
答案1
.bib
您可以根據需要使用任意數量的文件。重複的條目將導致 BibTeX 錯誤,該錯誤不會產生任何後果,並且僅保留第一個找到的條目。
\begin{filecontents*}{\jobname-cats.bib}
@article{unique-cats,
author={A. Uthor},
title={Title},
journal={Journal},
year=2016,
}
@article{duplicate,
author={W. Riter},
title={Title},
journal={Journal},
year=2016,
}
\end{filecontents*}
\begin{filecontents*}{\jobname-hats.bib}
@article{unique-hats,
author={P. Laywright},
title={Title},
journal={Journal},
year=2016,
}
@article{duplicate,
author={W. Riter},
title={Title},
journal={Journal},
year=2016,
}
\end{filecontents*}
\documentclass{article}
\begin{document}
\title{Cats in hats}
\author{Einpoklum}
\maketitle
We want to cite \cite{unique-cats}, but also \cite{unique-hats}.
There is a duplicate \cite{duplicate}.
\bibliographystyle{plain}
\bibliography{\jobname-cats,\jobname-hats}
\end{document}
這是 BibTeX 的警告:
This is BibTeX, Version 0.99d (TeX Live 2016)
The top-level auxiliary file: einmulti.aux
The style file: plain.bst
Database file #1: einmulti-cats.bib
Database file #2: einmulti-hats.bib
Repeated entry---line 7 of file einmulti-hats.bib
: @article{duplicate
: ,
I'm skipping whatever remains of this entry
(There was 1 error message)
答案2
Bib 檔案只是純文本,並且沒有等效項,\end{document}
因此您可以將它們連接起來(因為您接受重複條目的責任)。
在linux上--shell-escape
你可以做類似的事情
\documentclass{article}
\immediate\write18 {cat nice_papers*.bib > \jobname.bib}
\addbibresource{\jobname.bib}
\begin{document}
在 Windows 上,情況類似:cat...
您將使用copy /y nice_papers*.bib \jobname.bib
.假設使用 biblatex,但 bibtex 的變更微不足道 ( \bibliography{\jobname}
)。
這應該是相容的,latexmk
因為它不使用外部工具。
需要注意的一件事是,您的來源 bib 檔案應該以一個或多個換行符號結尾,這樣您就不會在合併點出現垃圾行(如果您有你的書目文件中的評論)