0

In a previous topic (Highlighting particular bibliography entries), the asker was looking for a way to color specific entries.

The solution provided allows for choosing arbitrary color for any desired bibliographic entry using \DeclareBibliographyCategory and \AtEveryBibitem. The entry that we want to be colored may explcictly be specified using \addtocategory The result is something as follows

enter image description here

I want to apply very similar thing except thing that I do not want to specify the color of a bibliographic entry. Instead, I want the entire entry to be highlighted with a specific color

\begin{filecontents*}{sample.bib}
@article{aldaoudeyeh2016,
    title={{Photovoltaic-battery scheme to enhance PV array characteristics in partial shading conditions}},
    author={Aldaoudeyeh, Al-Motasem},
    journal={IET Renewable Power Generation},
    volume={10},
    number={1},
    pages={108--115},
    year={2016},
    publisher={IET}
}
@ARTICLE{wu2017,
    title={{Assessing Impact of Renewable Energy Integration on System Strength Using Site-Dependent Short Circuit Ratio}},
    author={Wu, Di and Li, Gangan and Javadi, Milad and Malyscheff, Alexander M and Hong, Mingguo and Jiang, John Ning},
    journal={IEEE Transactions on Sustainable Energy},
    year={2017},
    publisher={IEEE}
}
@article{wu2019method,
    title={A method to identify weak points of interconnection of renewable energy resources},
    author={Wu, Di and Aldaoudeyeh, Al~Motasem and Javadi, Milad and Ma, Feng and Tan, Jin and Jiang, John N and others},
    journal={International Journal of Electrical Power \& Energy Systems},
    volume={110},
    pages={72--82},
    year={2019},
    publisher={Elsevier}
}
\end{filecontents*}


\documentclass{book}


\usepackage[x11names]{xcolor}

\usepackage{hyperref}
\hypersetup{citecolor=DodgerBlue3, citebordercolor=DodgerBlue3, colorlinks=true}

\usepackage[style=alphabetic]{biblatex}
\addbibresource{sample.bib}

        \DeclareBibliographyCategory{highlight}
        \AtEveryBibitem{%
            \ifcategory{highlight}%
            {\color{SlateBlue3}}%
            {}%
            }

\begin{document}

\addtocategory{highlight}{aldaoudeyeh2016}

\cite{aldaoudeyeh2016}

\nocite{*}

\printbibliography

\end{document}
  • 2
    I'm a bit confused by your question. Is the problem that you want the part in [...] to be highlighted also? Specifying the colour is going to be necessary somehow, so I'm not sure what you mean by saying you don't want to specify the colour yet "highlight with a specific color". – Alan Munn Jun 01 '20 at 18:40
  • By highlighting, I mean to highlight the question such as in \textcolor or \hl command from soul package. However, both commands require an argument – Al-Motasem Aldaoudeyeh Jun 01 '20 at 19:06
  • I have been proven wrong about things like this before, but I'm pretty sure that soul commands will not work, since they only allow a very restricted class of inputs. If you use LuaTeX you can try https://ctan.org/pkg/lua-ul – moewe Jun 02 '20 at 05:42

1 Answers1

1

I it is possible to get soul's highlighter commands working in a biblatex bibliography. soul and ulem are quite restricted in what they can accept as arguments. The code they would get as argument if we managed to pass the whole bibliography entry as an argument to those commands (which is already a non-trivial task), would not be of a form these commands can work with successfully.

With BibTeX your chances are better, because there the bibliography items are basically normal text that is ready to typeset.

See also How to underline whole bibitem in biblatex?. Since that answer was written, Marcel Krüger has released the package lua-ul (cf. for example https://tex.stackexchange.com/a/446488/35864), which makes it easy to reproduce the behaviour of soul's \hl with LuaLaTeX.

The following MWE, which must be run with LuaLaTeX, produces

\documentclass{article}
\usepackage[x11names]{xcolor}
\usepackage[style=alphabetic]{biblatex}
\usepackage{luacolor,lua-ul}
\usepackage[colorlinks]{hyperref}

\DeclareBibliographyCategory{highlight}

\makeatletter
% This relies on the internal definition of \highLight
% in lua-ul.
% It might be safer to define a new \newunderlinetype ourselves.
\newcommand*{\beginHighLight}[1][\luaul@highlight@color]{%
  \luaul@setcolor{#1}%
  \@highLight}
\makeatother

\AtEveryBibitem{%
  \ifcategory{highlight}%
    {\beginHighLight}%
    {}%
}

\addbibresource{biblatex-examples.bib}

\begin{document}
\addtocategory{highlight}{sigfridsson}

\cite{sigfridsson,worman,nussbaum}

\printbibliography
\end{document}

Highlighted bibliography entry

moewe
  • 175,683
  • Is an implementation for xelatex possible? – Al-Motasem Aldaoudeyeh Jun 02 '20 at 12:51
  • @Al-MotasemAldaoudeyeh I don't think so, no. With XeLaTeX your only option is soul, but that can't accept arbitrary input as required here. You could switch to BibTeX as mentioned above and write your own style as in the linked answer. But I don't see a way to get this working with XeLaTeX and biblatex. Most people can probably switch from XeLaTeX to LuaLaTeX without too much difficulty, especially now that HarfBuzz support in LuaLaTeX means that RTL languages (Arabic for example) are much better supported. – moewe Jun 02 '20 at 12:59
  • Thanks. Trying to run this code does not work. It says lua-ul is not found. When I try to search for this package and install it using MiKTeX, it is not shown in the list – Al-Motasem Aldaoudeyeh Jun 02 '20 at 13:39
  • @Al-MotasemAldaoudeyeh There is currently a bug with the MikTeX packaging of lua-ul. https://github.com/MiKTeX/miktex-packaging/issues/180 – moewe Jun 02 '20 at 13:41
  • I searched CTAN for the files. I was not able to find lua-ul.sty, lua-ul.lua, and pre_append_to_vlist_filter.lua – Al-Motasem Aldaoudeyeh Jun 02 '20 at 13:54
  • @Al-MotasemAldaoudeyeh You can generate those files from lua-ul.dtx (which is on CTAN) by running luatex (not lualatex) on it: luatex lua-ul.dtx. – moewe Jun 02 '20 at 13:58
  • I already got lua-ul.dtx. However, I do not really know how to generate the other files. May you help? – Al-Motasem Aldaoudeyeh Jun 02 '20 at 14:00
  • @Al-MotasemAldaoudeyeh As I say: you need to run luatex on the file. This is easiest done from the command line (most editors will probably only run lualatex for you). – moewe Jun 02 '20 at 14:03
  • 1
    @Al-MotasemAldaoudeyeh In case you are still interested in this, just update your MikTeX installation. The MikTeX packaging bug https://github.com/MiKTeX/miktex-packaging/issues/180 has been resolved. – moewe Jun 15 '20 at 06:51