source: trunk/review.sty @ 3

Last change on this file since 3 was 3, checked in by g7moreau, 9 years ago
  • Add review LaTeX package
File size: 9.5 KB
Line 
1
2\NeedsTeXFormat{LaTeX2e}[1999/01/01]
3\ProvidesPackage{review}[2004/02/17]
4\RequirePackage{color,keyval,twoopt}
5
6%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7% Copyright 2004-2011 Gabriel Moreau                                     %
8%                                                                        %
9% This work may be distributed and/or modified under the                 %
10% conditions of the LaTeX Project Public License, either version 1.3     %
11% of this license or (at your option) any later version.                 %
12% The latest version of this license is in                               %
13%   http://www.latex-project.org/lppl.txt                                %
14% and version 1.3 or later is part of all distributions of LaTeX         %
15% version 2005/12/01 or later.                                           %
16%                                                                        %
17% This work has the LPPL maintenance status `maintained'.                %
18%                                                                        %
19% The Current Maintainer of this work is G. Moreau.                      %
20%                                                                        %
21%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22
23%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
24% Pour gérer les deux types d'options :                                  %
25%  1. les options normales (\DeclareOption{...}{...})                    %
26%  2. les options type key-val option=value (\define@key{...}{...}{...}) %
27%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
28\@ifundefined{rev@unusedlist}{%
29  \let\rev@unusedlist\@empty}{}
30\@ifundefined{rev@extractkey}{%
31  \def\rev@extractkey#1=#2\rev@extractkey{#1}}{}
32\newcommand{\ProcessUnusedOptions}[1]{%
33  \let\my@tempa\@empty
34  \let\my@tempb\@empty
35  \@for\CurrentOption:=\rev@unusedlist\do{%
36    \expandafter\expandafter\expandafter\def
37    \expandafter\expandafter\expandafter\my@key
38    \expandafter\expandafter\expandafter{%
39      \expandafter\rev@extractkey\CurrentOption=\rev@extractkey}%
40    \@ifundefined{KV@#1@\my@key}{%
41      \edef\my@tempa{\my@tempa,\CurrentOption,}}{%
42      \edef\my@tempb{\my@tempb,\CurrentOption,}}}%
43  \@for\CurrentOption:=\my@tempa\do{%
44    \ifx\CurrentOption\@empty\else
45      \PackageWarning{review}{`\CurrentOption' not defined.}\fi}%
46  \edef\my@tempb{%
47    \noexpand\setkeys{#1}{\my@tempb}}%
48  \my@tempb
49  \AtEndOfPackage{\let\@unprocessedoptions\relax}}
50
51\DeclareOption*{%
52  \expandafter\expandafter\expandafter\def
53  \expandafter\expandafter\expandafter\rev@unusedlist
54  \expandafter\expandafter\expandafter{%
55    \expandafter\rev@unusedlist\expandafter,%
56    \CurrentOption}}
57
58%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59% initialisation
60%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
61
62\newif\if@rev@see \@rev@seetrue
63\newlength{\rev@len}
64\setlength{\rev@len}{\marginparwidth}
65\addtolength{\rev@len}{-0.5cm}
66\newcounter{rev@counter}
67\definecolor{rev@colortext}{rgb}{1,0,0}
68\definecolor{rev@colormark}{rgb}{0,0,1}
69
70\def\rev@contextwait{wait}
71\def\rev@contextreject{reject}
72\def\rev@contextaccept{accept}
73
74%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75% options
76%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77
78%% Options «normales»
79\DeclareOption{draft}{\@rev@seetrue}
80\DeclareOption{see}{\@rev@seetrue}
81\DeclareOption{hide}{\@rev@seefalse}
82\DeclareOption{final}{\@rev@seefalse}
83
84%% Options passées sous forme key=val
85\define@key{review}{width}{\setlength{\rev@len}{#1}}
86\define@key{review}{counter}{\setcounter{rev@counter}{#1}}
87%\define@key{review}{colortext}{\definecolor{rev@colortext}{rgb}{#1}}
88%\define@key{review}{colormark}{\definecolor{rev@colormark}{rgb}{#1}}
89%\define@key{mypack}{<key2>}[<default>]{<action 2> dépendant de #1}
90
91\ProcessOptions
92\ProcessUnusedOptions{review}
93
94%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
95% internal command
96%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
97
98% #1 command
99\newcommand{\rev@error}[1]{%
100   \PackageError{review}{option for #1 are 'accept' 'reject' or 'wait'}%
101   }
102
103% #1 author
104% #2 type
105% #3 other thing (with \\\hline please)
106\newcommand{\rev@notewait}[3]{%
107   \marginpar{%
108   \begin{tabular}{|p{\rev@len}|}\hline%
109   \texttt{\textcolor{#1}{\textcolor{rev@colormark}{\therev@counter{#2}}-#1}}\\\hline%
110   #3%
111   \end{tabular}%
112   }}
113
114% #1 author
115% #2 type
116\newcommand{\rev@noteaccept}[2]{%
117   \marginpar{%
118   $\left<\texttt{\textcolor{#1}{\textcolor{rev@colormark}{\therev@counter{#2}}-#1}}\right>$%
119   }}
120
121% #1 author
122% #2 type
123\newcommand{\rev@notereject}[2]{%
124   \marginpar{%
125   $\left/\texttt{\textcolor{#1}{\textcolor{rev@colormark}{\therev@counter{#2}}-#1}}\right/$%
126   }}
127
128% #1 author
129% #2 type
130\newcommand{\rev@notemark}[2]{%
131   \textcolor{#1}{$^{\left<\texttt{\textcolor{rev@colormark}{\therev@counter{#2}}}\right>}$}%
132   }
133
134%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
135% external command
136%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
137
138% #1 author
139% #2 color
140\newcommand{\revauthor}[2]{\definecolor{#1}{rgb}{#2}}
141
142% #1 color
143\newcommand{\revcolortext}[1]{\definecolor{rev@colortext}{rgb}{#1}}
144
145% #1 color
146\newcommand{\revcolormark}[1]{\definecolor{rev@colormark}{rgb}{#1}}
147
148
149% [#1] context
150% [#2] null
151%  #3  author
152%  #4  add
153%  #5  com
154\newcommandtwoopt{\revadd}[5][wait][null]{%
155   \def\rev@contextlocal{#1}%
156   \stepcounter{rev@counter}%
157   \if@rev@see%
158      \ifx\rev@contextlocal\rev@contextwait%
159         \textcolor{rev@colortext}{#4}%
160         \rev@notemark{#3}{a}%
161         \rev@notewait{#3}{a}{#5\\\hline}%
162      \else\ifx\rev@contextlocal\rev@contextaccept%
163         \textcolor{rev@colortext}{#4}%
164         \rev@noteaccept{#3}{a}%
165      \else\ifx\rev@contextlocal\rev@contextreject%
166         \rev@notereject{#3}{a}%
167      \else%
168         \rev@error{revadd}%
169      \fi\fi\fi%
170   \else%
171      \ifx\rev@contextlocal\rev@contextaccept%
172         #4%
173      \fi%
174   \fi%
175   }
176
177% [#1] context
178% [#2] null
179%  #3  author
180%  #4  old
181%  #5  new
182%  #6  com
183\newcommandtwoopt{\revmod}[6][wait][null]{%
184   \def\rev@contextlocal{#1}%
185   \stepcounter{rev@counter}%
186   \if@rev@see%
187      \ifx\rev@contextlocal\rev@contextwait%
188         \textcolor{rev@colortext}{#5}%
189         \rev@notemark{#3}{c}%
190         \rev@notewait{#3}{c}{#6\\\hline#4\\\hline}%
191      \else\ifx\rev@contextlocal\rev@contextaccept%
192         \textcolor{rev@colortext}{#5}%
193         \rev@noteaccept{#3}{c}%
194      \else\ifx\rev@contextlocal\rev@contextreject%
195         #4%
196         \rev@notereject{#3}{c}%
197      \else%
198         \rev@error{revmod}%
199      \fi\fi\fi%
200   \else%
201      \ifx\rev@contextlocal\rev@contextaccept%
202         #5%
203      \else%
204         #4%
205      \fi%
206   \fi%
207   }
208
209% [#1] context
210% [#2] null
211%  #3  author
212%  #4  old
213%  #5  new
214%  #6  com
215\newcommandtwoopt{\revforget}[6][wait][null]{%
216   \def\rev@contextlocal{#1}%
217   \stepcounter{rev@counter}%
218   \if@rev@see%
219      \ifx\rev@contextlocal\rev@contextwait%
220         \textcolor{rev@colortext}{#5}%
221         \rev@notemark{#3}{f}%
222         \rev@notewait{#3}{f}{#6\\\hline}%
223      \else\ifx\rev@contextlocal\rev@contextaccept%
224         \textcolor{rev@colortext}{#5}%
225         \rev@noteaccept{#3}{f}%
226      \else\ifx\rev@contextlocal\rev@contextreject%
227         #4%
228      \else%
229         \rev@error{revforget}%
230      \fi\fi\fi%
231   \else%
232      \ifx\rev@contextlocal\rev@contextaccept%
233         #5%
234      \else%
235         #4%
236      \fi%
237   \fi%
238   }
239
240% [#1] context
241% [#2] null
242%  #3  author
243%  #4  del
244%  #5  com
245\newcommandtwoopt{\revdel}[5][wait][null]{%
246\def\rev@contextlocal{#1}%
247\stepcounter{rev@counter}%
248\if@rev@see%
249   \ifx\rev@contextlocal\rev@contextwait%
250      \rev@notemark{#3}{d}%
251      \rev@notewait{#3}{d}{#5\\\hline#4\\\hline}%
252   \else\ifx\rev@contextlocal\rev@contextaccept%
253      \rev@noteaccept{#3}{d}%
254   \else\ifx\rev@contextlocal\rev@contextreject%
255      #4%
256   \else%
257      \rev@error{revdel}%
258   \fi\fi\fi%
259\else%
260   \ifx\rev@contextlocal\rev@contextaccept%
261   \else%
262      #4%
263   \fi%
264\fi%
265   }
266
267% [#1] context
268% [#2] null
269%  #3  author
270%  #4  com
271\newcommandtwoopt{\revmark}[4][wait][null]{%
272   \def\rev@contextlocal{#1}%
273   \stepcounter{rev@counter}%
274   \if@rev@see%
275      \ifx\rev@contextlocal\rev@contextwait%
276         \rev@notemark{#3}{m}%
277         \rev@notewait{#3}{m}{\footnotesize#4\\\hline}%
278      \else\ifx\rev@contextlocal\rev@contextaccept%
279         \textcolor{rev@colortext}{#4}%
280         \rev@noteaccept{#3}{m}%
281      \else\ifx\rev@contextlocal\rev@contextreject%
282      \else%
283         \rev@error{revmark}%
284      \fi\fi\fi%
285   \fi%
286   }
287
288% [#1] context
289% [#2] null
290%  #3  author
291%  #4  com
292\newcommandtwoopt{\revpar}[4][wait][null]{%
293   \def\rev@contextlocal{#1}%
294   \stepcounter{rev@counter}%
295   \if@rev@see%
296      \ifx\rev@contextlocal\rev@contextwait%
297%         \rev@notewait{#3}{p}{}%
298%         \textcolor{#3}{$\left<\texttt{\textcolor{rev@colormark}{\therev@counter{p}}}\right.-$}%
299%         \textcolor{rev@colortext}{#4}%
300%         \textcolor{#3}{$-\left.\texttt{\textcolor{rev@colormark}{\therev@counter{p}}}\right>$}%
301%
302%
303         \begin{center}%
304            \rev@notewait{#3}{p}{}%
305            \begin{tabular}{|p{0.95\linewidth}|}\hline%
306               \texttt{\textcolor{#3}{\textcolor{rev@colormark}{\therev@counter{p}}-#3}}\\\hline%
307               #4\\\hline%
308            \end{tabular}%
309         \end{center}%
310%   
311      \else\ifx\rev@contextlocal\rev@contextaccept%
312         \textcolor{rev@colortext}{#4}%
313         \rev@noteaccept{#3}{p}%
314      \else\ifx\rev@contextlocal\rev@contextreject%
315      \else%
316         \rev@error{revpar}%
317      \fi\fi\fi%
318   \fi%
319   }
320
321\endinput
Note: See TracBrowser for help on using the repository browser.