输出:

输出:

我想要书目列表中的特定参考文献采用不同的颜色,例如蓝色。这些是一些最低限度的工作示例。

这是我的乳胶文件:

\documentclass{article}
\usepackage{color}
\usepackage{cite}
\begin{document} 
This is my document \cite{fuente} and we have another \cite{nature}
\bibliographystyle{ieeetr}
\bibliography{myreference} 
\end{document}

这是 bibtex 文件:

//myReference.bib file

@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 = {\color{blue}Rosa Rademakers and Manuela Neumann and Ian R. Mackenzie}}, 
title = {\color{blue}Advances in understanding the molecular basis of frontotemporal dementia - elongated title}}, 
journal = {\color{blue} {Nature Reviews Neurology}}, 
volume = {\color{blue}{8}}, 
year = {\color{blue}{2012}}, 
pages = {\color{blue}{423-434}}, 
doi = {\color{blue}{10.1038/nrneurol.2012.117}},
} 

PDF 输出

我只想让第一个引用为蓝色。如何实现?

查找以下更新的 tex 文件:

\documentclass{article}
\usepackage{color}
\usepackage{cite}
\usepackage{etoolbox}

\renewcommand{\bibitem}[1]{%
\ifstrequal{#1}{nature}
{\color{blue}\mybibitem{#1}}
{\color{black}\mybibitem{#1}}%
}
\begin{document} 
This is my document \cite{fuente} and we have another \cite{nature}
\bibliographystyle{ieeetr}
\bibliography{myReference} 
\let\mybibitem\bibitem

\end{document}

答案1

\color{xxx}是一个改变文本颜色的开关,它适用于其后的文本(在组中)。但是,\bibitem不设置组。这样,颜色就会传播到设置颜色的条目后面的项目。

这是一个简单的 hack,可以实现 OP 的结果(它使用包toolbox,即\usepackage{etoolbox}

\let\mybibitem\bibitem
\renewcommand{\bibitem}[1]{%
  \ifstrequal{#1}{nature}
    {\color{blue}\mybibitem{#1}}
    {\color{black}\mybibitem{#1}}%
}

在此处输入图片描述

答案2

我发现一个简单的——完全hackish - 为特定项目着色的方法。

只需在结果文件中找到您想要着色的参考中写的最后一件事并在\color{black}其后面放置一个,这样参考之后的所有内容就不会被不同的颜色绘制。

此技巧有两个版本:

  1. 放在\color{blue}参考文献的第一个子项之后和\color{black}最后一个子项之后。在你的例子中,第一个子项是作者,最后一个子项是年份,所以你的 bibfile 将如下所示(注:我添加了另一个参考文献来测试效果):

    @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{test2, 
      author = {Zhu Zimmermann}, 
      title = {The glory of the letter Z}, 
      journal = {Alphanumeric Characters}, 
      volume = {99}, 
      year = {1999}, 
      pages = {199-299},
    }
    @article{nature, 
      author = {\color{blue}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\color{black}}, 
      pages = {423-434}, 
      doi = {10.1038/nrneurol.2012.117},
    }
    

    结果将是这样的:

在此处输入图片描述

  • 优点:不需要针对字符串内容进行测试,因此可以轻松地应用于许多不相关的项目中。
  • 缺点:编号不会与参考一起绘制

如果你需要数字具有相同的颜色,你可以尝试这个:

  1. 不要把 放在\color{blue}你想要着色的引用的第一个子项中,而是放在引用的最后一个子项中紧邻上方您的参考资料 - 在结果文件中,而不是在 bib 文件中。这样,数字将与文本一起绘制。这将是您的 bib 文件:

    @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\color{blue}}, 
      pages = {1420–1436},
    }
    @article{test2, 
      author = {Zhu Zimmermann}, 
      title = {The glory of the letter Z}, 
      journal = {Alphanumeric Characters}, 
      volume = {99}, 
      year = {1999}, 
      pages = {199-299},
    }
    @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\color{black}}, 
      pages = {423-434}, 
      doi = {10.1038/nrneurol.2012.117},
    }
    

    结果如下:

在此处输入图片描述

  • 优点:编号将与参考一起绘制
  • 缺点:项目不是独立于其他项目的,因此如果添加另一个项目,则可能需要更改放置的位置\color{blue}

答案3

输出:

在此处输入图片描述

我试图在这里合并原始答案:

  1. https://tex.stackexchange.com/a/242055/285518
  2. https://tex.stackexchange.com/a/26873

在main.tex中:

\documentclass{article}
% ====================
% show blue for the specific references whose marker has a substring "RefBlue"
% This section should be put together with other "\usepackage", and xcolor, xparse, etoolbox are needed
% Note: for all the markers of used references, only use the letter or number: \cite{36_942} would cause some errors
% usage: \cite{RefBlueMyRef1} or \cite{MyRef2RefBlue}
\usepackage{xparse}
\usepackage{etoolbox}
\usepackage{xcolor}
\ExplSyntaxOn
\NewDocumentCommand{\instringTF}{mmmm}
{\oleks_instring:nnnn { #1 } { #2 } { #3 } { #4 }}
\tl_new:N \l__oleks_instring_test_tl
\cs_new_protected:Nn \oleks_instring:nnnn
{
    \tl_set:Nn \l__oleks_instring_test_tl { #1 }
    \regex_match:nnTF { \u{l__oleks_instring_test_tl} } { #2 } { #3 } { #4 }
}
\ExplSyntaxOff
\let\mybibitem\bibitem
\renewcommand{\bibitem}[1]{%
    \instringTF{RefBlue}{#1}
    {\color{blue}\mybibitem{#1}}
    {\color{black}\mybibitem{#1}}%
}
% ====================

\begin{document}



first ref for blue \cite{myRef1RefBlue}, second ref for black \cite{myRef2}
\bibliography{mybib}
\bibliographystyle{plain}

\end{document}

然后在mybib.bib中:

@article{myRef1RefBlue,
    author = {myRef1RefBlue},
    title = {test for blue},
    journal = {Test},
    volume = {74},
    pages = {17-29},
    year = {2018},
}

@article{myRef2,
    author = {myRef2},
    title = {test for black},
    journal = {Test},
    volume = {74},
    pages = {17-29},
    year = {2018},
}

相关内容