1

I wanted all in-text citations in a different color to make them stand out from the text. I used a solution provided by following link.
Color citation using biblatex : in-text + references (issue with postnote + bibliography) In particular, I used \AtEveryCite command. The closing parenthesis is also colored blue. However, the period mark when the references are at the end of a sentence should be black, but above commands makes them blue. Any way to fix this minor glitch? Thanks. Jay

MWE

\documentclass[a4paper, oneside, 12pt]{memoir}
\usepackage[backend=bibtex, %bibtex worked well
style=authoryear-comp, %nature for numbered style
sorting=nyt, % cite according to author's last name,year and title.
maxbibnames=3]{biblatex} 

\addbibresource{biblatex-examples.bib}
\usepackage[table,xcdraw,dvipsnames]{xcolor} % colouring of raws and also for R code grey background
\definecolor{bleu_cite}{RGB}{34,111,212} % pure blue: {0,0,128}, light blue:{80,135,208}
\usepackage[
colorlinks=true,        
allcolors = black,  
citecolor=bleu_cite,        
]{hyperref} 
\AtEveryCite{\color{bleu_cite}}

\begin{document}
     This is a borrowed fact \parencite{aristotle:physics}. 

\end{document}
6
  • Unrelated: The 12 pt should probably be 12pt (no space).
    – Johannes_B
    Commented Aug 13, 2017 at 5:40
  • 2
    \AtEveryCiteKey is commented in moewe's code and \mkbibbracketscol is introduced. The example given by moewe does not have coloured periods. Please test his example to confirm.
    – Johannes_B
    Commented Aug 13, 2017 at 5:54
  • Thanks Johannes :) Yes, his command works, as in the periods are in black. However, some references disappear and there is extra spaces between references - both are risky when revising a thesis. Therefore, I won't be chasing this option further, but it could work with tweaking.
    – Jay
    Commented Aug 13, 2017 at 8:37
  • You would need to show the extra spaces in the example to get help.
    – Johannes_B
    Commented Aug 13, 2017 at 8:38
  • If you found a problem with my solution I would be grateful for an example that shows the problem. Note that you use a vastly different style to the one in the other question, so you can't just copy the \DeclareCiteCommand you will have to adapt those in authoryear-comp.
    – moewe
    Commented Aug 13, 2017 at 12:18

1 Answer 1

3

By default biblatex scans ahead for punctuation after a citation to avoid double punctuation. This means that biblatex 'takes over' printing punctuation directly after the citation. You can turn off this feature with

autopunct=false

Then you can continue to use \AtEveryCite{\color{bleu_cite}}.


But you can also use the \DeclareCiteCommand approach from Color citation using biblatex : in-text + references (issue with postnote + bibliography). You will have to modify this for your style, though.

\newcommand{\mkbibparenscol}[1]{\textcolor{bleu_cite}{\mkbibparens{#1}}}

\DeclareCiteCommand{\cite}[\textcolor{bleu_cite}]
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\parencite}[\mkbibparenscol]
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {}
  {\usebibmacro{postnote}}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .