有人知道如何改变参考书目中引用编号的颜色吗?
\documentclass{book}
\usepackage[square, numbers, comma, sort&compress]{natbib} % Use the "Natbib"
\begin{document}
How can I change the cite count number to blue~\cite{ref1}?
\label{References}
\bibliographystyle{unsrtnat} % Use the "unsrtnat" BibTeX style for formatting
\bibliography{Bibliography}
\end{document}
以下是 bib 文件的内容
@article{ref1,
author = {John Clark},
title = {Learn to use Latex},
journal = {Latex Journal},
volume = {1},
number = {1},
year = {2014},
pages = {1-2}
}
我怎样才能将“[1]”更改为蓝色
答案1
我不知道你为什么要这么做,但事实是这样的:
\begin{filecontents*}{\jobname.bib}
@article{ref1,
author = {John Clark},
title = {Learn to use {\LaTeX}},
journal = {{\LaTeX} Journal},
volume = {1},
number = {1},
year = {2014},
pages = {1-2},
}
\end{filecontents*}
\documentclass{book}
\usepackage[square, numbers, comma, sort&compress]{natbib}
\usepackage{xcolor,xpatch}
\makeatletter
\xpatchcmd{\@lbibitem}
{\item[\hfil}
{\item[\hfil\color{red}}
{}{}
\makeatother
\begin{document}
How can I change the cite count number to blue~\cite{ref1}?
\bibliographystyle{unsrtnat} % Use the "unsrtnat" BibTeX style for formatting
\bibliography{\jobname}
\end{document}
该filecontents*
环境只是为了避免破坏我的文件,.bib
照常使用外部文件。red
使用 提供的功能,将其更改为您喜欢的任何颜色xcolor
。
答案2
我不清楚你是否想要引用调用号码设置为蓝色,或者您希望将相应书目条目前面的数字设置为蓝色。
如果您想要的是前者,一个简单的解决方案是加载包hyperref
,将其选项设置colorlinks
为true
,并指定附加选项citecolor=blue
。作为一项单独的(可能非常重要的)好处,引用标注将变成指向相应条目的超链接。
(在下面的 MWE 中,我将文档类从 更改book
为article
纯粹,以便所有输出都可以在同一页面上排版。)
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{Bibliography.bib}
@article{ref1,
author = {John Clark},
title = {Learn to use {\LaTeX}},
journal = {LaTeX Journal},
volume = {1},
number = {1},
year = {2014},
pages = {1-2}
}
\end{filecontents*}
\usepackage[square, numbers, comma, sort&compress]{natbib}
\bibliographystyle{unsrtnat} % Use "unsrtnat" BibTeX style
\usepackage[colorlinks=true,citecolor=blue]{hyperref}
\begin{document}
Now the cite count numbers are typeset in blue in the body of the text: \cite{ref1}
\bibliography{Bibliography}
\end{document}