只有引用的年份是彩色的

只有引用的年份是彩色的

我只想要蓝色的引文年份,而不是现在的所有内容。

乳胶

\documentclass[a4paper,10pt]{article}

\usepackage{natbib}
\usepackage{apalike}

\usepackage{hyperref}
\hypersetup{
    hidelinks=false,             
    colorlinks=true,
    citecolor=blue
}

\begin{document}
    
    This is an example of ... \citep{author1}.
    
    \bibliographystyle{apalike}
    \bibliography{Bibliography}
\end{document} 

参考书目.bib

@book{author1,
  title={Book Title},
  author={Author},
  year={2014},
  publisher={Publisher}
}

答案1

花费了一些时间来找到正确的\NAT@hyper@补丁调用。

\begin{filecontents*}{\jobname.bib}
@book{author1,
  title={Book Title},
  author={Author},
  year={2014},
  publisher={Publisher}
}
\end{filecontents*}

\documentclass[a4paper,10pt]{article}

\usepackage{natbib}
\usepackage{apalike}
\usepackage{xpatch}

\usepackage{hyperref}
\hypersetup{
    %hidelinks,
    colorlinks=true,
    citecolor=blue
}

\makeatletter
\xpatchcmd\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}%
 }
 {}{}
\xpatchcmd\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}

This is an example of ... \citep{author1}.
    
This is an example of ... \citet{author1}.
    
\bibliographystyle{apalike}
\bibliography{\jobname}

\end{document} 

在此处输入图片描述

相关内容