I am using the nice changes
package. Which basically provides three commands \added
, \deleted
and \replaced
. Because of the structure and the fact that the optional arguments it takes, I think it is possible to simplify its use. I followed the xparse
package documentation to see if I could create a command that simplifies the call.
Below is a MWE. I was able to create two version of the command, one that delete
and one that replace
depending on the number of argument. But I ran quickly out of steam.
In summary here are the mappings I would like to achieve by defining a new command \ME
:
\ME{deleted}
maps to\deleted[id=Me]{deleted}
\ME[added]
maps to\added[id=Me]{added}
(or at least equivalent to\ME[added]{}
)\ME[replacing]{replaced}
maps to\replaced[id=Me]{replacing}{replaced}
\ME[comment]{deleted}
maps to\deleted[id=Me, remark={comment}]{deleted}
\ME[comment][added]
maps to\added[id=Me,remark={comment}]{added}
(or equivalent to\ME[comment][added]{}
)\ME[comment][replacing]{replaced}
maps to\replaced[id=Me, remark={comment}]{replacing}{replaced}
.
MWE:
\documentclass{article}
\usepackage{changes}
\usepackage{xparse}
\definechangesauthor[name={MyName},color=blue]{ME}
\DeclareDocumentCommand \ME { o m }{%
\IfNoValueTF{#1}{
\deleted[id=ME]{#2}}{
\replaced[id=ME]{#1}{#2}
}
}
%\newcommand{\ME}[1]{\deleted[id=ME]{#1}} %ok
%\newcommand{\ME}[1][]{\added[id=ME]{#1}} % not working
\begin{document}
\added[id=ME,remark={added}]{added}
\deleted[id=ME,remark={deleted}]{deleted}
\replaced[id=ME,remark={replaced}]{replacing}{replaced}
\ME{aaa} % ok
\ME[aaa]{bbb} % ok
\ME[aaa]{} % ok
\ME{remark}[aaa]{}
\end{document}
EDIT: Summary, so far. Thanks to @AxelBall and @ChristianHupfer I get this syntax, which is almost ideal (except for pure comments) with the implementation below:
\ME{addonly}
\ME{add}<deleted>
\ME<deleteonly>
\ME[addonlycommet]{addonly}
\ME[adddeletecomment]{add}<delete>
\ME[deleteonlycomment]<deleteonly>
text\ME[commentonly]
And finally the star variants, that add the id
on the revision:
\ME*[deleteonlycomment]<deleteonly>
code:
\NewDocumentCommand{\ME}{sogd<>}{
\IfBooleanTF#1{
\IfNoValueTF{#2}{\IfNoValueTF{#3}{\IfNoValueF{#4}{\deleted[id=ME]{#4}}}{\IfNoValueTF{#4}{\added[id=ME]{#3}}{\replaced[id=ME]{#3}{#4}}}}{\IfNoValueTF{#3}{\IfNoValueTF{#4}{\added[id=ME,remark={#2}]{}}{\deleted[id=ME, remark={#2}]{#4}}}{\IfNoValueTF{#4}{\added[id=ME,remark={#2}]{#3}}{\replaced[id=ME, remark={#2}]{#3}{#4}}}}
}{
\IfNoValueTF{#2}{\IfNoValueTF{#3}{\IfNoValueF{#4}{\deleted{#4}}}{\IfNoValueTF{#4}{\added{#3}}{\replaced{#3}{#4}}}}{\IfNoValueTF{#3}{\IfNoValueTF{#4}{\added[remark={#2}]{}}{\deleted[remark={#2}]{#4}}}{\IfNoValueTF{#4}{\added[remark={#2}]{#3}}{\replaced[remark={#2}]{#3}{#4}}}}
}
}
\Me[something]{real arg}
if something is the designed for the 2nd opt or as the 1st opt. You need another syntax, in my point of view. In addition, the omittance of{}
as mandatory argument is very difficult to achieve.\Me[comment]{added}{}
or\Me[][replacing]{replaced}
.