# How to highlight citations in a revised manuscript

I am submitting a revised manuscript to a journal (Medical Physics), and the journal requires that changes that are made in the revised manuscript should be highlighted. I've been attempting to use the soul package with the \hl command, but it seems that there is a known bug where you can't highlight citations. (You get a compilation error.) I have found some workarounds, but they don't seem to work for multiple citations like this: \cite{rockafellar1997convex,rudin1992nonlinear}. Also, the workarounds seem ugly, and I don't want to submit a latex file contaminated with ugly hacks for highlighting that the editors will not understand.

How do people handle this? It must be a common issue.

Should I just highlight the pdf using Adobe Acrobat and then submit a highlighted version of the pdf along with my latex file? I'm not sure that the journal will accept that -- they may want to receive just one manuscript that has the highlighting built in, rather than a manuscript and a separate pdf with highlighting.

Here is a minimal working example:

\documentclass[aapm,graphicx,preprint,showkeys]{revtex4-1}
\usepackage{amsmath,amssymb,enumitem,mathtools}
\usepackage{xcolor}
\usepackage{soul}

\begin{document}

\hl{This text is highlighted}.

Here's a citation \cite{rockafellar1997convex,rudin1992nonlinear}.

%\hl{ Highlighting a citation causes a compilation error \cite{rockafellar1997convex,rudin1992nonlinear}. }

\begin{thebibliography}{10}

\bibitem{rockafellar1997convex}
R.T. Rockafellar.
\newblock {\em Convex analysis}.
\newblock Number~28. Princeton university press, 1997.

\bibitem{rudin1992nonlinear}
L.~Rudin, S.~Osher, and E.~Fatemi.
\newblock Nonlinear total variation based noise removal algorithms.
\newblock {\em Physica D: Nonlinear Phenomena}, 60(1):259--268, 1992.

\end{thebibliography}

\end{document}

• Pragmatic solution: Just use another, less fragile sort of highlighting, e.g., text color: \renewcommand{\hl}[1]{\color{red}#1}. Oct 26 '16 at 9:29
• @Daniel Thanks, very helpful. This command seems to change the color of all text in the manuscript after the command is given. Do I also need a separate command to switch back to the normal text color? Would you mind submitting an answer to show exactly how you would fix the MWE? Oct 26 '16 at 9:44
• @Daniel There should be a pair of braces to limit the effect of \color: \renewcommand{\hl}[1]{{\color{red}#1}}. Oct 26 '16 at 9:52
• @gernot: Upps, you're right of course. Hasty comments :-) Oct 26 '16 at 15:24
• @littleO: Added corrected version as an answer Oct 26 '16 at 15:38

I don't know your other reasons for using the soul package, but doesn't the xcolor package suffice? Moreover, if I read the author's instructions correctly, you can also choose to use just a different text color.

Here are some possibilities for highlighting. Changing the background color usually entails some limitations, like boxes that don't wrap or restrictions on what can be put inside the highlighted area; but citations work with all approaches.

\documentclass[aapm,graphicx,preprint,showkeys]{revtex4-1}
\usepackage{amsmath,amssymb,enumitem,mathtools}
\usepackage{xcolor}
\newcommand\hl[1]{\colorbox{yellow}{\textcolor{red}{#1}}}
\newcommand\hlbreakable[1]{\textcolor{red}{#1}}
\usepackage[most]{tcolorbox}
\newtcolorbox{highlighted}{colback=yellow,coltext=red,breakable}
\usepackage{lipsum}
\begin{document}

\hl{This text is highlighted.}

\hl{Highlighting a citation causes no compilation error \cite{rockafellar1997convex,rudin1992nonlinear}.}

\hlbreakable{Highlighting a citation causes no compilation error \cite{rockafellar1997convex,rudin1992nonlinear}.
\lipsum}

\begin{highlighted}
Highlighting a citation causes no compilation error \cite{rockafellar1997convex,rudin1992nonlinear}.
\lipsum
\end{highlighted}

\begin{thebibliography}{10}
\bibitem{rockafellar1997convex}
R.T. Rockafellar.
\newblock {\em Convex analysis}.
\newblock Number~28. Princeton university press, 1997.
\bibitem{rudin1992nonlinear}
L.~Rudin, S.~Osher, and E.~Fatemi.
\newblock Nonlinear total variation based noise removal algorithms.
\newblock {\em Physica D: Nonlinear Phenomena}, 60(1):259--268, 1992.
\end{thebibliography}
\end{document}


Edit: It may be more convenient to define the \hlbreakable command as an environment, since \begin-\end pairs are easier to trace than pairs of braces.

\newenvironment{hlbreakable}%
{\color{red}}%
{}
...
\begin{hlbreakable}
Highlighting a citation causes no compilation error \cite{rockafellar1997convex,rudin1992nonlinear}.
\lipsum
\end{hlbreakable}

• \colorboxes cannot wrap, can they? Oct 26 '16 at 9:31
• Thanks, this is very helpful, but I agree with @Daniel's comment that \colorboxes can't wrap. Suppose that I want to highlight an entire paragraph. What would be a nice way to do that? Oct 26 '16 at 9:40
• Thank you. Would you mind providing an example that shows your first suggestion: "Either don't use background color and replace \textcolor by the \color declaration" ? Oct 26 '16 at 9:53
• Also, how would you remove the black border around the highlighted text? Oct 26 '16 at 10:13
• Thank you, that was super helpful! "Moreover, if I read the author's instructions correctly, you can also choose to use just a different text color." I think this is the simplest solution for my situation, together with the \hlbreakable command you provided. Oct 26 '16 at 10:18

You only need the "soul" package for this to work. Inside the "\hl{...}" command, instead of just putting in "\cite{...}", type "\mbox{\cite{...}}". This should do it.

• You should post a minimal document showing whether this works for multiple citations. May 16 '19 at 7:17
• Upvoted this because it is the only response that works with \hl Dec 24 '20 at 18:26

A pragmatic solution would be to use some other, less intrusive implementation of highlighting. In the following, I define the \hl command to just switch the text color to red (slightly toned for better readability):

\documentclass{article}
\usepackage{amsmath,amssymb,enumitem,mathtools}
\usepackage{xcolor}

\newcommand\hl[1]{%
\bgroup
\hskip0pt\color{red!80!black}%
#1%
\egroup
}

\begin{document}

\hl{This text is highlighted}.

Here's a citation \cite{rockafellar1997convex,rudin1992nonlinear}.

\hl{ Highlighting a citation does no longer cause a compilation error and even  works across line breaks \cite{rockafellar1997convex,rudin1992nonlinear}.}

\begin{thebibliography}{10}

\bibitem{rockafellar1997convex}
R.T. Rockafellar.
\newblock {\em Convex analysis}.
\newblock Number~28. Princeton university press, 1997.

\bibitem{rudin1992nonlinear}
L.~Rudin, S.~Osher, and E.~Fatemi.
\newblock Nonlinear total variation based noise removal algorithms.
\newblock {\em Physica D: Nonlinear Phenomena}, 60(1):259--268, 1992.

\end{thebibliography}

\end{document}


This simple approach looks less fancy, but has a lot of advantages: It works over most content (headings, tables, formulas, ...), is more printer-friendly and – taking the viewpoint of the reviewer – a lot more friendly for the reviewer's eye.

• +1 though red often comes out black on monochrome printers so another colour might work better (you can't assume your reviewer will work on screen or have easy access to a colour printer) Oct 26 '16 at 15:41
• A downvote about a year later? I wonder what was the reason for that... Jun 30 '17 at 21:34
• Anyway to make it incorporate footnotes? PS citations don't work for me. May 27 '21 at 8:10