hyperref
当我一起使用和包时,出现错误bibentry
。错误是:
./Test.bbl:1: LaTeX Error: Command \BR@bibitem already defined.
Or name \end... illegal, see p.192 of the manual.
指向l.1 \begin{thebibliography}{2}
,这当然是Text.bbl
文件的第一行。
Test
是我的 MWE 文件的名称:
\documentclass{article}
\usepackage[pagebackref=true,linktocpage]{hyperref}
\usepackage[square]{natbib}
\usepackage{bibentry}
\nobibliography*
\begin{document}
\section{Introduction}
Look ma, inline bibtex entries:
\begin{itemize}
\item \begin{NoHyper}\bibentry{McCune:2015}\end{NoHyper}
\item \begin{NoHyper}\bibentry{Deshpande:2018aa}\end{NoHyper}
\end{itemize}
\section{And now for something completely different}
Lorem ipsum yada yada,
also see \citep{McCune:2015},
yada yada, and \citep{Deshpande:2018aa} too.
\bibliographystyle{abbrvnat}
\bibliography{testref}
\end{document}
该testref.bib
文件内容如下:
@STRING{COMPSUR = {ACM Comput. Surv.}}
@book{Deshpande:2018aa,
Author = {Deshpande, Amol and Gupta, Amarnath},
Date-Added = {2017-04-12 14:27:29 +0000},
Date-Modified = {2017-04-12 14:28:23 +0000},
Note = {Forthcoming},
Publisher = {ACM Books},
Title = {Principles of Graph Data Management and Analytics},
Year = {2018}}
@article{McCune:2015,
Author = {McCune, Robert Ryan and Weninger, Tim and Madey, Greg},
Journal = COMPSUR,
Number = {2},
Numpages = {39},
Pages = {25:1--25:39},
Title = {Thinking Like a Vertex: A Survey of Vertex-Centric Frameworks for Large-Scale Distributed Graph Processing},
Url = {http://doi.acm.org/10.1145/2818185},
Volume = {48},
Year = {2015}}
有什么建议说我可能做错了什么吗?如果我删除 hyperref 包,一切就都正常了。我确实读过这里的文章,但建议的解决方案没有帮助——一个是将我在 MWE 中拥有的\bibentry
with包装起来NoHyper
(事实上,MWE 就是从其中一个中获取的)。
答案1
hyperref
在其他包之后加载,请参阅哪些包应该在 hyperref 之后加载而不是之前加载?以防例外。
\begin{filecontents}{testref.bib}
@STRING{COMPSUR = {ACM Comput. Surv.}}
@book{Deshpande:2018aa,
Author = {Deshpande, Amol and Gupta, Amarnath},
Date-Added = {2017-04-12 14:27:29 +0000},
Date-Modified = {2017-04-12 14:28:23 +0000},
Note = {Forthcoming},
Publisher = {ACM Books},
Title = {Principles of Graph Data Management and Analytics},
Year = {2018}}
@article{McCune:2015,
Author = {McCune, Robert Ryan and Weninger, Tim and Madey, Greg},
Journal = COMPSUR,
Number = {2},
Numpages = {39},
Pages = {25:1--25:39},
Title = {Thinking Like a Vertex: A Survey of Vertex-Centric Frameworks for Large-Scale Distributed Graph Processing},
Url = {http://doi.acm.org/10.1145/2818185},
Volume = {48},
Year = {2015}}
\end{filecontents}
\documentclass{article}
\usepackage[square]{natbib}
\usepackage{bibentry}
\nobibliography*
\usepackage[pagebackref=true,linktocpage]{hyperref}
\begin{document}
\section{Introduction}
Look ma, inline bibtex entries:
%
\begin{itemize}
\item \begin{NoHyper}\bibentry{McCune:2015}\end{NoHyper}
\item \begin{NoHyper}\bibentry{Deshpande:2018aa}\end{NoHyper}
\end{itemize}
\section{And now for something completely different}
Lorem ipsum yada yada,
also see \citep{McCune:2015},
yada yada, and \citep{Deshpande:2018aa} too.
\bibliographystyle{abbrvnat}
\bibliography{testref}
\end{document}
答案2
在其他包之后加载 hyperref 可能还不够。超链接手册建议采用以下解决方法(用您自己的 bib 文件更改“数据库”):
\makeatletter
\let\saved@bibitem\@bibitem
\makeatother
\usepackage{bibentry}
\usepackage{hyperref}
\begin{document}
\begingroup
\makeatletter
\let\@bibitem\saved@bibitem
\nobibliography{database}
\endgroup