使用 apacite,仅需要指定日期引用中的年份链接

使用 apacite,仅需要指定日期引用中的年份链接

我正在使用 apacite 包获取具有作者年份引用样式的参考文献。我只需要年份的链接。如何实现?

梅威瑟:

\documentclass{article}

\usepackage{hyperref}

\usepackage[natbibapa]{apacite}

\begin{document}

\noindent

See \verb+\citep{Adams2004}+ - \citep{Adams2004}\\

\verb+\citet{Adams2004}+ - \citet{Adams2004}\\

\verb+\citeyear{Adams2004}+ - \citeyear{Adams2004}\\

\verb+\citeauthor{Adams2004}+ - \citeauthor{Adams2004}\\

\verb+\citealp{Adams2004}+ - (\citealp{Adams2004}).

\begin{thebibliography}{}

\bibitem[\protect\citeauthoryear{Adams, Graf, {\&} Ernst}{Adams et al.}{2004}]{Adams2004}
Adams, W. J., Graf, E. W., \& Ernst, M. O. (2004). Experience can change the `light-from-above' prior.
Nature Neuroscience, Volume 7 (10), 1057--1058. doi: \url{https://doi.org/10.1038/nn1312}

\end{thebibliography}

\end{document}

输出:

使用 apacite 的电流输出

答案1

我从以下链接得到了答案: 使用 natbib 和 hyperref 时如何仅超链接年份部分

输入:

\documentclass{article}

\usepackage{hyperref}

\usepackage[natbibapa]{apacite}

\usepackage{etoolbox}

\makeatletter

\let\oldciteauthor\citeauthor

\def\citeauthor#1{{\NoHyper\oldciteauthor{#1}}}

% Patch case where name and year are separated by aysep
\patchcmd{\NAT@citex}
  {\@citea\NAT@hyper@{%
     \NAT@nmfmt{\NAT@nm}%
     \hyper@natlinkbreak{\NAT@aysep\NAT@spacechar}{\@citeb\@extra@b@citeb}%
     \NAT@date}}
  {\@citea\NAT@nmfmt{\NAT@nm}%
   \NAT@aysep\NAT@spacechar\NAT@hyper@{\NAT@date}}{}{}

% Patch case where name and year are separated by opening bracket
\patchcmd{\NAT@citex}
  {\@citea\NAT@hyper@{%
     \NAT@nmfmt{\NAT@nm}%
     \hyper@natlinkbreak{\NAT@spacechar\NAT@@open\if*#1*\else#1\NAT@spacechar\fi}%
       {\@citeb\@extra@b@citeb}%
     \NAT@date}}
  {\@citea\NAT@nmfmt{\NAT@nm}%
   \NAT@spacechar\NAT@@open\if*#1*\else#1\NAT@spacechar\fi\NAT@hyper@{\NAT@date}}
  {}{}

\makeatother

\begin{document}

\noindent 

See \verb+\cite{Adams2004}+ - \cite{Adams2004}\\ 

\verb+\citep{Adams2004}+ - \citep{Adams2004}\\ 

\verb+\citet{Adams2004}+ - \citet{Adams2004}\\

\verb+\citeyear{Adams2004}+ - \citeyear{Adams2004}\\

\verb+\citeauthor{Adams2004}+ - {\citeauthor{Adams2004}}\\

\verb+\citealp{Adams2004}+ - (\citealp{Adams2004}).

\begin{thebibliography}{}

\bibitem[\protect\citeauthoryear{Adams, Graf, {\&} Ernst}{Adams et al.}{2004}]{Adams2004}
Adams, W. J., Graf, E. W., \& Ernst, M. O. (2004). Experience can change the `light-from-above' prior.
Nature Neuroscience, Volume~7 (10), 1057--1058. doi: \url{https://doi.org/10.1038/nn1312}

\end{thebibliography}

\end{document}

输出:

仅限一年的链接

相关内容