为Bibtex的单一Reference添加颜色

  • Post author:
  • Post category:其他


论文修改会让你为添加的内容做特殊标记,例如标记为蓝色,如何把新添加的引用变蓝呢?网上各种方法,都不太靠谱,终于找到一个靠谱的方法,这里记录一下。



1. 参考


  1. 知乎回答

    。评价:看了半天,不知所云

  2. tex.stackexchange回答

    。评价:

    靠谱、易懂、易实现



2. 实践



myref.bib示例

@article{citeone,
  author = {D. de la Fuente and J.G. Castaño and M. Morcillo},
  title = {Long-term atmospheric corrosion of zinc},
  journal = {Corrosion Science},
  volume = {49},
  year = {2007},
  pages = {1420–1436},
}

@article{citetwo,
  author = {Xaver Zorro},
  title = {Vampires},
}



主文件修改

在主文件中的合适部位添加下述重点代码即可,其中

\newcommand*{\bibitem@citeone}{blue}



\newcommand*{\bibitem@citetwo}{blue}

代表将

citeone



citetwo

代表的reference标记为蓝色。

\usepackage{color} % 使用color包
\begin{document}
...
\makeatletter % 重点代码区开始 <=======================================================
\let\myorg@bibitem\bibitem
\def\bibitem#1#2\par{%
  \@ifundefined{bibitem@#1}{%
    \myorg@bibitem{#1}#2\par
  }{%
    \begingroup
      \color{\csname bibitem@#1\endcsname}%
      \myorg@bibitem{#1}#2\par
    \endgroup
  }%
}
\newcommand*{\bibitem@citeone}{blue}
\newcommand*{\bibitem@citetwo}{blue}
\makeatother % 重点代码区结束 <========================================================
...
\bibliographystyle{IEEEtran}
\bibliography{myref.bib} % 你的bib文件

\end{document}



3. 注意事项

注意被修改颜色的引用的名字中

不能带有数字

,例如:

@article{liu2006toll,
  title={Toll-like receptor triggering of a vitamin D-mediated human antimicrobial response},
  author={Liu, Philip T and Stenger, Steffen and Li, Huiying and Wenzel, Linda and Tan, Belinda H and Krutzik, Stephan R and Ochoa, Maria Teresa and Schauber, Jürgen and Wu, Kent and Meinken, Christoph and others},
  journal={Science},
  volume={311},
  number={5768},
  pages={1770--1773},
  year={2006},
  publisher={American Association for the Advancement of Science}
}

这里,使用

liu2006toll

导致reference不能被着色,可以将其改为

toll

@article{toll,
  title={Toll-like receptor triggering of a vitamin D-mediated human antimicrobial response},
  author={Liu, Philip T and Stenger, Steffen and Li, Huiying and Wenzel, Linda and Tan, Belinda H and Krutzik, Stephan R and Ochoa, Maria Teresa and Schauber, Jürgen and Wu, Kent and Meinken, Christoph and others},
  journal={Science},
  volume={311},
  number={5768},
  pages={1770--1773},
  year={2006},
  publisher={American Association for the Advancement of Science}
}

OK,现在就可以起飞了🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫



版权声明:本文为weixin_44465434原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。