I'm following this example on how to get strikethrough to work across multiple paragraphs (which contain citations, a sticking point for many strikethrough solutions):
More robust strike-through / cross-out
I have created a minimally reproducible example that does work, shown below.
\documentclass{article}
\usepackage{xcolor}
\usepackage[normalem]{ulem}
\newcommand\deleted[1]{\color{red}\let\helpcmd\sout\parhelp#1\par\relax\relax}
\newcommand\added[1]{\color{blue}\let\helpcmd\parhelp#1\par\relax\relax}
\long\def\parhelp#1\par#2\relax{%
\helpcmd{#1}\ifx\relax#2\else\par\parhelp#2\relax\fi%
}
\begin{document}
\deleted{
Example deleted section - \cite{abc} Lorem ipsum
dolor sit amet, consectetur adipiscing elit, sed
do eiusmod tempor incididunt ut labore et dolore magna aliqua.
}
\added{
Example added section - - \cite{abc} Lorem ipsum
dolor sit amet, consectetur adipiscing elit, sed
do eiusmod tempor incididunt ut labore et dolore magna aliqua.
}
\end{document}
In my main document where this is being used I've got the \usepackage statements and I'm copying/pasting the \newcommand lines and \long\def... line (I honestly don't understand this line, I've copied it from the tex/SE article referenced above).
When I use \added{...paragraph text...} I get the following Undefined control sequence error:
\added #1->\color {blue}\let \helpcmd
\parhelp #1\par \relax \relax
l.184 }
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., \hobx'), typeI' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
I can't see any difference between my document (which mostly just has a bunch more \usepackage statements) and the minimally reproducible example here.


\addedcommand inmain.tex, and it worked fine. Then I tested using\addedin one of the subsections of the document which are separate.texsections imported tomain.texusing\input{subsection-file-name}. When I try to use\addedin the subsection page overleaf doesn't auto-complete for me anymore. I'm testing if I can reproduce this in the MRE currently. – davidparks21 Jul 28 '22 at 23:31addedis fragile macros - What is the difference between Fragile and Robust commands? When and why do we need \protect? - TeX - LaTeX Stack Exchange. Add\MakeRobust\addedafter the\newcommand\added ...line. (just a guess, because no MWE.) – user202729 Jul 29 '22 at 01:48\let \helpcmd, so it seems there is a situation where the\let-assignment is not carried out and an attempt at expanding\helpcmdtakes place while that is undefined. Such things can happen in\edef- or\writecontexts, e.g., when sectioning-commands write their arguments to .toc-file. Try to suppress expansion by doing as suggested by user 202729 or by defining\deletedand\addedby means of\DeclareRobustCommandinstead of\newcommand. – Ulrich Diez Jul 29 '22 at 18:27\addedlooks weird: Seems the\let-assignment is not complete, thus\helpcmderroneously is let equal to\parhelpinstead of having\addedcarry out\parhelp. However, this should not lead to error-messages in normal contexts. But not carrying out\letin\edef- or\write-contexts and thus attempting to expand undefined\helpcmdtriggers error-messages. – Ulrich Diez Jul 29 '22 at 19:13