amsrefs 包中的超链接缺少最后一个括号

amsrefs 包中的超链接缺少最后一个括号

看起来像是一个错误,我想修复它但失败了。我将通过以下 MME 描述该问题:

\documentclass{amsart}
\usepackage[colorlinks,citecolor=cyan]{hyperref}
\usepackage[author-year]{amsrefs}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article {MotazedifardDalafiNaderiRoknizadeh2018Controllable,
    AUTHOR = {Motazedifard, Ali and Dalafi, A. and Naderi, M. H. and
              Roknizadeh, R.},
     TITLE = {Controllable generation of photons and phonons in a coupled
              {B}ose--{E}instein condensate-optomechanical cavity via the
              parametric dynamical {C}asimir effect},
   JOURNAL = {Ann. Physics},
  FJOURNAL = {Annals of Physics},
    VOLUME = {396},
      YEAR = {2018},
     PAGES = {202--219},
      ISSN = {0003-4916},
   MRCLASS = {81},
  MRNUMBER = {3853390},
       DOI = {10.1016/j.aop.2018.07.013},
       URL = {https://doi.org/10.1016/j.aop.2018.07.013},
}
\end{filecontents}
\begin{document}
In \ocite{MotazedifardDalafiNaderiRoknizadeh2018Controllable}, \citeauthor{MotazedifardDalafiNaderiRoknizadeh2018Controllable} show that ...
\bibliography{\jobname}
\end{document}

编译结果如下: MME PDF 据说这种颜色只适用于“在 Motazedifard 等人中。 (2018 年)“,为什么最后”“失色了?

答案1

我认为我在一些教科书中看到过这种错误的颜色,现在我确信这是软件包中的一个错误amsrefs。但是(我可能错了),值得指出的是,预期的行为应该是“使用黑色/正常颜色的括号,同时作者和年份是彩色的”,而不是“缺少最后一个右括号”。您可以通过键入来检查这一点

\cite{MotazedifardDalafiNaderiRoknizadeh2018Controllable}

这将产生一对黑色括号。

我可以提供一个修复程序,强制将左括号变为黑色。

\documentclass{amsart}
\usepackage[colorlinks,citecolor=cyan]{hyperref}
\usepackage[author-year]{amsrefs}

\makeatletter
\renewcommand*\citesel@object[5]{\PrintCiteNames{#3} \textcolor{black}{\citeleft}#4}
% The original definition is
% \def\citesel@object#1#2#3#4#5{\PrintCiteNames{#3} \citeleft#4}
% which misses the possible color change by hyperref
\makeatother

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article {MotazedifardDalafiNaderiRoknizadeh2018Controllable,
    AUTHOR = {Motazedifard, Ali and Dalafi, A. and Naderi, M. H. and
              Roknizadeh, R.},
     TITLE = {Controllable generation of photons and phonons in a coupled
              {B}ose--{E}instein condensate-optomechanical cavity via the
              parametric dynamical {C}asimir effect},
   JOURNAL = {Ann. Physics},
  FJOURNAL = {Annals of Physics},
    VOLUME = {396},
      YEAR = {2018},
     PAGES = {202--219},
      ISSN = {0003-4916},
   MRCLASS = {81},
  MRNUMBER = {3853390},
       DOI = {10.1016/j.aop.2018.07.013},
       URL = {https://doi.org/10.1016/j.aop.2018.07.013},
}
\end{filecontents}
\begin{document}
In \ocite{MotazedifardDalafiNaderiRoknizadeh2018Controllable}, \citeauthor{MotazedifardDalafiNaderiRoknizadeh2018Controllable} show that ...
\bibliography{\jobname}
\end{document}

颜色固定


也可以强制将右括号变为青色,如下所示:

\documentclass{amsart}
\usepackage[colorlinks,citecolor=cyan]{hyperref}
\usepackage[author-year]{amsrefs}

\usepackage{etoolbox}
\makeatletter
\patchcmd\cite@cj
  {\citeright}
  {\textcolor{cyan}\citeright}
  {}{}
\makeatother

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article {MotazedifardDalafiNaderiRoknizadeh2018Controllable,
    AUTHOR = {Motazedifard, Ali and Dalafi, A. and Naderi, M. H. and
              Roknizadeh, R.},
     TITLE = {Controllable generation of photons and phonons in a coupled
              {B}ose--{E}instein condensate-optomechanical cavity via the
              parametric dynamical {C}asimir effect},
   JOURNAL = {Ann. Physics},
  FJOURNAL = {Annals of Physics},
    VOLUME = {396},
      YEAR = {2018},
     PAGES = {202--219},
      ISSN = {0003-4916},
   MRCLASS = {81},
  MRNUMBER = {3853390},
       DOI = {10.1016/j.aop.2018.07.013},
       URL = {https://doi.org/10.1016/j.aop.2018.07.013},
}
\end{filecontents}
\begin{document}
In \ocite{MotazedifardDalafiNaderiRoknizadeh2018Controllable}, \citeauthor{MotazedifardDalafiNaderiRoknizadeh2018Controllable} show that ...
\bibliography{\jobname}
\end{document}

颜色交替固定

相关内容