本人使用VScode编写latex,在引用文献时遇到了以下问题:
引用不同文献,会出现编译成功/失败的差异。编译失败时,控制台显示”entry type for "123" isn't style-file defined“;输出的pdf中,引用处显示[?],文末的参考文献目录中。没有我引用的这条文献。
例如,我在正文中引用如下:

百度学术搜索得到bibtex如下:

将其复制到我的reference.bib,编译后错误:


多方查阅资料,最终解决问题。
首先,latex目录中.bst文件是模板性质的,它规定了你写的论文中的各种格式,

?打开后,对比我之前引用的bibtex,可以发现有如下差异:

?左边是.bst右边是.bib,矩形框中是.bib缺少的项,椭圆框中是不一样的项,修改后如下:

值得一提的是pages中可以什么也不写,即“pages={}”但这一项必须要有;多余的month并不影响正确输出pdf。所以我推测.bst中的如@masterthesis、@inproceedings、@conference,其所包含的项,在引用的bibtex中必须都要出现,否则编译就不成功。
现在再进行编译,就能得到正确的pdf了

如果做了上述修改还是不行,可以试试把我下面的settings.json设置复制到你的vscode中,关掉重启再试一下
{
// LaTeX
"latex-workshop.latex.autoBuild.run": "never",
"latex-workshop.message.error.show": false,
"latex-workshop.message.warning.show": false,
"latex-workshop.latex.tools": [
{
"name": "xelatex",
"command": "xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOCFILE%"
]
},
{
"name": "pdflatex",
"command": "pdflatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOCFILE%"
]
},
{
"name": "bibtex",
"command": "bibtex",
"args": [
"%DOCFILE%"
]
}
],
"latex-workshop.latex.recipes": [
{
"name": "xelatex",
"tools": [
"xelatex"
],
},
{
"name": "pdflatex",
"tools": [
"pdflatex"
]
},
{
"name": "xe->bib->xe->xe",
"tools": [
"xelatex",
"bibtex",
"xelatex",
"xelatex"
]
},
{
"name": "pdf->bib->pdf->pdf",
"tools": [
"pdflatex",
"bibtex",
"pdflatex",
"pdflatex"
]
}
],
"latex-workshop.view.pdf.viewer": "tab",
"latex-workshop.view.pdf.internal.synctex.keybinding": "ctrl-click",
// LaTex 编译时自动删除多余的文件,如果自动删除 .aux 文件,则 \ref{} 会报错; .out 文件被删除也会产生一个警告
"latex-workshop.latex.autoClean.run": "onBuilt", //注意结尾是 t 不是 d
"latex-workshop.latex.clean.fileTypes": [
// "*.aux",
"*.bbl",
"*.blg",
"*.idx",
"*.ind",
"*.lof",
"*.lot",
// "*.out",
"*.toc",
"*.acn",
"*.acr",
"*.alg",
"*.glg",
"*.glo",
"*.gls",
"*.ist",
"*.fls",
"*.log",
"*.fdb_latexmk"
]
|