LaTeX:「未定義的引用」警告

LaTeX:「未定義的引用」警告

運行此範例程式碼時:

\documentclass[11pt,a4paper]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[british]{babel}
\usepackage[onehalfspacing]{setspace}
\usepackage{natbib}

\begin{document}

Hello World \cite{greenwood_theoretical_2016}

\end{document}

\bibliography{Bibliography}
\bibliographystyle{plain}

我不斷收到警告:

'第 1 頁的引文 greenwood_theoretical_2016 在輸入行 10 上未定義'

並且參考文獻被標記為'' 在文件中。

LaTeXTools我在 macOS High Sierra 上使用 Sublime Text 3.2 。
構建器設定為 '基本的' 所以它運行:

pdflatex
bibtex
pdflatex
pdflatex

我從 Zotero 匯出參考書目(格式:Bibtex;編碼:UTF-8)並檢查了“Bibliography.bib”檔案(位於同一目錄中),引用似乎是正確的(範例):

@article{greenwood_theoretical_2016,
title = {Theoretical, contemporary observational and palaeo-perspectives on ice sheet hydrology: {Processes} and products},
volume = {155},
issn = {0012-8252},
shorttitle = {Theoretical, contemporary observational and palaeo-perspectives on ice sheet hydrology},
url = {http://www.sciencedirect.com/science/article/pii/S0012825216300095},
doi = {10.1016/j.earscirev.2016.01.010},
urldate = {2018-12-05},
journal = {Earth-Science Reviews},
author = {Greenwood, Sarah L. and Clason, Caroline C. and Helanow, Christian and Margold, Martin},
month = apr,
year = {2016},
keywords = {Geomorphology, Esker, Meltwater, Review, Hydrology, Channel, Glacier, Ice Sheet},
pages = {1--27}

使用biblatex而不是natbib給我方括號中的參考標籤,即

你好世界 [greenwood_theoretical_2016]

我也嘗試過使用不同的風格,但沒有任何改變。

我知道對此有很多疑問,但似乎沒有任何作用。

答案1

在您給定的程式碼中存在一些問題:

  1. 應該在程式碼中更改呼叫\bibliographystyle和的順序(樣式優先!)。\bibliography
  2. 加載時natbib你應該更好地使用plainnat樣式plain
  3. \end{document}在調用參考書目之前你已經有了。這意味著後面的程式碼\end{document}不會被執行。

請使用以下程式碼:

\RequirePackage{filecontents}
\begin{filecontents*}{Bibliography.bib}
@article{greenwood_theoretical_2016,
  title = {Theoretical, contemporary observational and palaeo-perspectives 
           on ice sheet hydrology: {Processes} and products},
  volume = {155},
  issn = {0012-8252},
  shorttitle = {Theoretical, contemporary observational and 
  palaeo-perspectives on ice sheet hydrology},
  url = {http://www.sciencedirect.com/science/article/pii/S0012825216300095},
  doi = {10.1016/j.earscirev.2016.01.010},
  urldate = {2018-12-05},
  journal = {Earth-Science Reviews},
  author = {Greenwood, Sarah L. and Clason, Caroline C. and Helanow, 
            Christian and Margold, Martin},
  month = apr,
  year = {2016},
  keywords = {Geomorphology, Esker, Meltwater, Review, Hydrology, 
              Channel, Glacier, Ice Sheet, Read Level 3},
  pages = {1--27},
}
\end{filecontents*}


\documentclass[11pt,a4paper]{scrartcl}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[british]{babel}
\usepackage[onehalfspacing]{setspace}

\usepackage{natbib}


\begin{document}

Hello World \cite{greenwood_theoretical_2016}

\bibliographystyle{plainnat} % plain
\bibliography{Bibliography} % Bibliography

\end{document}

並查看預期結果:

bibtex 的結果

如果您想取得編號的參考書目,請新增numbers選項natbib

\usepackage[numbers]{natbib}

正確的編譯程式碼biblatex

\documentclass[11pt,a4paper]{scrartcl}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[british]{babel}
\usepackage[onehalfspacing]{setspace}

\usepackage{csquotes}
\usepackage[%
  natbib=true, % <=======================================
  backend=biber, % <=====================================
]{biblatex}
\addbibresource{Bibliography.bib} % Bibliography <=======


\begin{document}

Hello World \cite{greenwood_theoretical_2016}

\printbibliography

\end{document}

結果:

在此輸入影像描述

答案2

這裡原始答案的部分說「我幾乎確定命令\bibliographystyle{plain}應該在命令之前\bibliography{Bibliography}」並不真正正確,因為 bibtex 編譯將單獨完成,因此僅使用已經具有以下資訊的 aux 檔案傳記風格。 (感謝@barbarabeeton和@moewe...)當然,編程習慣仍然會讓更多的人在打印命令之前添加它,因為通過說“獲取樣式並打印它”,代碼將更具可讀性。不是“打印它......啊!別忘了......我需要這種風格!” :P

未經測試,但我幾乎確定該命令\bibliographystyle{plain}應該在該命令之前\bibliography{Bibliography},最重要的是(我在這裡確定),兩個命令都應該在該\end{document}命令之前。

請嘗試一下,如果可以的話請回答。

相關內容