summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/proofread/proofread.sty
blob: b853a83637ee056e85baf0948f333642731c80dd (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
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
%%
%% This is file `proofread.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% proofread.dtx  (with options: `package')
%% ---------:| ---------------------------------------------------------------
%% 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
%% 
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{proofread}
    [2017/02/28 v1.02 Commands for inserting annotations]
\RequirePackage{marginnote}
\ifx\undefined\DoubleSpacing
  \RequirePackage{setspace}
\else
  \let\setstretch\setSpacing
  \let\onehalfspacing\OnehalfSpacing
  \let\doublespacing\DoubleSpacing
\fi
\newif\ifPR@spaced\PR@spacedfalse
\newdimen\PR@unit\PR@unit.6\baselineskip
\DeclareOption{onehalfspacing}{\onehalfspacing\PR@spacedtrue\PR@unit.525\baselineskip}
\DeclareOption{doublespacing}{\doublespacing\PR@spacedtrue\PR@unit.35\baselineskip}
\newif\ifPR@corrected\PR@correctedfalse
\newif\ifPR@uncorrected\PR@uncorrectedfalse
\DeclareOption{corrected}{\PR@correctedtrue}
\DeclareOption{uncorrected}{\PR@uncorrectedtrue}
\newif\ifPR@frame\PR@framefalse
\newdimen\PR@lw\PR@lw=0pt
\DeclareOption{frame}{\PR@lw=.5pt\PR@frametrue}
\ProcessOptions
\RequirePackage{soul}
\RequirePackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{decorations.pathmorphing}

\newcommand{\PR@defhiliter}[3][]{%
  \tikzset{every hiliter/.style={fill=#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

\DeclareRobustCommand*\hilite[1][]{%
  \ifPR@frame%
    \tikzset{this hiliter/.style={#1,draw=black,line width=\PR@lw}}%
  \else%
    \tikzset{this hiliter/.style={#1}}%
  \fi
  \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@
}
\AtBeginDocument{\marginparpush2pt}
\ifx\undefined\marginparmargin\else\marginparmargin{outer}\fi
\newbox\PR@soulbox
\newcount\PR@markerno\PR@markerno=1
\newcommand{\com}[1]{%
  \marginnote{%
    \setstretch{1}%
    \raggedright%
    \footnotesize%
    \the\PR@markerno: #1%
  }[\PR@skip]%
  \global\PR@skip0pt
  \global\advance\PR@markerno1%
}
\newdimen\PR@skip\PR@skip0\PR@unit
\newcommand{\skp}[1][1]{%
 \PR@skip#1\PR@unit%
}
\newcommand{\del}[1]{%
  \com{delete}%
  \sbox\PR@soulbox{\st{#1}}%
  \hilite[red]{{\usebox\PR@soulbox}}%
}
\newcommand{\yel}[2][]{%
  \com{#1}%
  \hilite{#2}%
}
\newcommand{\add}[1]{%
  \com{add}%
  \hilite[green]{#1}%
}
\newcommand{\rep}[2]{%
  \com{was: #1}%
  \hilite[blue]{#2}%
}
\ifPR@uncorrected
  \ifPR@corrected
    \PackageError{proofread}{You may not use both the corrected and uncorrected options}
  \fi
  \def\com#1{} \def\add#1{} \def\del#1{#1} \def\rep#1#2{#1}
  \renewcommand{\yel}[2][]{#2}\renewcommand{\hilite}[2][]{#2}
\else
  \ifPR@corrected
    \def\com#1{} \def\add#1{#1} \def\del#1{} \def\rep#1#2{#2}
    \renewcommand{\yel}[2][]{#2}\renewcommand{\hilite}[2][]{#2}
  \fi
\fi

%% 
%% Copyright (C) 2017 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.
%% 
%%
%% End of file `proofread.sty'.