%%
%% 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}
    [2019/04/25 v1.04 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
\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}%
  \hilite[red]{#1}%
}
\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}
      {corrected and uncorrected options are mutually exclusive}
      {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'.
