引文未显示 - 而别名显示在 pdf 中

Citation not getting displayed - instead the alias is getting displayed in the pdf

我正在尝试使用 \cite 来引用 bibliography.bib 中的项目。但是,我的引用无法正常工作。

环境、代码和输出如下:

\documentclass[12pt]{article}

\usepackage{amssymb,amsmath,amsfonts,eurosym,geometry,ulem,graphicx,caption,color,setspace,sectsty,comment,footmisc,caption,pdflscape,subfigure,array,hyperref,booktabs,dcolumn,threeparttable, adjustbox,apacite,dirtytalk,multirow,tabularx,booktabs,longtable,lscape,placeins,tikz}

\usepackage[backend=biber,natlib,style=author-year,citestyle=authoryear]{biblatex}

\usepackage{ulem}

\usepackage{float}
\restylefloat{table}

\usepackage{pgfplots}
\pgfplotsset{width=12cm,compat=1.9}
\usepackage{pst-func}
\psset{unit=2cm}
\usepackage{hyperref}
\hypersetup{colorlinks=true,urlcolor=blue,citecolor=blue,linkcolor=red}
\usepackage[center]{caption}
\usepackage{setspace}
\usepackage{epsfig}
\usepackage{graphics}
\usepackage{lscape}
\usepackage[english]{babel}
\usepackage{color}

\addbibresource{bibfile.bib}

\begin{document}

This is a \cite{sample}.

\end{document}

该引用引用了我的 .bib 文件,该文件位于同一文件夹中。在这里我附上了一个示例引文。

@article{sample,
  title={What is the price elasticity of housing demand?},
  author={Hanushek, Eric A and Quigley, John M},
  journal={The Review of Economics and Statistics},
  pages={449--454},
  year={1980},
  publisher={JSTOR}
}

我得到的输出看起来像

Author Year 年份链接到参考书目部分。但是,我希望它像 Author, Year 一样,整个短语链接到参考书目部分

你能帮我解决这个问题吗?

谢谢你:)

P.S。 : 我知道我的环境并不完美。它有一些包裹重复了两次。 :)

切勿忽略错误消息!发生错误后,latex 只能恢复到足以对文档的其余部分进行语法检查的程度。在仍然存在错误的情况下,甚至查看什么可能是或可能不是有效输出是没有意义的!

主要有几个问题:

  • 不要多次加载包,尤其是不要使用不同的选项多次加载它们。日志文件中的错误消息将明确告诉您有关选项 clash

  • 不要在同一文档中加载不兼容的包,如 apacite 和 biblatex。日志文件中的错误消息明确告诉您这两个包不兼容

  • biblatex 选项称为 natbib,而不是 natlib。一条错误消息会明确告诉您它不知道选项 natlib

  • biblatex 样式称为 authoryear,而不是 author-year。一条明确的错误消息会告诉您未找到 author-year 样式

... 然后还有许多其他重复的、不必要的或过时的包。你应该清理你的序言并只加载你需要的包。 hyperref 也应该在其他包之后加载。

\documentclass[12pt]{article}

\usepackage{amssymb,amsmath,amsfonts,eurosym,geometry,ulem,graphicx,caption,color,setspace,sectsty,comment,footmisc,caption,pdflscape,subfigure,array,
%hyperref,
booktabs,dcolumn,threeparttable, adjustbox,
%apacite,
dirtytalk,multirow,tabularx,booktabs,longtable,
%lscape,
placeins,tikz}

\usepackage[backend=biber,natbib,style=authoryear,citestyle=authoryear]{biblatex}

%\usepackage{ulem}

\usepackage{float}
\restylefloat{table}

\usepackage{pgfplots}
\pgfplotsset{width=12cm,compat=1.9}
\usepackage{pst-func}
\psset{unit=2cm}
%\usepackage{hyperref}

%\usepackage[center]{caption}
%\usepackage{setspace}
%\usepackage{epsfig}
%\usepackage{graphics}
%\usepackage{lscape}
\usepackage[english]{babel}
%\usepackage{color}

\usepackage{hyperref}
\hypersetup{colorlinks=true,urlcolor=blue,citecolor=blue,linkcolor=red}

\begin{filecontents*}[overwrite]{\jobname.bib}
@article{sample,
  title={What is the price elasticity of housing demand?},
  author={Hanushek, Eric A and Quigley, John M},
  journal={The Review of Economics and Statistics},
  pages={449--454},
  year={1980},
  publisher={JSTOR}
}
\end{filecontents*}

\addbibresource{\jobname.bib}

\begin{document}

This is a \cite{sample}.

\end{document}