blob: a6d2501eed14c4a6443eda315436bfa9bf692cfe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{xreview}[2024/08/29 Reviewing LaTeX documents made easy]
\RequirePackage{xcolor}
\RequirePackage[normalem]{ulem}
\RequirePackage{etoolbox}
\RequirePackage{environ}
\RequirePackage{letltxmacro}
\RequirePackage{todonotes}
\RequirePackage{soul}
\RequirePackage{pifont}
\RequirePackage{xparse}
\RequirePackage{amsmath}
%%%% Equation numbering
\newcounter{removedeqcounter}
\setcounter{removedeqcounter}{0}
%%%% Comment numbering
\newcounter{commentcounter}
\setcounter{commentcounter}{0}
%%%% Define colours and prefixes
\newcommand{\addedcolor}{blue}
\newcommand{\removedcolor}{red}
\newcommand{\removedeqprefix}{R}
\newcommand{\commentcolor}{yellow}
\newcommand{\resolvedcommentcolor}{green}
\newcommand{\commentprefix}{C}
%%%% Necessary for comments to work in twocolumn-type documents
\setlength{\marginparwidth}{2cm}
%%%% Reviewing commands
\newtoggle{annotated}
\toggletrue{annotated} % Show changes by default
\newcommand{\showchanges}{\toggletrue{annotated}}
\newcommand{\showclean}{\togglefalse{annotated}}
\newtoggle{commented}
\toggletrue{commented} % Show comments by default
\newcommand{\showcomments}{\toggletrue{commented}}
\newcommand{\hidecomments}{\togglefalse{commented}}
%%%% Text coloring and hiding
\newcommand{\colortext}[2]{{\leavevmode\color{#1}{#2}}}
\newcommand{\safesout}[1]{\ifmmode\text{\sout{\ensuremath{#1}}}\else\sout{#1}\fi}
\newcommand{\hidefromclean}[1]{\iftoggle{annotated}{#1}{}}
\newcommand{\added}[1]{\iftoggle{annotated}{\colortext{\addedcolor}{#1}}{{#1}}}
\newcommand{\removed}[1]{\hidefromclean{%
\begingroup%
\let\oldcite\cite%
\renewcommand{\cite}[1]{\mbox{\oldcite{##1}}}%
\colortext{\removedcolor}{\safesout{#1}}%
\endgroup}}
\newcommand{\changed}[2]{\removed{#1}\iftoggle{annotated}{ }{}\added{#2}}
%%%% Equation coloring and hiding
\NewEnviron{remequation}{\hidefromclean{%
\addtocounter{equation}{-1}%
\refstepcounter{removedeqcounter}%
\renewcommand{\theequation}{\textcolor{\removedcolor}{\removedeqprefix\arabic{removedeqcounter}}}%
\let\oldnonumber\nonumber%
\renewcommand{\nonumber}{\addtocounter{equation}{1}\addtocounter{removedeqcounter}{-1}\oldnonumber}%
\renewcommand{\notag}{\nonumber}%
\begin{equation}%
\color{\removedcolor}%
\safesout{\BODY}%
\end{equation}}}
\NewEnviron{remequation*}{\hidefromclean{%
\begin{equation*}%
\color{\removedcolor}%
\safesout{\BODY}%
\end{equation*}}}
\NewEnviron{addequation}{%
\begin{equation}%
\added{\BODY}%
\end{equation}}
\NewEnviron{addequation*}{%
\begin{equation*}%
\added{\BODY}%
\end{equation*}}
\newcommand{\removedeqline}[1]{\hidefromclean{%
\let\oldnonumber\nonumber%
\renewcommand{\nonumber}{\global\tag@false\addtocounter{removedeqcounter}{-1}}%
\renewcommand{\notag}{\nonumber}%
\makeatletter%
\newcommand{\remlabel}{%
\refstepcounter{removedeqcounter}%
\global\tag@true%
\oldnonumber%
\gdef\df@tag{\maketag@@@{\textcolor{\removedcolor}{(\removedeqprefix\arabic{removedeqcounter})}}\def\@currentlabel{\textcolor{\removedcolor}{\removedeqprefix\arabic{removedeqcounter}}}}}
\makeatother
\remlabel%
\color{\removedcolor}%
\makeatletter\let\default@color\current@color\makeatother%
\safesout{#1}%
}}
\newcommand{\addedeqline}[1]{%
\iftoggle{annotated}{\color{\addedcolor}{#1}}%
{{#1}}%
}
\newcommand{\remaligntab}{\hidefromclean{&}}
\newcommand{\remnewline}{\hidefromclean{\\}}
%%%% Commenting
\DeclareRobustCommand{\resolvedhl}[1]{{\sethlcolor{green}\hl{#1}}}
\newcommand{\comment}[3][]{%
\stepcounter{commentcounter}%
\ifboolexpr{togl{annotated} and togl{commented}}{%
\hl{#2}\todo[prepend, color=\commentcolor ,caption=\textbf{\commentprefix\arabic{commentcounter}}, linecolor=black, #1]{#3}}%
{#2}}
\newcommand{\resolvedcomment}[3][]{%
\stepcounter{commentcounter}%
\ifboolexpr{togl{annotated} and togl{commented}}{%
\resolvedhl{#2}\todo[prepend, color=\resolvedcommentcolor ,caption=\textbf{\ding{52} \commentprefix\arabic{commentcounter}}, linecolor=black, #1]{#3}}%
{#2}}
\NewDocumentCommand{\authoredcomments}{O{} O{} m}{%
\expandafter\newcommand\csname #3comment\endcsname{\comment[author=#3, #1]}%
\expandafter\newcommand\csname resolved#3comment\endcsname{\resolvedcomment[author=#3, #2]}%
}
|