1

i was searching for the past hour and couldnt find an answer. I'm using the cite{} command and its working nicely ofc. But I would like to make a small modification. When my reference appears in the text, the reference number inside the square brackets should have a specified color. How can I achive this (please see attached picture below)? Only the inner number should be colored and the outer brackets should stay black. Any help is appreciated, thank you very much.

EDIT: So far im using the following method to create my document.

Like this

% main tex-file
\documentclass[a4paper,11pt]{memoir}
\usepackage[style=numeric, backend=biber, backref, sorting=none]{biblatex}
\addbibresource{bib/bibfile.bib}

\begin{document}
This is a test \cite{ref1}.

\printbibliography
\end{document}


% bib/bibfile.bib
@CONFERENCE{ref1,
  author = {Hans Neumann},
  title = {title},
  booktitle = {book title},
  year = {1998}
}
  • Posibly duplicate of tex.stackexchange.com/questions/224568/… – user170109 May 16 at 2:10
  • I'm primarily interested in colouring the reference numbers in my text and not necessarily in my list. – Henry May 16 at 2:16
  • 1
    Should the citation callouts also be made into hyperlinks to the associated bib entries? – Mico May 16 at 2:35
  • Can you please tell us which bibliography/citation package you are using? A solution for biblatex will be wildly different from a solution for natbib. The specific style you use also plays a role, so it would be great if you could show us a short example document (a so-called MWE: tex.meta.stackexchange.com/q/228) that reproduces the status quo. You may also want to clarify if you use hyperref. By default citations are usually linked with hyperref and if you give the correct options citations will automatically be coloured (though that colouring might not survive printing) – moewe May 16 at 4:20
  • It would be easier to understand what you wanted if you added minimal working example to show what you are using bibtex or biblatex etc. – Andrew May 16 at 11:44
1

One way is to use hyperref, which has the added benefit of turning your citations etc into hyperlinks in the PDF file. By adding the lines

\usepackage{hyperref}
\hypersetup{colorlinks=true, citecolor=green}

to the end of your preamble (hyperref likes being loaded last), your MWE produces:

enter image description here

although you pmight want a different shade of green:) Here is the full code:

% main tex-file
\documentclass[a4paper,11pt]{memoir}
\usepackage[style=numeric, backend=biber, backref, sorting=none]{biblatex}
\addbibresource{bibfile.bib}

% to generate the bibfile
\usepackage{filecontents}
\begin{filecontents}{bibfile.bib}
@CONFERENCE{ref1,
  author = {Hans Neumann},
  title = {title},
  booktitle = {book title},
  year = {1998}
}
\end{filecontents}

\usepackage{hyperref}
\hypersetup{colorlinks=true, citecolor=green}

\begin{document}
This is a test \cite{ref1}.

\printbibliography
\end{document}
0

A big thank you to Andrew who posted an answer that solves my problem.

However, I also managed to get another solution as well (although Andrew's answer seems more elegant). This question helped me: Link

\documentclass[a4paper,11pt]{memoir}
\usepackage[style=numeric, backend=biber, backref, sorting=none, labelnumber]{biblatex}
\addbibresource{bib/bibfile.bib}

% using labelnumber
\DeclareCiteCommand{\citenum}
  {}
  {\printfield{labelnumber}}
  {}
  {}

% defining a new custom command with desired color:
\newcommand\mycite[1]{[\textcolor{green}{\citenum{#1}}]}

\begin{document}
This is a test \mycite{ref1}.
% and i get the same output as Andrew! :D

\printbibliography
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.