# Highlighting particular references in .bib file

I have the following sample .tex file

\documentclass{article}
\usepackage{soul}

\begin{document}

This is the file \cite{kang2020energy,pilakkat2019improved,ram2020performance}

\bibliographystyle{IEEEtran}
\bibliography{abc}

\end{document}


The .bib file goes like this

@article{kang2020energy,
title={{Energy systems for climate change mitigation: A systematic review}},
author={{Kang, Jia-Ning and Wei, Yi-Ming and Liu, Lan-Cui and Han, Rong and Yu, Bi-Ying and Wang, Jin-Wei}},
journal={{Applied Energy}},
volume={{263}},
pages={{114602}},
year={{2020}},
publisher={{Elsevier}}
}
@article{pilakkat2019improved,
title={An improved {P}\&{O} algorithm integrated with artificial bee colony for photovoltaic systems under partial shading conditions},
author={Pilakkat, Deepthi and Kanthalakshmi, S},
journal={Solar Energy},
volume={178},
pages={37--47},
year={2019},
publisher={Elsevier}
}
@article{ram2020performance,
title={Performance enhancement of solar {P}{V} systems applying {P}\&{O} assisted Flower Pollination Algorithm ({F}{P}{A})},
author={Ram, J Prasanth and Pillai, Dhanup S and Ghias, Amer MYM and Rajasekar, N},
journal={Solar Energy},
volume={199},
pages={214--229},
year={2020},
publisher={Elsevier}
}


I want to highlight second reference in the reference list. Due to journal requirements, I dont want to change the color of references, rather I specifically want to highlight the complete reference. How can I do that?

• No, that uses biblatex, whereas I am using bibtex. Also, that particular link relates to sorting
– ShJ
Jul 27 '21 at 15:04
• I want to use something which performs same function as \hl{} for a particular reference which is written via bibtex
– ShJ
Jul 27 '21 at 17:47
• No please, this link does not give the solution to that. It just says to change the color of reference to any other color
– ShJ
Jul 28 '21 at 2:19

## 1 Answer

Put the following lines into your preamble:

\newcommand\highlightReference[1]{%
\expandafter\newcommand\csname highlightReference-#1\endcsname{}%
}
\let\oldbibitem\bibitem
\def\bibitem#1 #2\par{%
\expandafter\ifx\csname highlightReference-#1\endcsname\relax
\oldbibitem{#1}#2\par
\else
\oldbibitem{#1}\highlight{#2}\par
\fi
}


Then define the command \highlight{...} the way you want to have your references highlighted. To underline them, use

\usepackage{soul}
\newcommand\highlight[1]{\ul{#}}


If you want to highlight by a yellow background, use

\usepackage{color,soul}
\newcommand\highlight[1]{\hl{#1}}


If you want to highlight by typesetting the words in red, use

\usepackage{color}
\newcommand\highlight[1]{\textcolor{red}{#1}}


The last solution is the most stable one, since the soul package may get into troubles if the highlighted text contains certain commands (error 'reconstruction failed').

\documentclass{article}
\newcommand\highlightReference[1]{%
\expandafter\newcommand\csname highlightReference-#1\endcsname{}%
}
\let\oldbibitem\bibitem
\def\bibitem#1 #2\par{%
\expandafter\ifx\csname highlightReference-#1\endcsname\relax
\oldbibitem{#1}#2\par
\else
\oldbibitem{#1}\highlight{#2}\par
\fi
}
\usepackage{color,soul}
\newcommand\highlight[1]{\hl{#1}}
\begin{document}

This is the file \cite{kang2020energy,pilakkat2019improved,ram2020performance}

\highlightReference{pilakkat2019improved}
\bibliographystyle{IEEEtran}
\bibliography{abc}

\end{document}


\documentclass{article}
\newcommand\highlightReference[1]{%
\expandafter\newcommand\csname highlightReference-#1\endcsname{}%
}
\let\oldbibitem\bibitem
\def\bibitem#1 #2\par{%
\expandafter\ifx\csname highlightReference-#1\endcsname\relax
\oldbibitem{#1}#2\par
\else
\oldbibitem{#1}\highlight{#2}\par
\fi
}
\usepackage{soul}
\newcommand\highlight[1]{\ul{#1}}
\begin{document}

This is the file \cite{kang2020energy,pilakkat2019improved,ram2020performance}

\highlightReference{pilakkat2019improved}
\bibliographystyle{IEEEtran}
\bibliography{abc}

\end{document}


\documentclass{article}
\newcommand\highlightReference[1]{%
\expandafter\newcommand\csname highlightReference-#1\endcsname{}%
}
\let\oldbibitem\bibitem
\def\bibitem#1 #2\par{%
\expandafter\ifx\csname highlightReference-#1\endcsname\relax
\oldbibitem{#1}#2\par
\else
\oldbibitem{#1}\highlight{#2}\par
\fi
}
\usepackage{color}
\newcommand\highlight[1]{\textcolor{red}{#1}}
\begin{document}

This is the file \cite{kang2020energy,pilakkat2019improved,ram2020performance}

\highlightReference{pilakkat2019improved}
\bibliographystyle{IEEEtran}
\bibliography{abc}

\end{document}

• I dont want to underline, I want to highlight during revision of paper
– ShJ
Aug 11 '21 at 15:06
• @ShJ Well, then replace \ul by whatever you want to do to the reference ... Aug 11 '21 at 16:30
• @ShJ I have modified the code to make the highlighting explicit, with examples showing underlining as well as coloring the background in yellow. Aug 11 '21 at 18:11
• Due to soul package reconstruction failed error, I have to use \newcommand\highlight[1]{\hl{\mbox{#1}}}, but, when I use this, the whole highlighted reference spreads across a single column, whereas all other references are in two columns type format. Can you please tell What can be done for this
– ShJ
Aug 20 '21 at 12:13
• @ShJ If you put something into an \mbox command, it will not break across lines, so it is not a surprise that such lines will stick out to the other column (and beyond). I'm afraid there is no general solution, as long as you want to use background coloring. I have added a third option to my answer, coloring the text in red. This should work more reliably than the soul package. Otherwise, if you absolutely need background coloring and the soul package, you have to find out which command in your bibliography leads to the failed reconstruction, and try to do without it. Aug 20 '21 at 14:10