为Bibtex的单一Reference添加颜色

为Bibtex的单一Reference添加颜色

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

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}代表将citeonecitetwo代表的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,现在就可以起飞了🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫🛫

评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值