![為參考書目中的特定參考文獻著色](https://rvso.com/image/370302/%E7%82%BA%E5%8F%83%E8%80%83%E6%9B%B8%E7%9B%AE%E4%B8%AD%E7%9A%84%E7%89%B9%E5%AE%9A%E5%8F%83%E8%80%83%E6%96%87%E7%8D%BB%E8%91%97%E8%89%B2.png)
在手稿的修訂版本中,我們通常會用彩色文本標記新的更改。這個問題涉及針對.bib
文件中的特定引用執行此操作的不同方法。以前有關於此的解決方案,但它們對我來說並不令人滿意。這個只是做一份參考工作。這裡是透過使用多個巢狀來對前一個引用進行擴展的ifstreqal
。但當彩色參考的數量增加時,這可能變得毫無用處。
我的想法是擁有一個程式碼,它可以取得彩色引用的所有標籤,而不需要使用者參與製作嵌套結構。
其他新的解決方案也受到歡迎。
首先是 MWE。
\documentclass{article}
\usepackage{filecontents}
\usepackage{color}
\usepackage{etoolbox}
\begin{filecontents}{jobname.bib}
@article{greenwade93,
author = "George D. Greenwade",
title = "The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN})",
year = "1993",
journal = "TUGBoat",
volume = "14",
number = "3",
pages = "342--351"
}
@book{goossens93,
author = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
title = "The LaTeX Companion",
year = "1993",
publisher = "Addison-Wesley",
address = "Reading, Massachusetts"
}
@article{fuente,
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{nature,
author = "Rosa Rademakers and Manuela Neumann and Ian R. Mackenzie",
title = "Advances in understanding the molecular basis of frontotemporal dementia - elongated title",
journal = "Nature Reviews Neurology",
volume = "8",
year = "2012",
pages = "423-434",
doi = "10.1038/nrneurol.2012.117",
}
}
\end{filecontents}
\let\mybibitem\bibitem
\renewcommand{\bibitem}[1]{%
\ifstrequal{#1}{greenwade93}
{\color{blue}\mybibitem{#1}}
{\color{black}\mybibitem{#1}}%
}
\begin{document}
This is my document \cite{fuente} and we have another \cite{nature}. We can speak also about \LaTeX! So two more reference are \cite{greenwade93} and \cite{goossens93}
\bibliographystyle{ieeetr}
\bibliography{jobname}
\end{document}
答案1
使用 biblatex/biber 可以輕鬆標記參考文獻:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage[style=ieee]{biblatex}
\addbibresource{biblatex-examples.bib}
\DeclareBibliographyCategory{changed}
\addtocategory{changed}{doody,angenendt}
\AtEveryBibitem{\ifcategory{changed}{\color{red}}{}}
\DeclareFieldFormat{labelnumberwidth}{\ifcategory{changed}{\textcolor{green}{\mkbibbrackets{#1}}}{\mkbibbrackets{#1}}}
\begin{document}
\cite{doody,herrmann,angenendt}
\printbibliography
\end{document}