我发现了和定位书目中的引用部分的功能之间的一个natbib
错误。sort&compress
backrefalt
以下是重现错误的简短模板:
\documentclass[11pt]{article}
\usepackage[square,comma,numbers,sort&compress]{natbib}
\usepackage[breaklinks=true,pagebackref]{hyperref}
\renewcommand*{\backref}[1]{}
\renewcommand*{\backrefalt}[4]{
\ifcase #1 %
(Not cited.) %
\or
{(Referenced on page #2.)}%
\else
{(Referenced on pages #2.)}%
\fi
}
\renewcommand*{\backrefsep}{, }
\renewcommand*{\backreftwosep}{ and }
\renewcommand*{\backreflastsep}{, and }
\begin{document}
\cite{cite1,cite2,cite3}
\bibliographystyle{plainnat}
\bibliography{my}
\end{document}
cite1,cite2,cite3
假设在 中有三次连续引用my.bib
。结果将显示为[1-3],并且引文 2 将显示为(未引用)。
我从切换到sort&compress
以sort
避免这个错误,但是有没有办法同时获得压缩和正确的反向引用?
答案1
你可以尝试这个补丁:
\documentclass[11pt]{article}
\usepackage[square,comma,numbers,sort&compress]{natbib}
\usepackage[breaklinks=true,pagebackref]{hyperref}
\renewcommand*{\backref}[1]{}
\renewcommand*{\backrefalt}[4]{
\ifcase #1 %
(Not cited.) %
\or
{(Referenced on page #2.)}%
\else
{(Referenced on pages #2.)}%
\fi
}
\renewcommand*{\backrefsep}{, }
\renewcommand*{\backreftwosep}{ and }
\renewcommand*{\backreflastsep}{, and }
\usepackage{etoolbox}
\makeatletter
\patchcmd\NAT@citexnum{\let\NAT@last@num\NAT@num}{\MakeLinkTarget[cite]{}\Hy@backout{\@citeb\@extra@b@citeb}\let\NAT@last@num\NAT@num}{}{\fail}
\makeatother
\begin{document}
\cite{doody,herrmann,angenendt}
\bibliographystyle{plainnat}
\bibliography{biblatex-examples}
\end{document}