[Tex/LaTex] Colorbox with changes package

changescolor

I am working with the changes package. Modifying the color of the changed passages works well with \colorlet command. Is it possible to create colorboxes (with yellow color) only around the changes (without the \colorbox command)?

Thanks for your answer…
Philipp

Best Answer

You can control the appearance of added and deleted text through the commands \setaddedmarkup and \setdeletedmarkup, respectively.

So you can define, for example:

\setaddedmarkup{\colorbox{yellow}{#1}}
\setdeletedmarkup{\colorbox{red}{\sout{#1}}}

With the following code

\documentclass{article}

\usepackage{changes}

\definechangesauthor[name={Philipp}]{P}

\setaddedmarkup{\colorbox{yellow}{#1}}
\setdeletedmarkup{\colorbox{red}{\sout{#1}}}

\begin{document}
This is \added[id=P]{new} text.

This is \deleted[id=P]{bad} text.

This is \replaced[id=P]{nice}{bad} text.
\end{document} 

you get

enter image description here

This doesn't obviously support line breaks.

If you don't need particular formatting apart from coloring, you can load the soul package (once loaded by changes), and define, for example:

\setaddedmarkup{\sethlcolor{yellow}\hl{#1}}
\setdeletedmarkup{\sethlcolor{red}\hl{#1}}

MWE

\documentclass{article}

\usepackage{changes}
\usepackage{soul}

\definechangesauthor[name={Philipp}]{P}

\setaddedmarkup{\sethlcolor{yellow}\hl{#1}}
\setdeletedmarkup{\sethlcolor{red}\hl{#1}}

\begin{document}
This is \added[id=P]{new} text.

This is \deleted[id=P]{bad} text.

This is \replaced[id=P]{nice}{bad} text.
\end{document} 

Output:

enter image description here

Otherwise, have a look at this thread for more highlighting possibilities: Cool Text Highlighting in LaTeX