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.





\hlc[pink]{hello given by mattsson et al \cite{mattsson1998physical}}


  • I think you might find an answer here tex.stackexchange.com/questions/139463/… – sheß Feb 26 '19 at 14:13
  • welcome. did it work? consider posting a solution – sheß Feb 28 '19 at 10:26
  • 2
    @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 – KGV Mar 3 '19 at 14:50

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.


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:

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, 
journal={\hl{Heat Transfer—Asian Research}},
publisher={\hl{Wiley Online Library}}

For more information you can refer to soul package documentation: soul package documentation

| improve this answer | |
  • 1
    It would be helpful if you provided a little bit of explanation on why this works. – PLG May 12 at 5:22
  • 1
    @PLG Added some explanation. Hope it works for you. – Navid Roohani May 13 at 23:16
  • @PLG Added some explanation. Hope it works for you. – Navid Roohani May 13 at 23:17
  • Perfect, thank you! =) – PLG May 14 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.