
Я получаю ошибку, когда я использую 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, все работает. Я читал статьи здесь, но предложенные решения не помогают — одно из них заключалось в том, чтобы обернуть то, \bibentry
что NoHyper
у меня есть в MWE (на самом деле, 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 после других пакетов может оказаться недостаточной.гиперрефруководство предлагает следующий обходной путь (замените «database» на свой собственный файл bib):
\makeatletter
\let\saved@bibitem\@bibitem
\makeatother
\usepackage{bibentry}
\usepackage{hyperref}
\begin{document}
\begingroup
\makeatletter
\let\@bibitem\saved@bibitem
\nobibliography{database}
\endgroup