How to highlight text containing citation and figure referencing?
The soul package (\usepackage{soul}
) provides \hl
command for highlighting text. But, \cite
, \ref
are not compatible with \hl
and must be placed within an \mbox
in order for \hl
to work properly. An \mbox
also lets soul see the contents as one item.
You can use the \mbox
.
\hl{\mbox{\cite{roohani2019numerical}}
At the same time if you want to highlight the reference in the bibliography list, you have to annotate the reference within bibliography file. For instance:
@article{roohani2019numerical,
title={\hl{Numerical study and sensitivity analysis on convective heat
transfer enhancement in a heat pipe partially filled with porous material
using LTE and LTNE methods}},
author={\hl{Roohani Isfahani, Seyed N and Salimpour, Mohammad R and Shirani,
Ebrahim}},
journal={\hl{Heat Transfer—Asian Research}},
volume={\hl{48}},
number={\hl{8}},
pages={\hl{4342--4353}},
year={\hl{2019}},
publisher={\hl{Wiley Online Library}}
}
For more information you can refer to soul package documentation: soul package documentation
Related videos on Youtube
KGV
Updated on August 01, 2022Comments
-
KGV over 1 year
I am trying to highlight a text with reference. Without references, the below works fine. Could anyone know how to handle the highlighting the text containing citation and figure references? MWE is given below. Any help is highly appreciated.
\documentclass{article} \usepackage{xcolor} \usepackage{soul} \newcommand{\hlc}[2][yellow]{{% \colorlet{foo}{#1}% \sethlcolor{foo}\hl{#2}}% } \begin{document} \hlc[pink]{hello given by mattsson et al \cite{mattsson1998physical}} \hlc[cyan!50]{hello} \end{document}
-
sheß over 4 yearsI think you might find an answer here tex.stackexchange.com/questions/139463/…
-
sheß over 4 yearswelcome. did it work? consider posting a solution
-
KGV over 4 years@sheß: \hlc[green!50]{The write-up is given and please see the figure \mbox{\ref{fig1}}}. In place of \ref{fig1}, use \cite{mattsson1998physical}. The key is using \mbox to wrap the figures and cites. Thank you
-
-
PLG over 3 yearsIt would be helpful if you provided a little bit of explanation on why this works.
-
Navid Roohani over 3 years
@PLG
Added some explanation. Hope it works for you. -
Navid Roohani over 3 years@PLG Added some explanation. Hope it works for you.
-
PLG over 3 yearsPerfect, thank you! =)