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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
|
% \iffalse meta-comment
% vim: textwidth=75
%<*internal>
\iffalse
%</internal>
%<*readme>
|
---------:| ---------------------------------------------------------------
proofread:| Commands for inserting annotations
Author:| Wybo Dekker
E-mail:| wybo@dekkerdocumenten.nl
License:| Released under the LaTeX Project Public License v1.3c or later
See:| http://www.latex-project.org/lppl.txt
Short description:
The proofread package defines a few LaTeX commands that are useful
when you proofread a latex document. These allow you to easily highlight
text and add comments in the margin. Vim escape sequences are provided
for inserting these LaTeX commands in the source. The package is based
on code for a text highlighting command that was published by Antal S-Z
in http://tex.stackexchange.com/questions/5959.
The main file, proofread.dtx, is self-extracting, so you can generate the
style file by compiling proofread.dtx with pdflatex.
%</readme>
%<*internal>
\fi
\def\nameofplainTeX{plain}
\ifx\fmtname\nameofplainTeX\else
\expandafter\begingroup
\fi
%</internal>
%<*install>
\input docstrip.tex
\keepsilent
\askforoverwritefalse
\preamble
---------:| ---------------------------------------------------------------
proofread:| Commands for inserting annotations
Author:| Wybo Dekker
E-mail:| wybo@dekkerdocumenten.nl
License:| Released under the LaTeX Project Public License v1.3c or later
See:| http://www.latex-project.org/lppl.txt
\endpreamble
\postamble
Copyright (C) 2015 by Wybo Dekker <wybo@dekkerdocumenten.nl>
This work may be distributed and/or modified under the
conditions of the LaTeX Project Public License (LPPL), either
version 1.3c of this license or (at your option) any later
version. The latest version of this license is in the file:
http://www.latex-project.org/lppl.txt
This work is "maintained" (as per LPPL maintenance status) by
Wybo Dekker.
This work consists of the file proofread.dtx and a Makefile.
Running "make" generates the derived files README, proofread.pdf and
proofread.sty.
Running "make inst" installs the files in the user's TeX tree.
Running "make install" installs the files in the local TeX tree.
\endpostamble
\usedir{tex/latex/proofread}
\generate{
\file{\jobname.sty}{\from{\jobname.dtx}{package}}
}
%</install>
%<install>\endbatchfile
%<*internal>
\usedir{source/latex/proofread}
\generate{
\file{\jobname.ins}{\from{\jobname.dtx}{install}}
}
\nopreamble\nopostamble
\usedir{doc/latex/proofread}
\generate{
\file{README.txt}{\from{\jobname.dtx}{readme}}
}
\ifx\fmtname\nameofplainTeX
\expandafter\endbatchfile
\else
\expandafter\endgroup
\fi
%</internal>
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{proofread.dtx}
%</driver>
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{proofread}
%<*package>
[2015/12/07 v1.01 Commands for inserting annotations]
%</package>
%<*driver>
\documentclass{ltxdoc}
\usepackage[a4paper,margin=25mm,left=50mm,nohead]{geometry}
\usepackage[numbered]{hypdoc}
\usepackage{microtype}
\usepackage{\jobname}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\parindent0pt\parskip2ex
\makeatletter
\def\com#1{\relax}
\begin{document}
\DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
%
% \GetFileInfo{\jobname.dtx}
% \DoNotIndex{\newcommand, \DeclareRobustCommand, \RequirePackage, \add,
% \advance, \begin, \bgroup, \coordinate, \def, \del, \discretionary,
% \egroup, \end, \endinput, \endpgfextra, \fi, \fill, \footnotesize,
% \global, \hbox, \hilite, \ifdef, \ifdim, \marginpar, \marginparmargin,
% \marginparpush, \mbox, \newbox, \newcount, \newdimen, \p, \path,
% \pgfextra, \rep, \sbox, \st, \the, \tikz, \tikzset, \usebox,
% \usetikzlibrary, \y, \yel
% }
%
%\title{\textsf{proofread} --- Commands for inserting annotations\thanks{This file
% describes version \fileversion, last revised \filedate.}
%}
%\author{Wybo Dekker\thanks{E-mail: wybo@dekkerdocumenten.nl}}
%\date{Released \filedate}
%
%\maketitle
%
%\changes{v1.00}{2015/09/06}{First public release}
%\changes{v1.01}{2015/12/07}{running counter was sometimes not advanced}
%
% \begin{abstract}\noindent
% The |proofread| package defines a few \LaTeX\ commands that are useful
% when you proofread a latex document. These allow you to easily highlight
% text and add comments in the margin. Vim escape sequences are provided
% for inserting these \LaTeX\ commands in the source. The package is based
% on code for a text highlighting command that was published by Antal S-Z
% in \href{http://tex.stackexchange.com/questions/5959}{StackExchange}.
% \end{abstract}
%
% \section{Usage}
% The commands described below display a highlighted phrase in your
% compiled document and place a comment in the margin, prefixed with a
% counter, which is indicated with \textit{n} in the following. This
% counter is useful in the communication with the author of the document.
%
% \DescribeMacro{\del}
% |\del{phrase}| displays \del{phrase} and places \textit{n}:Delete in the
% margin. In the |vim| editor, you can generate this code by selecting the
% phrase and typing |<escape>d| if you add the following line to your
% |.vimrc| file:\footnote{If you made sequences or commands for your own
% editor, please inform the author; he will include those in this
% document.}
%
% |map <Esc>d s\del{}<Esc>hp|
%
% After typing this escape sequence, you will be in normal mode, behind the
% closing brace.
%
% \DescribeMacro{\yel}
% |\yel[comment]{phrase}| displays \yel{phrase} and places
% \textit{n}:comment in the margin. In the |vim| editor, you can generate
% this code by selecting the phrase and typing |<escape>y| if you add the
% following line to your |.vimrc| file:
%
% |map <Esc>y s\yel[]{}<Esc>PF[li|
%
% After typing this escape sequence, you will be in insert mode between the
% square bracket pair, ready to insert the \textit{comment}.
%
% \DescribeMacro{\add}
% |\add{phrase}| displays \add{phrase} and places \textit{n}:Add in the
% margin. In the |vim| editor, you can generate this code by typing
% |<escape>a| if you add the following line to your |.vimrc| file:
%
% |map <Esc>a a\add{}<Esc>i|
%
% After typing this escape sequence, you will be in insert mode between the
% braces pair, ready to type what should be added.
%
% \DescribeMacro{\rep}
% |\rep{phrase}{replacement}| displays \rep{phrase}{replacement} and places
% \textit{n}:was:phrase in the margin. In the |vim| editor, you can
% generate this code by selecting the phrase and typing |<escape>r| if you
% add the following line to your |.vimrc| file:
%
% |map <Esc>r s\rep{}{}<Esc>2F{plla|
%
% After typing this escape sequence, you will be in normal mode between
% the second pair of braces, ready to edit the new content.
%
% \DescribeMacro{\com}
% |\com{comment}| is used by |\del|, |\yel|, |\add|, and |\rep| to place
% \textit{n}:comment in the margin. You can use it to place comment in the
% margin without text highlighting. In the |vim| editor, you can insert the
% command by typing |<escape>c| if you add the following line to your
% |.vimrc| file:
%
% |map <Esc>c a\com{}<Esc>i|
%
% After typing this escape sequence, you will be in insert mode between the
% braces pair, ready to type your comment.
%
% \DescribeMacro{\hilite}
% |\hilite[options]{phrase}| is the command on which the above commands are
% based. It was published by Antal S-Z in
% \href{http://tex.stackexchange.com/questions/5959}{StackExchange}.
% It highlights the phrase with the default colour, yellow, using the
% default fill opacity, 0.25; but using the options, you can change this.
% For example,
% \hilite[fill=blue,draw=yellow,opacity=.5,line width=3pt]{this phrase}
% was highlighted with blue, with a 3pt width line in yellow around it,
% with the command:
%
% |\hilite[fill=blue,draw=yellow,opacity=.5,line width=3pt}|
%
% Both the fill color and the draw color get 50\% opacity, but you can set
% each individually with the |fill opacity| and |draw opacity| options.
% See the documentation of the tikz package for more options.
%
%\StopEventually{^^A
% \PrintChanges
% \PrintIndex
%}
%
% \section{Implementation}
%
% \begin{macrocode}
%<*package>
% \end{macrocode}
% The following code for a text highlighting command (here renamed to
% |\hilite| was published by Antal S-Z in
% \href{http://tex.stackexchange.com/questions/5959}{StackExchange}.
% \begin{macrocode}
\RequirePackage{soul}
\RequirePackage{tikz}
\RequirePackage{etoolbox}
\usetikzlibrary{calc}
\usetikzlibrary{decorations.pathmorphing}
\newcommand{\PR@defhiliter}[3][]{%
\tikzset{every hiliter/.style={color=#2, fill opacity=#3, #1}}%
}
\PR@defhiliter{yellow}{.25}
\newcommand{\PR@hilite@Dohilite}{
\fill [ decoration = {random steps, amplitude=1pt, segment length=15pt}
, outer sep = -15pt, inner sep = 0pt, decorate
, every hiliter, this hiliter ]
($(begin hilite)+(0,8pt)$) rectangle ($(end hilite)+(0,-3pt)$) ;
}
\newcommand{\PR@hilite@Beginhilite}{
\coordinate (begin hilite) at (0,0) ;
}
\newcommand{\PR@hilite@Endhilite}{
\coordinate (end hilite) at (0,0) ;
}
\newdimen\PR@hilite@previous
\newdimen\PR@hilite@current
% \end{macrocode}
% \begin{macro}{\hilite}
% \begin{macrocode}
\DeclareRobustCommand*\hilite[1][]{%
\tikzset{this hiliter/.style={#1}}%
\SOUL@setup
%
\def\SOUL@preamble{%
\begin{tikzpicture}[overlay, remember picture]
\PR@hilite@Beginhilite
\PR@hilite@Endhilite
\end{tikzpicture}%
}%
%
\def\SOUL@postamble{%
\begin{tikzpicture}[overlay, remember picture]
\PR@hilite@Endhilite
\PR@hilite@Dohilite
\end{tikzpicture}%
}%
%
\def\SOUL@everyhyphen{%
\discretionary{%
\SOUL@setkern\SOUL@hyphkern
\SOUL@sethyphenchar
\tikz[overlay, remember picture] \PR@hilite@Endhilite ;%
}{%
}{%
\SOUL@setkern\SOUL@charkern
}%
}%
%
\def\SOUL@everyexhyphen##1{%
\SOUL@setkern\SOUL@hyphkern
\hbox{##1}%
\discretionary{%
\tikz[overlay, remember picture] \PR@hilite@Endhilite ;%
}{%
}{%
\SOUL@setkern\SOUL@charkern
}%
}%
%
\def\SOUL@everysyllable{%
\begin{tikzpicture}[overlay, remember picture]
\path let \p0 = (begin hilite), \p1 = (0,0) in \pgfextra
\global\PR@hilite@previous=\y0
\global\PR@hilite@current =\y1
\endpgfextra (0,0) ;
\ifdim\PR@hilite@current < \PR@hilite@previous
\PR@hilite@Dohilite
\PR@hilite@Beginhilite
\fi
\end{tikzpicture}%
\the\SOUL@syllable
\tikz[overlay, remember picture] \PR@hilite@Endhilite ;%
}%
\SOUL@
}
% \end{macrocode}
% \end{macro}
% Reduce minimum vertical space between margin paragraphs; if the memoir
% class is active, use the outer margin:
% \begin{macrocode}
\AtEndPreamble{\marginparpush2pt}
\ifdef{\marginparmargin}{\marginparmargin{outer}}{}
% \end{macrocode}
% We need a save box and a counter for prefixing the margin paragraphs:
% \begin{macrocode}
\newbox\PR@soulbox
\newcount\PR@markerno\PR@markerno=1
% \end{macrocode}
% \begin{macro}{\com}
% Make a margin paragraph, in footnote fontsize, prefixed with the counter
% plus a colon:
% \begin{macrocode}
\newcommand{\com}[1]{%
\marginpar{%
\footnotesize%
\the\PR@markerno:#1%
}%
\global\advance\PR@markerno1%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\del}
% \begin{macrocode}
\newcommand{\del}[1]{%
\com{delete}%
\sbox\PR@soulbox{\st{#1}}%
\hilite[red]{{\usebox\PR@soulbox}}%
\bgroup\egroup%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\yel}
% \begin{macrocode}
\newcommand{\yel}[2][\mbox{}]{%
\com{#1}%
\hilite[yellow]{#2}%
\bgroup\egroup%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\add}
% \begin{macrocode}
\newcommand{\add}[1]{%
\com{add}%
\hilite[green,draw=blue]{#1}%
\bgroup\egroup%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\rep}
% \begin{macrocode}
\newcommand{\rep}[2]{%
\com{was:#1}%
\hilite[blue]{#2}%
\bgroup\egroup%
}
\endinput
%</package>
% \end{macrocode}
% \end{macro}
%\Finale
|