我似乎无法natbib
使用author-year
样式引用。
以下独立示例:
\documentclass{article}
\usepackage[authoryear]{natbib}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@misc{A01,
author = {Test, A. and Foo, B.},
year = {2001},
title = {Alpha},
}
@misc{A02,
author = {Alex, A. and Bar, B.},
year = {2005},
title = {Alpha},
}
\end{filecontents}
\begin{document}
\citep{A01}, \citep{A02}, \citet{A02}
\bibliography{\jobname}
\end{document}
仅返回错误
“!包 natbib 错误:参考书目与作者年份版本不兼容。”
我查看了围绕这个错误的各种答案,但无法找出我的情况出了什么问题。
谢谢你的帮助 :)
编辑:在下面添加了带有日志文件的代码截图:
答案1
嗯,似乎有两个问题:
- 您忘记添加书目样式,例如
\bibliographystyle{abbrvnat}
- 看来你的 TeX 发行版有点过时了……
使用以下 MWE
\RequirePackage{filecontents}
\begin{filecontents}{\jobname.bib}
@misc{A01,
author = {Test, A. and Foo, B.},
year = {2001},
title = {Alpha},
}
@misc{A02,
author = {Alex, A. and Bar, B.},
year = {2005},
title = {Alpha},
}
\end{filecontents}
\listfiles %<========= creates list of used packages and version numbers
\documentclass{article}
\usepackage[authoryear]{natbib}
\begin{document}
\citep{A01}, citep: \citep{A02}, citet: \citet{A02}
\bibliographystyle{abbrvnat} % <=======================================
\bibliography{\jobname}
\end{document}
我得到了以下结果,且没有错误消息:
如果你查看该.log
文件(例如386491.log
,如果 TeX 文件是名称386491.tex
)
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (MiKTeX 2.9.6400 64-bit) (preloaded format=pdflatex 2017.4.26) 15 AUG 2017 19:37
entering extended mode
**./386491.tex
(386491.tex
LaTeX2e <2017-04-15>
Babel <3.9r> and hyphenation patterns for 76 language(s) loaded.
("C:\Program Files\MiKTeX 2.9\tex\latex\filecontents\filecontents.sty"
Package: filecontents 2011/10/08 v1.3 Create an external file from within a LaTeX document
)
LaTeX Warning: Overwriting file `./386491.bib'.
\openout15 = `386491.bib'.
("C:\Program Files\MiKTeX 2.9\tex\latex\base\article.cls"
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
("C:\Program Files\MiKTeX 2.9\tex\latex\base\size10.clo"
File: size10.clo 2014/09/29 v1.4h Standard LaTeX file (size option)
)
\c@part=\count79
\c@section=\count80
\c@subsection=\count81
\c@subsubsection=\count82
\c@paragraph=\count83
\c@subparagraph=\count84
\c@figure=\count85
\c@table=\count86
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
) ("C:\Program Files\MiKTeX 2.9\tex\latex\natbib\natbib.sty"
Package: natbib 2010/09/13 8.31b (PWD, AO)
\bibhang=\skip43
\bibsep=\skip44
LaTeX Info: Redefining \cite on input line 694.
\c@NAT@ctr=\count87
)
(386491.aux)
\openout1 = `386491.aux'.
LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 23.
LaTeX Font Info: ... okay on input line 23.
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 23.
LaTeX Font Info: ... okay on input line 23.
LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 23.
LaTeX Font Info: ... okay on input line 23.
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 23.
LaTeX Font Info: ... okay on input line 23.
LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 23.
LaTeX Font Info: ... okay on input line 23.
LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 23.
LaTeX Font Info: ... okay on input line 23.
(386491.bbl) [1
{C:/Users/Internet/AppData/Local/MiKTeX/2.9/pdftex/config/pdftex.map}] (386491.aux)
*File List*
filecontents.sty 2011/10/08 v1.3 Create an external file from within a LaTeX document
article.cls 2014/09/29 v1.4h Standard LaTeX document class
size10.clo 2014/09/29 v1.4h Standard LaTeX file (size option)
natbib.sty 2010/09/13 8.31b (PWD, AO)
386491.bbl
***********
)
Here is how much of TeX's memory you used:
564 strings out of 493324
6475 string characters out of 3138984
58170 words of memory out of 3000000
4171 multiletter control sequences out of 15000+200000
4245 words of font info for 16 fonts, out of 3000000 for 9000
1141 hyphenation exceptions out of 8191
24i,4n,32p,145b,312s stack positions out of 5000i,500n,10000p,200000b,50000s
<C:/Program Files/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmbx12.pfb><C:/Program Files/MiKTeX 2.9/fonts/type1/public
/amsfonts/cm/cmr10.pfb>
Output written on 386491.pdf (1 page, 24658 bytes).
PDF statistics:
14 PDF objects out of 1000 (max. 8388607)
0 named destinations out of 1000 (max. 500000)
1 words of extra memory for PDF output out of 10000 (max. 10000000)
您可以在第一行看到我正在使用当前的 MiKTeX 2,9 版本,3.14159265-2.6-1.40.18 (MiKTeX 2.9.6400 64-bit)
并且我的系统使用了以下包(使用命令创建\listfiles
):
*File List*
filecontents.sty 2011/10/08 v1.3 Create an external file from within a LaTeX document
article.cls 2014/09/29 v1.4h Standard LaTeX document class
size10.clo 2014/09/29 v1.4h Standard LaTeX file (size option)
natbib.sty 2010/09/13 8.31b (PWD, AO)
请将此数字与您的数字进行比较。从您向我们展示的屏幕截图来看,我猜您的系统有点旧。请更新...