%%
%% This is file `fancypar.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% fancypar.dtx  (with options: `package')
%% 
%% Copyright (C) 2010, 2019 Gonzalo Medina (gmedinaar@unal.edu.co)
%% 
%% --------------------------------------------------------------------------
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2003/12/01 or later.
%% 
%% This work has the LPPL maintenance status "maintained".
%% 
%% The Current Maintainer of this work is Gonzalo Medina.
%% 
%% This work consists of the files fancypar.ins, fancypar.dtx,
%% and the derived files fancypar.sty and fancypar.pdf.
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{fancypar}[2019/01/18 v1.2 fancy paragraphs]

\@ifpackageloaded{xkeyval}{}{\RequirePackage{xkeyval}}
\@ifpackageloaded{tikz}{\usetikzlibrary{calc}}
  {\RequirePackage{tikz}\usetikzlibrary{calc}}
\@ifpackageloaded{xcolor}{}{\RequirePackage{xcolor}}

\DeclareOptionX[FP]<fancypar>{colorone}{\def\FancyZColorOne{#1}}
\DeclareOptionX[FP]<fancypar>{colortwo}{\def\FancyZColorTwo{#1}}
\DeclareOptionX[FP]<fancypar>{textcolorone}{\def\FancyZTextColorOne{#1}}
\DeclareOptionX[FP]<fancypar>{textcolortwo}{\def\FancyZTextColorTwo{#1}}
\DeclareOptionX[FP]<fancypar>{linecolor}{\def\FancyNlColor{#1}}
\DeclareOptionX[FP]<fancypar>{intercolor}{\def\FancyNilColor{#1}}
\DeclareOptionX[FP]<fancypar>{interheight}{\def\FancyNilHeight{#1}}
\DeclareOptionX[FP]<fancypar>{spiralcolor}{\def\FancyNSColor{#1}}
\DeclareOptionX[FP]<fancypar>{textcolor}{\def\FancyNTextColor{#1}}
\DeclareOptionX[FP]<fancypar>{nbtextwidth}{\def\FancyNTWidth{#1}}
\DeclareOptionX[FP]<fancypar>{mark}{\def\FancyMark{#1}}
\DeclareOptionX[FP]<fancypar>{rulecolor}{\def\FancyUColor{#1}}
\DeclareOptionX[FP]<fancypar>{separation}{\def\FancyDSeparation{#1}}
\DeclareOptionX[FP]<fancypar>{dashcolor}{\def\FancyDColor{#1}}
\DeclareOptionX[FP]<fancypar>{dashsymbol}{\def\FancyDSymbol{#1}}

\newlength\textindent{}
\newlength\textindentright{}
\setlength\textindentright{\textwidth}
\addtolength\textindentright{-2cm}

\define@boolkey[FP]{fancypar}{spiral}{%
\ifFP@fancypar@spiral
  \setlength\textindent{-2.6mm}%
\else
  \setlength\textindent{3mm}%
\fi
}

\define@choicekey+[FP]{fancypar}{position}[\val\nr]{left,right}{%
  \ifcase\nr\relax
    \def\FancyMarkPosition{\llap{\mbox{\FancyMark\quad}}\box\linebox}
  \or
    \def\FancyMarkPosition{\box\linebox\rlap{\mbox{\quad\FancyMark}}}
  \fi 
}{%
  \PackageWarning{fancypar}{erroneous input ignored}%
}

\DeclareOptionX*{\PackageWarning{fancypar}{‘\CurrentOption’ ignored}}

\definecolor{zcolori}{RGB}{185,211,238}%SlateGray2
\definecolor{zcolorii}{RGB}{188,238,104}%DarkOliveGreen2
\definecolor{lcolor}{RGB}{159,182,205}%SlateGray3
\definecolor{scolor}{RGB}{205,205,180}%LightYellow3
\definecolor{rcolor}{RGB}{162,205,90}%DarkOliveGreen3

\ExecuteOptionsX[FP]<fancypar>{%
  colorone=zcolori,%
  colortwo=zcolorii!90!white!70,%
  textcolorone=black,%
  textcolortwo=black,%
  linecolor=lcolor!80,%
  intercolor=green!20,%
  interheight=1pt,%
  spiralcolor=scolor,%
  spiral=true,%
  textcolor=black,%
  nbtextwidth=\textindentright,%
  mark=$\surd$,% \changes{v 1.1}{2010/04/25}{changed to $\surd$}
  rulecolor=rcolor,%
  position=right,%
  dashcolor=blue!50,%
  separation=0.9em,%
  dashsymbol=--
}

\ProcessOptionsX[FP]<fancypar>

\DeclareRobustCommand*\fancyparsetup[1]{%
  \setkeys[FP]{fancypar}{#1}
}

%%%% notebook %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\NotebookPar[2][]{%
  \begingroup
  \setkeys[FP]{fancypar}{#1}
  \renewcommand\FancyPreFormat{\smallskip}
  \renewcommand\FancyFormat{%
    \hskip\textindent%
    \tikz{%
      \draw[draw=black,fill=white] (-1,-0.3) circle (3pt);%
      \ifFP@fancypar@spiral
        \draw[very thin,rotate=4,double=\FancyNSColor,%
          double distance=1.5pt]%
          (-1,-0.2) arc (40:-250:10pt and 2pt);%
      \else\relax
      \fi
    }
    \hskip4mm\vphantom{\strut}%
    \textcolor{\FancyNTextColor}{\box\linebox}%
    \color{\FancyNilColor}\hrule height\FancyNilHeight%
    \smallskip%
  }
  \setlength\parindent{0pt}
  \par\vskip\baselineskip
  \noindent%
  \begin{tikzpicture}[inner sep=-1.1pt]%
    \setlength\fboxsep{0pt}%
    \node (a) {\colorbox{\FancyNlColor}{%
      \vbox{%
        \vskip-0.5mm\parshape 1 0cm \FancyNTWidth%
         \def\par{{\@@par}}% A trick that executes the real "par" = \@@par inside a group so that the parshape is restored. Thanks to Frank Mittelbach.
         #2\@@par
         \add@fancy@format%
      }%
    }%
  } {};
  \end{tikzpicture}
  \par\bigskip
  \endgroup
}

\newcounter{fancycount}
\newcommand\FancyZColor{}
\renewcommand\FancyZColor{%alternate line colors
  \ifodd\thefancycount %
    \FancyZColorOne%
  \else
    \FancyZColorTwo%
  \fi
}

\newcommand\FancyZTextColor{}
\renewcommand\FancyZTextColor{%alternate text colors
  \ifodd\thefancycount %
    \FancyZTextColorOne%
  \else
    \FancyZTextColorTwo%
  \fi
}

%%%% zebra %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\ZebraPar[2][]{%
  \begingroup
  \setkeys[FP]{fancypar}{#1}%
  \renewcommand\FancyPreFormat{\setcounter{fancycount}{0}}%
  \renewcommand\FancyFormat{%
    \noindent\stepcounter{fancycount}%
    \makebox[\textwidth]{\colorbox{\FancyZColor}{%
      \textcolor{\FancyZTextColor}{\box\linebox}}}%
    \hrule height 0pt%
  }
  \par\smallskip\noindent%
  \vbox{#2\par\add@fancy@format}%
  \par\smallskip%
  \endgroup
}

\def\leaderfill{%
  \color{\FancyDColor}%
  \xleaders\hbox to \FancyDSeparation{\hss\FancyDSymbol\hss}\hfill%
}

%%%% dashed %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\DashedPar[2][]{%
  \begingroup
  \setkeys[FP]{fancypar}{#1}%
  \renewcommand\FancyPreFormat{%
    \hbox to \textwidth{\leaderfill}%
    \vskip-\baselineskip%
  }
  \renewcommand\FancyFormat{%
    \vphantom{\strut}\box\linebox%
    \hbox to \textwidth{\leaderfill}%
    \vskip-\baselineskip%
  }
  \par\medskip
  \vbox{\noindent#2\par\add@fancy@format\medskip}%
  \par\bigskip
  \endgroup
}%

%%%% marked %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\MarkedPar[2][]{%
  \begingroup
  \setkeys[FP]{fancypar}{#1}
  \renewcommand\FancyPreFormat{}
  \renewcommand\FancyFormat{%
    \noindent%
    \FancyMarkPosition\par%
  }%
  \par\medskip%
  \vbox{#2\par\add@fancy@format}%
  \par\medskip%
  \endgroup
}

%%%% underlined %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\UnderlinedPar[2][]{
  \begingroup
  \setkeys[FP]{fancypar}{#1}
  \renewcommand\FancyPreFormat{}%
  \renewcommand\FancyFormat{%
    \box\linebox\color{\FancyUColor}\hrule
    \smallskip
  }
  \par\medskip%
  \vbox{\noindent#2\par\add@fancy@format}
  \par\medskip%
  \endgroup
}

\newsavebox\linebox%
\def\add@fancy@format{%
  \setbox\linebox\lastbox
  \ifvoid\linebox\FancyPreFormat\else
    \unskip
    \unpenalty
    \unskip %Allows more than one paragraph in MarkedPar, DashedPar, ZebraPar, and UnderlinedPar. Thanks to Frank Mittelbach
    {\add@fancy@format}%
    \FancyFormat
  \fi
}

\let\AddFancyFormat\add@fancy@format

\newcommand\FancyPreFormat{}%
\newcommand\FancyFormat{}%
\endinput
%%
%% End of file `fancypar.sty'.
