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ß
    Commented Feb 26, 2019 at 14:13
  • 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
    – Gopalpur
    Commented Mar 3, 2019 at 14:50

3 Answers 3


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

  • Thanks a lot! I have been looking for something like \mbox{} and couldn't recall what it was called.
    – psyguy
    Commented Apr 10, 2023 at 17:31
  • \mbox will prevent line breaks within longer citations and possibly lead to overfull hboxes. Commented Jul 16 at 21:12

You could use the lua-ul package for highlighting. This way you don't have to worry about citations or cross-references in your text:

% !TeX TS-program = lualatex



    author = {Einstein, A.},
    title = {{Die Grundlage der allgemeinen Relativitätstheorie}},
    journal = {Annalen der Physik},
    volume = {354},
    number = {7},
    doi = {10.1002/andp.19163540702},
    pages = {769--822},
    year = {1916}



\highLight[red]{hello given by mattsson et al \cite{einstein} and Figure~\ref{fig}.}




enter image description here


You can use the soul package (\usepackage{soul}), and make the reference or the citation between curly braces inside of the \hl command:

\hl{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Curabitur dictum {\cite{your citation}} or {\ref{your reference}} gravida mauris.} 
  • Cicilio's answer already explains how to use soul and \hl and also explains how to solve the issue using \hl with \cite. So IMHO this unfortunately is not really a useful new answer.
    – cabohah
    Commented Dec 5, 2023 at 18:03
  • @cabohah The {...} approach seems to have not yet been covered in the other answer and might actually be more flexible in certain situations. Commented Dec 5, 2023 at 19:10
  • @samcarter_is_at_topanswers.xyz The only difference here is, that instead of \mbox only braces are used. Sorry, but IHMO this is at most a comment to the existing answer than a new one.
    – cabohah
    Commented Dec 6, 2023 at 7:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .