1

I would like to color in red specific citations in bibliography section (let's say Jahani et al.) using the apa6 class and the apacite package.

Here is my .tex file:

\documentclass[a4paper,man,noextraspace,apacite]{apa6}
\usepackage[utf8]{inputenc}
\usepackage[utf8]{inputenc}

\title{Title of the Study}

\begin{document}
\maketitle

I want to color \citeA{jahani2018motion} in red in bibliography section. However, I want \citeA{drenckhahn2015validation} and \citeA{magistretti1999energy} to remain in black.

\bibliography{references}

\end{document}

And here is my .bib file:

@article{drenckhahn2015validation,
  title={A validation study of the use of near-infrared spectroscopy imaging in primary and secondary motor areas of the human brain},
  author={Drenckhahn, Christoph and Koch, Stefan P and D{\"u}mmler, Johannes and Kohl-Bareis, Matthias and Steinbrink, Jens and Dreier, Jens P},
  journal={Epilepsy \& Behavior},
  doi={10.1016/j.yebeh.2015.04.006},
  volume={49},
  pages={118--125},
  year={2015},
  publisher={Elsevier}
}

@article{jahani2018motion,
  title={Motion artifact detection and correction in functional near-infrared spectroscopy: {A} new hybrid method based on spline interpolation method and {S}avitzky--{G}olay filtering},
  author={Jahani, Sahar and Setarehdan, Seyed K and Boas, David A and Y{\"u}cel, Meryem A},
  journal={Neurophotonics},
  doi={10.1117/1.NPh.5.1.015003},
  volume={5},
  number={1},
  pages={1--11},
  year={2018},
  publisher={International Society for Optics and Photonics}
}

@article{magistretti1999energy,
  title={Energy on demand},
  author={Magistretti, Pierre J and Pellerin, Luc and Rothman, Douglas L and Shulman, Robert G},
  journal={Science},
  doi={10.1126/science.283.5401.496},
  volume={283},
  pages={496--497},
  year={1999},
  publisher={American Association for the Advancement of Science}
}

Can someone help me?

  • Related: https://tex.stackexchange.com/q/327357/35864, https://tex.stackexchange.com/q/242042/35864, https://tex.stackexchange.com/q/414758/35864, – moewe Jul 30 '19 at 15:37
  • Thank you @moewe, I saw them, but the suggested solutions do not work for apacite... – Ségolène Guérin Jul 31 '19 at 09:41

1 Answers1

2

Taking Ulrike Fischer's answer to Coloring References, but extending it to items with an explicit label we get

\documentclass[a4paper,man,noextraspace,apacite]{apa6}
\usepackage[utf8]{inputenc}

\usepackage{xcolor}
\usepackage{etoolbox}
\makeatletter
\apptocmd\@bibitem{\color{black}\csname keycolor#1\endcsname}{}{\fail}
\apptocmd\@lbibitem{\color{black}\csname keycolor#2\endcsname}{}{\fail}
\newcommand\citecolor[2][red]{\@namedef{keycolor#2}{\color{#1}}}
\makeatother

\citecolor[blue]{jahani2018motion}

\shorttitle{Study}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{drenckhahn2015validation,
  title   = {A validation study of the use of near-infrared spectroscopy
             imaging in primary and secondary motor areas of the human brain},
  author  = {Drenckhahn, Christoph and Koch, Stefan P. and D{\"u}mmler, Johanne
             and Kohl-Bareis, Matthias and Steinbrink, Jens and Dreier, Jens P.},
  journal = {Epilepsy \& Behavior},
  doi     = {10.1016/j.yebeh.2015.04.006},
  volume  = {49},
  pages   = {118--125},
  year    = {2015},
}
@article{jahani2018motion,
  title   = {Motion artifact detection and correction in functional
             near-infrared spectroscopy:
             {A} new hybrid method based on spline interpolation method
             and {S}avitzky--{G}olay filtering},
  author  = {Jahani, Sahar and Setarehdan, Seyed K. and Boas, David A.
             and Y{\"u}cel, Meryem A.},
  journal = {Neurophotonics},
  doi     = {10.1117/1.NPh.5.1.015003},
  volume  = {5},
  number  = {1},
  pages   = {1--11},
  year    = {2018},
}
@article{magistretti1999energy,
  title   = {Energy on demand},
  author  = {Magistretti, Pierre J. and Pellerin, Luc and Rothman, Douglas L.
             and Shulman, Robert G.},
  journal = {Science},
  doi     = {10.1126/science.283.5401.496},
  volume  = {283},
  pages   = {496--497},
  year    = {1999},
}
\end{filecontents}

\begin{document}
I want to color \citeA{jahani2018motion} in red in bibliography section
However, I want \citeA{drenckhahn2015validation}
and \citeA{magistretti1999energy} to remain in black.

\bibliography{\jobname}
\end{document}

References with <code>jahani2018motion</code> highlighted in blue.

\citecolor can be issued anywhere before \bibliography. The command has two arguments. The optional (first) argument is the colour, the mandatory (second) argument the key of the entry to be highlighted.

moewe
  • 175,683