I am revising a scientific publication and keeping track of the changes using the \added{}, \deleted{}, and \replaced{good}{bad} commands.
The compilation fails when trying to replace/add/delete text that contains citations made with the \citet{} or \citep{} commands, e.g.,:
\replaced{This is a better sentence \citep{somearticle2016}}{This sentence is lame}
does not work. I have tried to use \protect in front of the citation as suggested here, also tried to add curly brackets around the citation as suggested here, unsuccessfully. I would rather avoid putting the citation outside of the \replaced{good}{bad} command (like this: \replaced{This is a better sentence} \added{\citep{somearticle2016}}{This sentence is lame}).
Has anyone encountered this issue, and how did you work around it? Note that I cannot add macros of my own, and would like to avoid adding packages.
\replaced{good}{bad} is defined as follows (but cannot be modified):
\def\replaced{\@ifnextchar[{\xreplaced}{\yreplaced}}
\long\def\xreplaced[#1]#2#3{%
\ifdraft
\global\advance\refchangenumber by 1
\ifnumlines\xdef\doit{\noexpand\linelabel{\the\refchangenumber}}\doit\else%
\xdef\doit{\noexpand\label{\the\refchangenumber}}\doit\fi%
{\color{trackcolor}(Replaced: \sout{#2}}
{\color{black}replaced with:} {\color{trackcolor} #3)}%
\expandafter\gdef\csname
changenum\the\refchangenumber\endcsname{Replaced: [#1]
{\color{trackcolor}\sout{#2}} {\color{black} replaced with:}
{\color{trackcolor}#3}, }\else#3\fi}
\long\def\yreplaced#1#2{%
\ifdraft
\global\advance\refchangenumber by 1
\ifnumlines\xdef\doit{\noexpand\linelabel{\the\refchangenumber}}\doit\else%
\xdef\doit{\noexpand\label{\the\refchangenumber}}\doit\fi%
{\color{trackcolor}(Replaced: \sout{#1}}
{\color{black}replaced with:} {\color{trackcolor} #2)}%
\expandafter\gdef\csname changenum\the\refchangenumber\endcsname{Replaced:
{\color{trackcolor}\sout{#1}} {\color{black} replaced with:}
{\color{trackcolor}#2}, }\else#2\fi}
{}symbol in the gui to highlight it). This way people can easily copy your code and work with it. The screenshot is close to being useless as the only way to use it is to retype it! – May 12 '16 at 11:27