forked from pedromateo/revdiff-LaTeX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
revdiff.sty
135 lines (99 loc) · 3.96 KB
/
revdiff.sty
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
%================================================%
% Revision / diff package for LaTeX
% Created with love by Pedro Mateo
%================================================%
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{revdiff}[2015/12/13 revdiff Package]
\RequirePackage{letltxmacro}
\RequirePackage{xcolor}
\RequirePackage{tikz}
\RequirePackage[normalem]{ulem}
\definecolor{newcolor}{RGB}{0,0,240}
\definecolor{oldcolor}{RGB}{253,102,102}
\definecolor{tagcolor}{RGB}{253,128,0}
\definecolor{commentcolor}{RGB}{0,153,0}
\newcommand{\rnew}[1]{#1}
\newcommand{\rold}[1]{#1}
\newcommand{\rchange}[2]{#2}
\newcommand{\rtag}[1]{#1}
\newcommand{\rcomment}[1]{#1}
\newcommand{\renclose}[2]{#2}
\newcommand{\rtchange}[3]{#3}
\newcommand{\rtcomment}[2]{#2}
\newcommand{\rtenclose}[3]{#3}
\newcommand{\rlegend}{}
% Cites have to be inserted into mbox to allow strikethrough
\LetLtxMacro\origcite\cite
%================================================%
% Declare options - revision mode
%================================================%
\DeclareOption{revision}{
\renewcommand{\rnew}[1]{\textcolor{newcolor}{#1}}
\renewcommand{\rold}[1]{\textcolor{oldcolor}{{\sout{#1}}}}
\renewcommand{\rchange}[2]{\rold{#1}\rnew{#2}}
\renewcommand{\rtag}[1]{\noindent \raisebox{-1.2ex}{\tikz{\node[text height=1.5ex,text depth=.5ex,scale=.9,fill=tagcolor!50,draw=tagcolor!100,thick,rounded corners] {\tt #1};}}}
\renewcommand{\rcomment}[1]{\noindent \textcolor{commentcolor}{\sf //#1//}}
\renewcommand{\renclose}[2]{~~\textcolor{commentcolor}{#1 $>>>>$} #2 \textcolor{commentcolor}{$<<<<$}~~}
\renewcommand{\rtchange}[3]{\rtag{#1}~\rchange{#2}{#3}}
\renewcommand{\rtcomment}[2]{\rtag{#1}~\rcomment{#2}}
\renewcommand{\rtenclose}[3]{\rtag{#1}~\renclose{#2}{#3}}
% cite needs to be redefined to avoid compilation errors
\renewcommand{\cite}[1]{\mbox{\origcite{#1}}}
% this command prints a legend
\renewcommand{\rlegend}{
\textbf{Warning:}
This is a revised version including diff statements.
Changes in the text are marked as follows:
%
\rnew{Blue color is used to denote new text.}
\rold{Removed text is turn into red.}
Changes can also be inline: \rchange{This is an}{ inline change.}
You can also find \rtag{tags} and \rcomment{other comments} in the text.
Comments can be \renclose{linked to}{a specific part of the text.}
Changes can be also \rtchange{tagged}{to mark}{something}.
Comments can be \rtcomment{tagged}{as well}.
}
}
%================================================%
% Declare options - new mode
%================================================%
\DeclareOption{new}{
\renewcommand{\rnew}[1]{\textcolor{newcolor}{#1}}
\renewcommand{\rold}[1]{\textcolor{oldcolor}{[\ldots]}}
\renewcommand{\rchange}[2]{\rnew{#2}}
\renewcommand{\rtag}[1]{}
\renewcommand{\rcomment}[1]{}
\renewcommand{\renclose}[2]{#2}
\renewcommand{\rtchange}[3]{\rchange{#2}{#3}}
\renewcommand{\rtcomment}[2]{\rcomment{#2}}
\renewcommand{\rtenclose}[3]{\renclose{#2}{#3}}
% cite needs to be redefined to avoid compilation errors
%\renewcommand{\cite}[1]{\origcite{#1}}
% this command prints a legend
\renewcommand{\rlegend}{}
}
%================================================%
% Declare options - clean mode
%================================================%
\DeclareOption{clean}{
\renewcommand{\rnew}[1]{#1}
\renewcommand{\rold}[1]{}
\renewcommand{\rchange}[2]{#2}
\renewcommand{\rtag}[1]{}
\renewcommand{\rcomment}[1]{}
\renewcommand{\renclose}[2]{#2}
\renewcommand{\rtchange}[3]{#3}
\renewcommand{\rtcomment}[2]{}
\renewcommand{\rtenclose}[3]{#3}
% cite needs to be redefined to avoid compilation errors
\renewcommand{\cite}[1]{\origcite{#1}}
% this command prints a legend
\renewcommand{\rlegend}{}
}
%================================================%
%
%================================================%
% default option
\ExecuteOptions{clean}
\ProcessOptions\relax
\endinput