我正在使用multibib
和natbib
一起獲得兩份不同的參考書目(一份用於正文,一份用於附錄)。這是一個範例程式碼
\documentclass[12pt]{article}
\usepackage{natbib}
\usepackage{multibib}
\newcites{apndx}{References}
\begin{document}
First paper to cite: \cite{X1}
\bibliographystyle{ecca}
\bibliography{XXX}
\appendix
Cite a paper in the appendix \citeapndx{X2}
\bibliographystyleapndx{ecca}
\bibliographyapndx{XXX}
\end{document}
然而,第二個參考書目並沒有出現,附錄中的引文只給了一個「?」。我查閱了multibib
手冊和其他類似的問題,但我不明白錯誤在哪裡。
更新 1 即使我運行 bibtex 檔案兩次也會發生這種情況。這是log
文件:
Process started: /Library/TeX/texbin/bibtex "prova".aux
This is BibTeX, Version 0.99d (TeX Live 2016)
The top-level auxiliary file: prova.aux
The style file: plain.bst
Database file #1: myrefs.bib
Process exited normally
Process started: /Library/TeX/texbin/bibtex "prova".aux
This is BibTeX, Version 0.99d (TeX Live 2016)
The top-level auxiliary file: prova.aux
The style file: plain.bst
Database file #1: myrefs.bib
Process exited normally
更新2:我認為問題是我的TexStudio沒有運行sec.aux
產生第二個參考書目連結的檔案。我按照此連結的步驟操作https://sourceforge.net/p/texstudio/wiki/Tips%20and%20Tricks/並創建了一個.cwl
並將其添加到 TexStudio Completion 但它仍然不起作用。
答案1
在兩個multibib
新文件和mwe.tex
.這兩個文件都需要使用. TeXStudio 使用for file進行運行,因為您需要自己完成。只需在 Windows 終端機中執行該命令即可。之後,您可以使用 TeXStudio 編譯兩次以獲得最終的 PDF。pdflatex
mwe.aux
apndx.aux
.aux
bibtex
bibtex
mwe.aux
apndx.aux
bibtex apndx
要讓命令\citeapndx
在圖的標題中運行(您在評論中的問題),您需要使用\protect
類似的命令(與 a 相同\section
):
\caption{In figure caption \protect\citeapndx{Johnson2000}}
% ^^^^^^^^
因此,使用以下檔案mwe.tex
(套件filecontents
僅用於在一個編譯 MWE 中同時包含 bib 檔案和 tex 程式碼):
% needs: bibtex apndx
\RequirePackage{filecontents}
\begin{filecontents}{\jobname.bib}
@inproceedings{Creighton2006,
author = {Creighton, Oliver and Ott, Martin and Bruegge, Bernd},
booktitle = {Requirements Engineering, 14th IEEE International Conference},
isbn = {0769525555},
pages = {109--118},
publisher = {IEEE},
title = {{Software cinema-video-based requirements engineering}},
url = {http://ieeexplore.ieee.org/xpls/abs{\_}all.jsp?arnumber=1704054},
year = {2006},
}
\end{filecontents}
\begin{filecontents}{apndx.bib}
@article{Johnson2000,
author = {Johnson, W Lewis and Rickel, Jeff W and Lester, James C},
journal = {International Journal of Artificial Intelligence in Education},
number = {11},
pages = {47--78},
title = {{Animated pedagogical agents: face-to-face interaction in
interactive learning environments}},
volume = {Internatio},
year = {2000},
}
\end{filecontents}
\documentclass[12pt]{article}
\usepackage{natbib}
\usepackage{multibib}
\usepackage{graphicx}
\newcites{apndx}{References in Appendix}
\begin{document}
First paper to cite: \cite{Creighton2006}
\bibliographystyle{ecca}
\bibliography{\jobname}
\appendix
Cite a paper in the appendix \citeapndx{Johnson2000}
%\section{In the appendix \protect\citeapndx{Johnson2000}} % <===========
\begin{figure}
\centering
\includegraphics[width=5cm]{example-image-a}
\caption{In figure caption \protect\citeapndx{Johnson2000}} % <=======
\label{fig:example-image-a}
\end{figure}
\bibliographystyleapndx{ecca}
\bibliographyapndx{apndx}
\end{document}
和編譯鏈(獨立於 TeXStudio):
- 按 Windows 開始鍵在 Windows 中開啟終端機窗口,
R
然後鍵入cmd
,按 Enter - 移動到你有 tex 程式碼和 bib 檔案的目錄
cd <directory path>
- 運行命令
pdflatex mwe
(產生兩個所需的.aux
檔案) - 運行命令
bibtex mwe
(編譯mwe.aux
) - 運行命令
bibtex apndx
(編譯apndx.aux
) - 運行命令
pdflatex mwe
(生成文件*.bbl
和*.blg
) - 運行命令
pdflatex mwe
(產生帶有pdf
參考書目的檔案)
如果您使用編輯器(TeXStudio、TeXnicCenter...),則編輯器可以為您運行pdflatex mwe
和bibtex mwe
,但不能運行 bibtex apndx
.因此,在 Windows 終端機中使用 TeXStudio 進行第一次編譯運行後執行此命令...
運行編譯鏈後,您將得到以下結果 pdf: