为何我的参考书目不起作用?

为何我的参考书目不起作用?

这是我的references.bib文件:

@article{fakeref,
title = {Fast-swimming sperm causes hurricanes in Africa},
volume = {7},
issn = {1234-5678},
shorttitle = {Sperm and hurricanes},
doi = {12.3456/j.ffs.2050.01.001},
abstract = {Our results suggest that fast-swimming sperm from human males are the main cause of hurricanes on the west coast of Africa.},
language = {eng},
number = {2},
journal = {Journal of Sperm and Climate Change},
author = {Eggnowitz, Eggina and Spermirowski, Sperminald},
month = apr,
year = {2050},
keywords = {Sperm,Hurricanes,Tornados,Eggs,Africa,Climate change,Global warming},
pages = {77--100}
}

这是我的 MWE(mwe.tex):

\documentclass[twocolumn,twoside,11pt]{article}
\usepackage{natbib} %Bibliography.
\setcitestyle{number} %Cite as numbers or author-year.
\bibliographystyle{vancouver} %Reference style.

\begin{document} %Everything that's written should come next.
\title{\vspace{-1.0cm}\textbf{\Large{This is a title}}} %Title

Random text here \citep{fakeref}.

\bibliography{‎⁨‎⁨‎⁨‎⁨‎⁨references}

\end{document}

当我运行以下命令时:

$ pdflatex mwe.tex

我得到以下终端输出:

$ pdflatex mwe.tex 
This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2018) 
(preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
(./mwe.tex
LaTeX2e <2018-04-01> patch level 2
Babel <3.18> and hyphenation patterns for 84 language(s) loaded.
(/usr/local/texlive/2018/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2018/texmf-dist/tex/latex/base/size11.clo))
(/usr/local/texlive/2018/texmf-dist/tex/latex/natbib/natbib.sty) 
(./mwe.aux)

Package natbib Warning: Citation `fakeref' on page 1 undefined on input line 16
.

! Undefined control sequence.
\GenericError  ...                                
                                                #4  \errhelp \@err@     
...
l.18 ...{‎⁨‎⁨‎⁨‎⁨‎⁨references}

? 

我尝试了很多方法,但似乎都不起作用。每当我将其包含\bibliography{references}在代码中时,它都不会编译,并且我会收到相同的错误消息。有人知道哪里出了问题吗?

答案1

您的代码中的问题是您的 bib 文件名称中隐藏了字母reference.bib。请参阅以下 MWE(使用您的 bib 文件reference.bib,确保文件名中也没有隐藏字母!):

\documentclass[twocolumn,twoside,11pt]{article}

\usepackage{natbib} %Bibliography.
\setcitestyle{numbers} %Cite as numbers or author-year.
\bibliographystyle{vancouver} %Reference style.


\begin{document} %Everything that's written should come next.
\title{\vspace{-1.0cm}\textbf{\Large{This is a title}}} %Title

Random text here \citep{fakeref}.

%\bibliography{‎⁨‎⁨‎⁨‎⁨‎⁨references} % <========================================
\bibliography{references} % <===========================================

\end{document}

在带有命令的注释行中,\bibliography您可以找到隐藏的字母。在我的编辑器中,我可以看到隐藏的字母,如下所示:

隐藏的字母

编译代码(并使用numbers\setcitestyle我得到以下结果:

在此处输入图片描述

答案2

你应该使用

\setcitestyle{numbers}

代替

\setcitestyle{number}

编辑:

文档中的第 2.9 节natbib说,引用模式是numbers,如参考表中所述。

相关内容