%%
%% This is file `phfnote.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% phfnote.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2016 by Philippe Faist <philippe.faist@bluewin.ch>
%% 
%% This file 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
%% 2005/12/01 or later.
%% 
\NeedsTeXFormat{LaTeX2e}[2005/12/01]
\ProvidesPackage{phfnote}
    [2016/08/15 v1.0 phfnote package]
\RequirePackage{xkeyval}
\RequirePackage{kvoptions}
\RequirePackage{etoolbox}
\def\phfnote@internal@execattribs#1#2#3{%
  \@for\next:=#3\do{%
    \ifcsname #1\next\endcsname%
      \csname #1\next\endcsname%
    \else%
      \PackageWarning{phfnote}{Unknown #2: '\next'. Ignoring.}
    \fi
  }
}
\newcommand{\notetitlefont}{\sffamily\bfseries}
\newcommand{\notetitleauthorfont}{}
\newcommand{\notetitledatefont}{\footnotesize}
\newcommand{\notetitlebelowspace}{4mm}
\newcommand{\notetitletopspace}{-1.2cm}
\newcommand{\notetitlehrule}{\hrule}
\long\def\notetitle@title#1{\long\gdef\@title{#1}}
\def\phfnote@title@checksetspace#1{%
  \ifdefined\singlespace\else%
    \PackageError{phfnote}{Note title style `#1' requires the
      `setspace' package to be loaded!  Please load it, or use a
      pkgset which loads it automatically}%
  \fi%
}
\def\phfnote@setupthanksmpfootnote{%
  \def\thempfootnote{\arabic{mpfootnote}}%
  \let\footnoterule\relax%
  \let\thanks\footnote%
  \def\phfnote@mpfootmaterial{}%
  \long\def\@mpfootnotetext##1{%
    \protected@edef\@currentlabel%
         {\csname p@mpfootnote\endcsname\@thefnmark}%
    \protected@edef\@tmpa{\protect\phfnote@mympfootnotemark{\@thefnmark}{##1}%
      \protect\phfnote@mpfootnoteglue}%
    \expandafter\g@addto@macro\expandafter\phfnote@mpfootmaterial%
      \expandafter{\@tmpa}%
  }%
  \def\thanksmark[##1]{\phfnote@mympfootnotemark{##1}}%
}
\def\phfnote@finalizempfootnotes{%
  \global\setbox\@mpfootins=\vbox{%
    \parskip=0pt\parindent=0pt\parshape 1 0.04\textwidth 0.96\textwidth\relax%
    \noindent\leavevmode%
    \reset@font\footnotesize%
    \phfnote@fmt@titlefootnotes%
    \phfnote@mpfootmaterial}%
}
\def\phfnote@fmt@titlefootnotes{}
\def\phfnote@mympfootnotemark#1{\@textsuperscript{\normalfont#1}}
\def\phfnote@mpfootnoteglue{\hskip 1.2em plus 2em minus 0.5em\relax}
\def\notetitle@thanksmark{\footnotemark}
\let\phfnote@old@thanks\thanks
\def\notetitle@thanks{\@ifnextchar[\phfnote@thanks{\phfnote@thanks[]}}%]
\long\def\phfnote@thanks[#1]#2{%
  \if\relax\detokenize{#1}\relax%
    \footnotemark%
    \protected@xdef\@thanks{\@thanks\protect\footnotetext[\the\c@footnote]{#2}}%
  \else% argument, pass on to sub-commands:
    \footnotemark[#1]%
    \protected@xdef\@thanks{\@thanks\protect\footnotetext[#1]{#2}}%
  \fi%
}
\newcommand{\notetitle@style@default}{%
  \begingroup\par\raggedright%
    \phfnote@setupthanksmpfootnote%
    \vspace*{\notetitletopspace}%
    \phfnote@title@checksetspace{default}%
    \begin{minipage}{\textwidth}%
      \begin{singlespace}%
        \parskip=0pt\parindent=0pt\relax%
        {\let\phfnote@old@par\par%
          \def\par{\phfnote@old@par%
            \parskip=1.5ex\relax\parshape 1 0pt \textwidth\relax%
            \noindent}%
          \par%
          \Large  {\notetitlefont \@title}\par}%
        \vskip 2mm\relax
        \if\relax\detokenize\expandafter{\@author}\relax\else%
          \par\parshape 1 0.04\textwidth 0.96\textwidth\relax%
          {\notetitleauthorfont \@author}%
          \vskip 2mm\relax%
        \fi
        \if\relax\detokenize\expandafter{\@date}\relax\else%
          \par\parshape 1 0.04\textwidth 0.96\textwidth\relax%
          {\notetitledatefont \@date}
          \vskip 2mm\relax%
        \fi
        \global\let\@thanks\@empty%
        \phfnote@finalizempfootnotes%
      \end{singlespace}%
    \end{minipage}\par%
    \vspace*{2mm}%
    \notetitlehrule\relax%
    \par%
  \endgroup%
  \vskip\notetitlebelowspace\relax% don't change this, abstract needs to \removelastskip
}
\newcommand{\notetitle@style@small}{%
  \begingroup\par\raggedright%
    \let\footnote\thanks%
    \vspace*{\notetitletopspace}%
    {\notetitlefont \@title}%
    \hfill\makebox{\fontsize{9pt}{10pt}\selectfont {\notetitleauthorfont \@author}%
      \hspace*{2mm}--\hspace*{2mm}{\emph{\notetitledatefont \@date}}}%
    \vspace*{1mm}\notetitlehrule\relax\vspace*{1mm}%
    \par%
  \endgroup%
  \vskip\notetitlebelowspace\relax% don't change this, abstract needs to \removelastskip
}
\newcommand{\notetitle@style@article}{%
  \vspace*{-3em}%
  \begingroup
    \centering
    \let\footnote\thanks%
    {\LARGE \@title \par}%
    \vskip 1.5em%
    {\large%
      \lineskip .5em%
      \begin{tabular}[t]{c}%
        \@author%
      \end{tabular}\par}%
    \vskip 1.5em%
    {\large \@date}%
    \par%
  \endgroup%
  \par%
  \vskip 2.5em\relax%
}
\def\phfnote@do@notetitle#1{
  \if\relax\detokenize\expandafter{#1}\relax
  \else
    \ifcsname notetitle@style@#1\endcsname
      \def\phfnote@tmp@titsty{#1}%
    \else
      \PackageError{phfnote}{Unknown title style: '#1'.}{Unknown title
        style: '#1'. Please consult the package documentation for available
        styles.}
      \def\phfnote@tmp@titsty{default}%
    \fi
    \let\title\notetitle@title
    \let\thanks\notetitle@thanks
    \let\thanksmark\notetitle@thanksmark
    \def\@maketitle{\csname notetitle@style@\phfnote@tmp@titsty\endcsname}
  \fi
}
\let\notedefaultabstract\abstract
\let\endnotedefaultabstract\endabstract
\newcommand{\noteabstracttextfont}{}
\newcommand{\noteabstractnamefont}{\bfseries\small}
\if@twocolumn
  \newcommand\noteabstracttextwidth{\hsize}
\else
  \newcommand{\noteabstracttextwidth}{0.9\hsize}
\fi
\newcommand\noteabstractafterspacing{1.5em}
\newcommand\noteabstractbeforespacing{1.5em}
\def\noteabstract@nameline{
  {\parskip=0pt\relax\par\centering\noteabstractnamefont%
    \abstractname%
    \par}\vskip 1ex\relax%
}
\newenvironment{noteabstract}{%
  \removelastskip%
  \vspace{\noteabstractbeforespacing}%
  \begingroup%
    \par\noindent\centering%
    \begin{minipage}{\noteabstracttextwidth}%
      \noteabstract@nameline%
      \noteabstracttextfont%
    }%
    {%
    \end{minipage}%
    \par%
  \endgroup%
  \vspace{\noteabstractafterspacing}%
}
\def\noteabstract@attr@wide{%
  \def\noteabstracttextwidth{\textwidth}%
}
\def\noteabstract@attr@narrow{%
  \if@twocolumn
  \else
    \def\noteabstracttextwidth{0.8\textwidth}%
  \fi
}
\def\noteabstract@attr@noname{%
  \def\noteabstract@nameline{}%\vspace*{1ex}}%
}
\def\noteabstract@attr@original{%
  \let\abstract\notedefaultabstract
  \let\endabstract\endnotedefaultabstract
}
\def\noteabstract@attr@small{%
  \g@addto@macro\noteabstracttextfont{\small}%
}
\def\noteabstract@attr@compact{%
  \renewcommand\noteabstractafterspacing{1ex}%
  \renewcommand\noteabstractbeforespacing{1ex}%
}
\def\noteabstract@attr@it{%
  \g@addto@macro\noteabstracttextfont{\itshape}%
}
\def\phfnote@do@noteabstract#1{
  \let\abstract\noteabstract
  \let\endabstract\endnoteabstract
  \phfnote@internal@execattribs{noteabstract@attr@}{abstract attribute}{#1}
}
\def\phfnote@pagegeomstyle@default{
  \if@twocolumn
    \PassOptionsToPackage{hmargin=1in,vmargin=0.75in,includeheadfoot}{geometry}%
  \else
    % fix the margins a bit to make text wider
    \ifcase\@ptsize% mods for 10 pt
      \PassOptionsToPackage{hmargin=1.5in,vmargin=1.25in}{geometry}%
    \or% mods for 11 pt
      \PassOptionsToPackage{hmargin=1.5in,vmargin=1.25in}{geometry}%
    \or% mods for 12 pt
      \PassOptionsToPackage{hmargin=1.25in,vmargin=1.25in}{geometry}%
    \fi%
  \fi
}
\def\phfnote@pagegeomstyle@narrow{
  \if@twocolumn
    \PassOptionsToPackage{hmargin=1.25in,vmargin=0.75in,includeheadfoot}{geometry}%
  \else
    % fix the margins a bit to make text wider
    \ifcase\@ptsize% mods for 10 pt
      \PassOptionsToPackage{hmargin=1.75in,vmargin=1.5in}{geometry}%
    \or% mods for 11 pt
      \PassOptionsToPackage{hmargin=1.75in,vmargin=1.5in}{geometry}%
    \or% mods for 12 pt
      \PassOptionsToPackage{hmargin=1.5in,vmargin=1.5in}{geometry}%
    \fi%
  \fi
}
\def\phfnote@pagegeomstyle@wide{
  \if@twocolumn
    \PassOptionsToPackage{hmargin=0.75in,vmargin=0.75in,includeheadfoot}{geometry}%
  \else
    % fix the margins a bit to make text wider
    \ifcase\@ptsize% mods for 10 pt
      \PassOptionsToPackage{hmargin=1.25in,vmargin=1.25in}{geometry}%
    \or% mods for 11 pt
      \PassOptionsToPackage{hmargin=1.25in,vmargin=1.25in}{geometry}%
    \or% mods for 12 pt
      \PassOptionsToPackage{hmargin=1in,vmargin=1.25in}{geometry}%
    \fi%
  \fi
}
\def\phfnote@pagegeomstyle@xwide{
  \if@twocolumn
    \PassOptionsToPackage{hmargin=0.5in,vmargin=0.5in,includeheadfoot}{geometry}%
  \else
    % fix the margins a bit to make text wider
    \ifcase\@ptsize% mods for 10 pt
      \PassOptionsToPackage{hmargin=1in,vmargin=1.25in}{geometry}%
    \or% mods for 11 pt
      \PassOptionsToPackage{hmargin=1in,vmargin=1.25in}{geometry}%
    \or% mods for 12 pt
      \PassOptionsToPackage{hmargin=0.75in,vmargin=1.25in}{geometry}%
    \fi%
  \fi
}
\def\phfnote@pagegeomstyle@bigmargin{%
  \if@twocolumn
    \PassOptionsToPackage{hmargin=1.5in,vmargin=0.75in,includeheadfoot}{geometry}%
  \else
    % fix the margins a bit to make text wider
    \ifcase\@ptsize% mods for 10 pt
      \PassOptionsToPackage{hmargin={2.25in,1.75in},vmargin=1.25in}{geometry}%
    \or% mods for 11 pt
      \PassOptionsToPackage{hmargin={2.25in,1.75in},vmargin=1.25in}{geometry}%
    \or% mods for 12 pt
      \PassOptionsToPackage{hmargin={2in,1.5in},vmargin=1.25in}{geometry}%
    \fi%
  \fi
}
\newcommand{\phfnote@do@pagegeomdefs}[1]{
  \ifcsname phfnote@pagegeomstyle@#1\endcsname
    \csname phfnote@pagegeomstyle@#1\endcsname
  \else
    \PackageWarning{phfnote}{Unknown page geometry style: `#1'!}
  \fi

  \RequirePackage{geometry}%
}
\def\phfnote@do@spacing{
  \@ifpackageloaded{setspace}{
    \def\phfnote@dostretch##1{%
      \setstretch{##1}\phfnote@docaptionstretch{##1}}
  }{
    \def\phfnote@dostretch##1{%
      \renewcommand\baselinestretch{##1}\phfnote@docaptionstretch{##1}}
  }
  \@ifpackageloaded{caption}{
    \def\phfnote@docaptionstretch##1{\captionsetup{font={stretch=##1}}}
  }{
    \def\phfnote@docaptionstretch##1{\PackageWarning{phfnote}{Can't
        set line spacing for captions, because the package `caption'
        is not loaded.  Please load it before `phfnote', or use an
        appropriate (e.g. `rich') pkgset which loads this package
        automatically .}}
  }
  \if@twocolumn
    \phfnote@dostretch{1.0} % leave default
    \emergencystretch=3em\relax
  \else
    \ifcase\@ptsize% 10pt
      \phfnote@dostretch{1.1}
    \or% 11pt
      \phfnote@dostretch{1.0} % 1.05? better 1.0...
    \or% 12pt
      \phfnote@dostretch{1.0} % 1.03? not really noticeable...
    \fi
    \emergencystretch=6em\relax
  \fi
}
\def\phfnote@par@original{%
}
\def\phfnote@par@indent{%
  \parindent=1.5em\relax
  \parskip=0pt\relax
}
\def\phfnote@par@indentminiskip{%
  \parindent=1.5em\relax
  \parskip=0.3em plus 0.1em\relax
}
\def\phfnote@par@skip{%
  \parindent=0pt\relax
  \parskip=0.8em plus 0.2em minus 0.1em\relax
}
\def\phfnote@do@par#1{%
  \ifcsname phfnote@par@#1\endcsname
    \csname phfnote@par@#1\endcsname
  \else
    \PackageWarning{phfnote}{Bad paragraph setting: #1. Leaving original}
  \fi
}
\newcommand{\notesectionallfont}{%
  \fontfamily{\notesectionallfontfamily}\fontseries{bx}\selectfont}
\newcommand{\notesectionallfontfamily}{ppl}
\newcommand{\notesectionfont}{\large}
\newcommand{\notesubsectionfont}{\normalsize}
\newcommand{\notesubsubsectionfont}{\small}
\newcommand{\noteparagraphfont}{\normalsize}
\newcommand{\notesubparagraphfont}{\normalsize}
\newcommand{\notesectionsetfonts}[3]{%
  \renewcommand{\notesectionfont}{#1}%
  \renewcommand{\notesubsectionfont}{#2}%
  \renewcommand{\notesubsubsectionfont}{#3}%
}
\newcommand{\noteparagraphsetfonts}[2]{%
  \renewcommand{\noteparagraphfont}{#1}%
  \renewcommand{\notesubparagraphfont}{#2}%
}
\def\phfnote@do@secfmt@section{
  \RequirePackage{sectsty}
  \sectionfont{\notesectionallfont\notesectionfont}
  \subsectionfont{\notesectionallfont\notesubsectionfont}
  \subsubsectionfont{\notesectionallfont\notesubsubsectionfont}
}
\def\phfnote@do@secfmt@paragraph{
  \RequirePackage{sectsty}
  \paragraphfont{\notesectionallfont\noteparagraphfont}
  \subparagraphfont{\notesectionallfont\notesubparagraphfont}
}
\def\phfnote@do@secfmt@compact{
  \notesectionsetfonts{\normalsize}{\small}{\small}
}
\def\phfnote@do@secfmt@larger{
  \notesectionsetfonts{\Large}{\large}{\normalsize}
}

\def\phfnote@do@secfmt@secsquares{
  \RequirePackage{amssymb}
  \let\phfnote@secsquares@old@seccntformat\@seccntformat
  \def\@seccntformat##1{%
    \expandafter\ifx\csname ##1\endcsname\section\relax%
    \unexpanded{\makebox[0pt][r]{\raisebox{0.15ex}{{%
            \notesmaller[0.6]\ensuremath{\blacksquare}}}%
        \hspace*{1.2ex}}}%
    \fi%
    \phfnote@secsquares@old@seccntformat{##1}}
}
\def\phfnote@do@secfmt@secnummargin{
  \let\phfnote@secnummargin@old@seccntformat\@seccntformat
  \def\@seccntformat##1{%
    \protect\makebox[0pt][r]{\phfnote@secnummargin@old@seccntformat{##1}}}
}

\def\phfnote@do@secfmt@rmfamily{
  \renewcommand\notesectionallfontfamily{\rmdefault}
}
\def\phfnote@do@secfmt@sffamily{
  \renewcommand\notesectionallfontfamily{\sfdefault}
}
\def\phfnote@do@secfmt@itpar{
  \def\noteparagraphfont{\normalfont\normalsize\itshape}
  \def\notesubparagraphfont{\normalfont\normalsize\itshape}
}
\def\phfnote@do@secfmt@blockpar{
  \let\phfnote@old@paragraph\paragraph
  \def\paragraph##1{%
    \phfnote@old@paragraph{##1}%
    \hspace*{0pt}\par\nopagebreak% ugly hack!!
  }
}
\def\phfnote@do@secfmt#1{%
  \phfnote@internal@execattribs{phfnote@do@secfmt@}{section formatting preset}{#1}
}
\def\phfnote@do@pkgset@none{
}

\def\phfnote@do@pkgset@minimal{

  \RequirePackage{amsmath}
  \RequirePackage{amsfonts}
  \RequirePackage{amssymb}
  \RequirePackage{amsthm}

  \RequirePackage{xcolor}

}

\def\phfnote@do@pkgset@rich{

  \phfnote@do@pkgset@minimal

  \RequirePackage{setspace}
  \RequirePackage{caption}

  \RequirePackage{microtype}

  \PassOptionsToPackage{shortlabels}{enumitem}
  \RequirePackage{enumitem}

  \RequirePackage{graphicx}

  \PassOptionsToPackage{T1}{fontenc}
  \RequirePackage{fontenc}

  \PassOptionsToPackage{utf8}{inputenc}
  \RequirePackage{inputenc}
}

\def\phfnote@do@pkgset@extended{

  \phfnote@do@pkgset@rich

  \RequirePackage{float}

  \RequirePackage{verbdef}

  \PassOptionsToPackage{autostyle,autopunct=true}{csquotes}
  \RequirePackage{csquotes}

  \RequirePackage{dsfont}
  \RequirePackage{bbm}
  \RequirePackage{mathtools}

}
\def\phfnote@do@pkgset#1{
  \phfnote@internal@execattribs{phfnote@do@pkgset@}{package set}{#1}
}
\newcommand{\phfnote@do@pdfhyperrefdefs}{%
  \phfnote@requirecolorpackage%
  \definecolor{docnotelinkcolor}{rgb}{0,0,0.4}%
  \RequirePackage{url}%
  \DeclareUrlCommand\phfnote@format@url{}%
  \PassOptionsToPackage{bookmarks=true,backref=false}{hyperref}%
  \RequirePackage{hyperref}%
  %
  \hypersetup{unicode=true,%
    bookmarksnumbered=false,bookmarksopen=false,bookmarksopenlevel=1,%
    breaklinks=true,pdfborder={0 0 0},colorlinks=true}%
  \hypersetup{%
    anchorcolor=docnotelinkcolor,citecolor=docnotelinkcolor,%
    filecolor=docnotelinkcolor,linkcolor=docnotelinkcolor,%
    menucolor=docnotelinkcolor,runcolor=docnotelinkcolor,%
    urlcolor=docnotelinkcolor}%
  \let\email\phfnote@email%
  \urlstyle{notesf}%
}
\newcommand{\phfnotePdfLinkColor}[1]{%
  \@ifpackageloaded{xcolor}{%
    \colorlet{docnotelinkcolor}{#1}%
  }{% else:
    \PackageWarning{phfnote}{\protect\phfnotePdfLinkColor may only be
      used if the package xcolor is loaded.}%
  }%
}
\def\phfnote@sanitize@url{%
  \catcode`\$12%
  \catcode`\&12%
  \catcode`\#12%
  \catcode`\^12%
  \catcode`\_12%
  \catcode`\%12%
  % \catcode`\^^J10%  newline = space
  % \catcode`\^^M10%  newline = space
  \relax%
}%
\providecommand\phfnote@format@url{\texttt}
\def\phfnote@email{\begingroup\phfnote@sanitize@url\phfnote@impl@email@}%
\def\phfnote@impl@email@#1{\endgroup\href{mailto:#1}{\phfnote@format@url{#1}}}%
\def\phfnote@requirecolorpackage{%
  \@ifpackageloaded{color}{%
  }{%
    \@ifpackageloaded{xcolor}{%
    }{%
      \RequirePackage{xcolor}%
    }%
  }%
}
\def\phfnote@do@fontdefs{

  \PassOptionsToPackage{T1}{fontenc}
  \RequirePackage{fontenc}

  \renewcommand\sfdefault{cmbr}

}
\newcommand{\phfnote@bibstyle}{naturemagdoi}
\newcommand{\phfnote@bibfont}{\fontsize{9}{11}\selectfont}
\let\phfnote@old@bibliography\bibliography
\let\phfnote@old@bibliographystyle\bibliographystyle
\newcommand{\phfnote@bibliography}[1]{%
  \begingroup%
    \phfnote@bibfont%
    \phfnote@old@bibliographystyle{\phfnote@bibstyle}%
    \phfnoteHackSectionStarWithTOC%
    \catcode`\&=12\relax% normal char
    \providecommand\eprint[2][]{\href{http://arxiv.org/abs/##2}{arXiv:##2}}
    \phfnote@old@bibliography{#1}%
  \endgroup%
}
\newcommand{\phfnote@bibliographystyle}[1]{%
  \renewcommand{\phfnote@bibstyle}{#1}%
}
\def\phfnote@do@bibliographydefs{%
  \let\bibliographystyle\phfnote@bibliographystyle%
  \let\bibliography\phfnote@bibliography%
}
\def\phfnote@do@footnotedefs{
  \let\phfnote@orig@makefnmark\@makefnmark
%%  \def\@makefnmark{\hbox{\@textsuperscript{%
%%      \normalfont\tiny\fontseries{sb}\selectfont\@thefnmark}}}
  \def\@makefnmark{\hbox{\@textsuperscript{%
        \normalfont\tiny\bfseries\@thefnmark}}}
%%  \def\@makefnmark{\hbox{\@textsuperscript{%
%%      \normalfont\scriptsize\bfseries\@thefnmark}}}% too large
}
\newcommand\notesmaller[1][\notesmallerfrac]{%
  \fontsize{#1\dimexpr\f@size pt\relax}{#1\dimexpr\f@baselineskip pt\relax}%
  \selectfont\ignorespaces%
}
\def\notesmallerfrac{0.9}
\newcommand{\inlinetoc}{%
  \begingroup%
    \vspace*{2mm}%
    \hrule%
    \vspace*{2mm}%
    \parskip=1pt\relax%
    \@starttoc{toc}%
    \vspace*{4mm}%
    \hrule%
    \vspace*{6mm}%
  \endgroup%
}
\def\url@notettstyle{%
  \def\UrlFont{\ttfamily\notesmaller}%
  \phfnote@urlstyle@common%
}
\def\url@notesfstyle{%
  \def\UrlFont{\sffamily\notesmaller}%
  \phfnote@urlstyle@common%
}
\def\url@notesfssstyle{%
  \def\UrlFont{\fontfamily{cmss}\selectfont\notesmaller}%
  \phfnote@urlstyle@common%
}
\def\url@noteitsfstyle{%
  \def\UrlFont{\sffamily\itshape\notesmaller}%
  \phfnote@urlstyle@common%
}
\def\url@notermstyle{%
  \def\UrlFont{\rmfamily\notesmaller}%
  \phfnote@urlstyle@common%
}
\def\url@noteitstyle{%
  \def\UrlFont{\itshape\notesmaller}%
  \phfnote@urlstyle@common%
}
\def\url@notesmlstyle{%
  \def\UrlFont{\notesmaller}%
  \phfnote@urlstyle@common%
}
\def\phfnote@url@tilde{\hbox{\fontfamily{ptm}\selectfont\textasciitilde}}
%%\def\phfnote@url@tilde{\raise-0.8ex\hbox{%
%%    \kern-0.2ex\fontfamily{cmbr}\selectfont\textasciitilde}}
\def\phfnote@urlstyle@common{%
  \def\UrlTildeSpecial{\do\~{\phfnote@url@tilde}}%
  \let\Url@force@Tilde\UrlTildeSpecial%
}
\def\phfnoteHackSectionStarWithTOC{%
    \let\phfnote@old@section\section%
    \def\section*##1{\phfnote@old@section*{##1}\addcontentsline{toc}{section}{##1}}%
}
\def\phfnoteHackSectionStarWithTOCInCommand#1{%
  \expandafter\let\csname phfnote@old@\string#1\endcsname#1%
  \gdef#1{%
    \begingroup%
    \phfnoteHackSectionStarWithTOC%
    \csname phfnote@old@\string#1\endcsname%
    \endgroup%
  }%
}
\def\phfnoteSaveDefs#1#2{%
  \csgdef{phfnote@restoredefs@#1}{}%
  \def\@tmpa{#2}%
  \@for\next:=\@tmpa\do{%
    \global\csletcs{phfnote@restoredefs@#1@\next}{\next}%
    \expandafter\xappto\csname phfnote@restoredefs@#1\endcsname{%
      \noexpand\csletcs{\next}{phfnote@restoredefs@#1@\next}%
    }%
  }%
}
\def\phfnoteRestoreDefs#1{%
  \ifcsname phfnote@restoredefs@#1\endcsname%
    \csname phfnote@restoredefs@#1\endcsname%
  \else%
    \PackageError{phfnote}{\string\phfnoteRestoreDefs: no such
      definitions stored (#1)}
  \fi%
}
\def\phfverb#1{%
  \ifx\protect\relax%
    \phfverbfmt{\detokenize{#1}\unskip}%
  \else%
    \noexpand\phfverb{\unexpanded{#1}}%
  \fi%
}
\def\phfverbfmt#1{{\normalfont\texttt{#1}}}
\SetupKeyvalOptions{
  family=phfnote,
  prefix=phfnote@opt@
}
\DeclareStringOption[default]{title}
\DeclareStringOption[]{abstract}
\DeclareStringOption[rich]{pkgset}
\DeclareBoolOption[true]{pagegeomdefs}
\DeclareComplementaryOption{nopagegeomdefs}{pagegeomdefs}
\DeclareStringOption[default]{pagegeom}
\DeclareStringOption[section]{secfmt}
\DeclareStringOption[skip]{par}
\DeclareBoolOption[true]{spacingdefs}
\DeclareComplementaryOption{nospacingdefs}{spacingdefs}
\DeclareBoolOption[true]{fontdefs}
\DeclareComplementaryOption{nofontdefs}{fontdefs}
\DeclareBoolOption[true]{footnotedefs}
\DeclareComplementaryOption{nofootnotedefs}{footnotedefs}
\DeclareBoolOption[true]{hyperrefdefs}
\DeclareComplementaryOption{nohyperrefdefs}{hyperrefdefs}
\DeclareBoolOption[true]{bibliographydefs}
\DeclareComplementaryOption{nobibliographydefs}{bibliographydefs}
\define@key{phfnote}{preset}{%
  \ifcsname phfnote@preset@#1\endcsname%
    \csname phfnote@preset@#1\endcsname%
  \else%
    \PackageError{phfnote}{Unknown preset: `#1'!}{You specified the
      option 'preset=...' with an invalid value.  Please look up the
      package documentation corresponding to your version of phfnote
      for possible values.}
  \fi%
}
\DeclareDefaultOption{%
  \@unknownoptionerror
}
\def\phfnote@hook@atendload{}
\def\phfnote@preset@article{
  \def\phfnote@opt@title{article}
  \def\phfnote@opt@par{indent}
  \def\phfnote@opt@pagegeom{default}
}
\newcommand\phfnote@presetcommon@xnote[1][noteitsf]{
  \def\phfnote@opt@title{default}
  \def\phfnote@opt@par{skip}
  \phfnote@opt@pagegeomdefstrue
  \def\phfnote@opt@pagegeom{wide}
  \setlength{\footnotesep}{5pt}
  \g@addto@macro\phfnote@hook@atendload{
    \ifdefined\urlstyle
      \urlstyle{#1}
    \fi
  }
}
\def\phfnote@preset@sfnote{
  \phfnote@presetcommon@xnote
  \phfnote@opt@footnotedefstrue
  \phfnote@opt@fontdefstrue
  \renewcommand\familydefault{\sfdefault}
  \renewcommand{\notesectionallfontfamily}{\sfdefault}
}
\def\phfnote@preset@sfssnote{
  \phfnote@preset@sfnote
  \phfnote@opt@fontdefsfalse
  \PassOptionsToPackage{T1}{fontenc}
  \RequirePackage{fontenc}
  \renewcommand\sfdefault{cmss}
}
\def\phfnote@preset@opensansnote{
  \phfnote@preset@sfnote
  \phfnote@opt@fontdefsfalse
  \PassOptionsToPackage{T1}{fontenc}
  \RequirePackage{fontenc}
  \PassOptionsToPackage{default,osfigures,scale=0.9}{opensans}
  \RequirePackage{opensans}
}
\def\phfnote@preset@utopianote{
  \phfnote@presetcommon@xnote[noteit]
  \phfnote@opt@fontdefsfalse
  \PassOptionsToPackage{T1}{fontenc}
  \RequirePackage{fontenc}
  \RequirePackage{fourier}
  \renewcommand{\notesectionallfontfamily}{put}
  \renewcommand{\notetitlefont}{\bfseries}
  \renewcommand{\sfdefault}{phv}
}
\def\phfnote@preset@mnmynote{
  \phfnote@presetcommon@xnote[noteit]
  \phfnote@opt@footnotedefsfalse
  \phfnote@opt@fontdefsfalse
  \PassOptionsToPackage{T1}{fontenc}
  \RequirePackage{fontenc}
  \renewcommand{\notesectionallfontfamily}{\sfdefault}
  \g@addto@macro\phfnote@hook@atendload{
    \RequirePackage{MnSymbol}
    \PassOptionsToPackage{medfamily,textosf,mathlf,minionint,footnotefigures}{MinionPro}
    \RequirePackage{MinionPro}
    \PassOptionsToPackage{medfamily}{MyriadPro}
    \RequirePackage{MyriadPro}
  }
}
\def\phfnote@preset@pkgdoc{
  \phfnote@presetcommon@xnote[noteit]
  \phfnote@opt@fontdefsfalse
  \phfnote@pkgdoc@setupfont
  \def\phfnote@opt@secfmt{section,paragraph,itpar,blockpar,larger,secsquares,secnummargin}
  \def\phfnote@opt@pagegeom{bigmargin}
  \def\phfnote@opt@abstract{noname}
}
\providecommand\phfnote@pkgdoc@setupfont{
  \PassOptionsToPackage{T1}{fontenc}
  \RequirePackage{fontenc}
  \phfnote@pkgdoc@setupmainfont
  \renewcommand{\notesectionallfontfamily}{put}
  \renewcommand{\notetitlefont}{\bfseries}
  \IfFileExists{opensans.sty}{}{\PackageError{phfnote}{Font OpenSans is not
      available (need `opensans' package)}{Please install the opensans
      package, which provides the OpenSans font.}}
  \def\opensans@scale{s*[0.85]}
  \renewcommand{\sfdefault}{fosj}
}
\providecommand\phfnote@pkgdoc@setupmainfont{\RequirePackage{fourier}}
\def\phfnote@preset@xpkgdoc{
  \phfnote@preset@pkgdoc
  \RequirePackage{verbdef}
  \ifdefined\PrintChanges
    \phfnoteHackSectionStarWithTOCInCommand\PrintChanges
  \fi
  \ifdefined\PrintIndex
    \phfnoteHackSectionStarWithTOCInCommand\PrintIndex
  \fi
  \def\PrintChangesAndIndexSpacing{\vspace{3cm plus 2cm minus 2cm}}
  \def\PrintChangesAndIndex{\PrintChangesAndIndexSpacing\PrintChanges
    \PrintChangesAndIndexSpacing\PrintIndex}
  \ifdefined\c@IndexColumns
    \setcounter{IndexColumns}{2}
  \fi
  \let\phfnote@xpkgdoc@old@theglossary\theglossary
  \let\phfnote@xpkgdoc@old@endtheglossary\endtheglossary
  \renewenvironment{theglossary}{%
    \glossary@prologue%
    \GlossaryParms \let\item\@idxitem \ignorespaces}
  {}
  \phfnote@opt@hyperrefdefsfalse
  \g@addto@macro\phfnote@hook@atendload{
    \definecolor{docnotelinkcolor}{rgb}{0,0,0.4}%
    \RequirePackage{url}%
    \DeclareUrlCommand\phfnote@format@url{}%
    \RequirePackage{hypdoc}
    %
    \hypersetup{bookmarks=true,backref=false,unicode=true,%
      bookmarksnumbered=false,bookmarksopen=false,bookmarksopenlevel=1,%
      breaklinks=true,pdfborder={0 0 0},colorlinks=true}%
    \hypersetup{%
      anchorcolor=docnotelinkcolor,citecolor=docnotelinkcolor,%
      filecolor=docnotelinkcolor,linkcolor=docnotelinkcolor,%
      menucolor=docnotelinkcolor,runcolor=docnotelinkcolor,%
      urlcolor=docnotelinkcolor}%
    \let\email\phfnote@email%
    \urlstyle{noteit}
  }
  \def\pkgname##1{%
    \pkgnamefmt{##1}%
    \index{##1=\pkgnamefmt{##1}|hyperpage}%
    \index{packages:>##1=\pkgnamefmt{##1}|hyperpage}%
  }
  \robustify\pkgname
  \def\pkgnamefmt##1{\textsf{##1}}
  \robustify\pkgnamefmt
  \newcounter{phfnotechanged}
  \newcommand*\changed[4][]{%
    \if\relax\detokenize{##1}\relax%
      \changedtextfmt{##2}{##3}{##4}%
      \changes{##2}{##3}{##4}%
    \else%
      \protected@edef\phfnotechanged@tmpa{{##2}{##3}{##4}}%
      \immediate\write\@auxout{\string\phfnote@changed@set%
        {##1}{\expandonce\phfnotechanged@tmpa}}%
      \par\hspace*{0pt}\refstepcounter{phfnotechanged}\label{phfnotechanged:##1}%
      \begingroup\let\phfnote@changedreftext@par\relax
        \changedreftext{##1}%
      \endgroup
      \changes{##2}{##3}{\hyperref[phfnotechanged:##1]{##4}}%
    \fi
  }
  \def\phfnote@changed@set##1{%
    \expandafter\gdef\csname phfnote@changed@lbl@##1\endcsname%
  }
  \def\phfnote@changedreftext@par{\par}
  \newcommand*\changedreftext[1]{%
    \phfnote@changedreftext@par%
    \ifcsname phfnote@changed@lbl@##1\endcsname
      \hyperref[phfnotechanged:##1]{%
        \expandafter\expandafter\expandafter\changedtextfmt%
            \csname phfnote@changed@lbl@##1\endcsname
      }
    \else
      \hyperref[phfnotechanged:##1]{%
        \changedtextfmt{???}{???}{[\textbf{missing ref}]}%
      }%
    \fi
    \par
  }
  \newcommand*\changedtextfmt[3]{%
    \textit{Changed in {##1\kern 0.3ex\relax[##2]}:} ##3.
  }
  \RequirePackage{enumitem}
  \newlist{pkgoptions}{description}{1}
  \setlist[pkgoptions]{font=\pkgoptionfmt[{\vspace*{5pt}}],style=nextline}
  \apptocmd\pkgoptions{\let\pkgoptions@old@item\item%
    \def\item{\@ifnextchar[\pkgoptions@item@\pkgoptions@item@@}%]
    \def\pkgoptions@item@[##1]{\pkgoptions@old@item[{{##1}}]}%
    \def\pkgoptions@item@@{\PackageWarning{phfnote}{{pkgoptions}: you must
        specify label to \string\item as \string\item[label].}%
      \pkgoptions@old@item}%
  }{}{\PackageWarning{phfnote}{preset xpkgdoc: Failed to patch command
      \string\pkgoptions}}
  \def\pkgoptionscombineitem{\leavevmode\vspace{\dimexpr-\baselineskip-\parskip-\itemsep\relax}}
  \def\metatruefalsearg{\meta{\phfverb{true} $\mid$ \phfverb{false}}}
  \newcommand\pkgoptionfmt[2][]{%
    \begingroup\let\meta\pkgoptfmt@meta\fbox{\normalfont\ttfamily ##2}\endgroup%
    \expandafter\phfnote@pkgdoc@index\expandafter{\@firstofone ##2}%
    ##1}
  \let\pkgopt@save@meta\meta
  \def\pkgoptfmt@meta##1{\begingroup\normalfont\itshape\pkgopt@save@meta{##1}\endgroup}
  \def\phfnote@pkgdoc@index##1{%
    \begingroup\lccode`\= = `\,\relax%
      \def\x{\lowercase{\def\@tmpa{##1}}}%
      \x%
      \let\meta\@gobble%
      \let\marg\@gobble%
      \let\oarg\@gobble%
      \let\parg\@gobble%
      \let\pkgoptattrib\@firstofone%
      \let\pkgoptattribnodots\@firstofone%
      \let\pkgoptattribempty\@empty%
      \def\handleitemindex####1{%
        \edef\@tmpc{####1}%
        \if\relax\detokenize\expandafter{\@tmpc}\relax\else%
          \edef\@tmpb{{\expandonce\@tmpc=\string\verb!*+\expandonce\@tmpc+ (\pkgoptname)|hyperpage}}%
          \expandafter\index\@tmpb%
          \edef\@tmpb{{\packageoptionsname:>\expandonce\@tmpc=\string\verb!*+\expandonce\@tmpc+|hyperpage}}%
          \expandafter\index\@tmpb%
        \fi%
      }%
      \def\@tmpc{\forcsvlist{\handleitemindex}}%
      \expandafter\@tmpc\expandafter{\@tmpa}%
    \endgroup%
  }
  \def\pkgoptname{pkg. opt.}
  \def\packageoptionsname{package options}
  \def\cmdoptions{\begingroup\setcmdnotpkgoptions
    \pkgoptions}
  \def\endcmdoptions{\endpkgoptions\endgroup}
  \newcommand\cmdoptionfmt[2][]{\begingroup\setcmdnotpkgoptions
    \pkgoptionfmt[{##1}]{##2}\endgroup}
  \def\cmdoptname{cmd. opt.}
  \def\commandoptionsname{command options}
  \def\setcmdnotpkgoptions{\let\pkgoptname\cmdoptname
    \let\packageoptionsname\commandoptionsname
    \let\fbox\cmdoptionsfbox}
  \def\cmdoptionsfbox##1{\ensuremath{\underline{{\text{##1}}}}}
  \def\pkgoptattrib##1{\{##1,...\}}
  \def\pkgoptattribnodots##1{\{##1\}}
  \def\pkgoptattribempty{\{\}}
  \phfnoteSaveDefs{verbatimstuff}{%
    verbatim,@verbatim,@xverbatim,@sxverbatim,endverbatim}
  \usepackage{tcolorbox}
  \newtcolorbox{pkgnote}{
    colback=blue!5!white,
    colframe=blue!5!white,
    coltitle=blue!50!black,
    toptitle=1.5ex,
    fonttitle=\bfseries,
    title={NOTE}
  }
  \newtcolorbox{pkgwarning}{
    colback=red!5!white,
    colframe=red!5!white,
    coltitle=red!50!black,
    toptitle=1.5ex,
    fonttitle=\bfseries,
    title={WARNING}
  }
  \newtcolorbox{pkgtip}{
    colback=green!5!white,
    colframe=green!5!white,
    coltitle=green!50!black,
    toptitle=1.5ex,
    fonttitle=\bfseries,
    title={TIP}
  }
  \phfnoteRestoreDefs{verbatimstuff}
  \def\phfqitltxPkgTitle##1{The \pkgname{##1} package\thanks{\itshape
    This document corresponds to \pkgname{##1}~\fileversion, dated \filedate. It
    is part of the
    \href{https://github.com/phfaist/phfqitltx/}{\pkgname{phfqitltx}} package
    suite, see \url{https://github.com/phfaist/phfqitltx}.}}
  \def\pkgfmtdate##1{%
    \edef\pkgfmtdate@thedate{##1}%
    \expandafter\pkgfmtdate@next\pkgfmtdate@thedate\@nil%
  }
  \def\pkgfmtdate@next##1/##2/##3\@nil{% YYYY/MM/DD
    \ifcase ##2 \or January\or February\or March\or April\or May%
    \or June\or July\or August\or September\or October\or November\or December\fi\space ##3,%
    \space ##1}
  \robustify\pkgfmtdate@next
}
\def\phfnote@preset@reset{
  \def\phfnote@opt@pkgset{none}
  \def\phfnote@opt@title{}
  \phfnote@opt@pagegeomdefsfalse
  \phfnote@opt@spacingdefsfalse
  \def\phfnote@opt@par{original}
  \def\phfnote@opt@abstract{original}
  \phfnote@opt@hyperrefdefsfalse
  \phfnote@opt@fontdefsfalse
  \def\phfnote@opt@secfmt{}
  \phfnote@opt@bibliographydefsfalse
  \phfnote@opt@footnotedefsfalse
}
\ProcessKeyvalOptions*
\phfnote@do@pkgset{\phfnote@opt@pkgset}

\phfnote@do@notetitle{\phfnote@opt@title}

\phfnote@do@noteabstract{\phfnote@opt@abstract}

\phfnote@do@secfmt{\phfnote@opt@secfmt}

\ifphfnote@opt@pagegeomdefs
  \phfnote@do@pagegeomdefs{\phfnote@opt@pagegeom}
\fi

\ifphfnote@opt@spacingdefs
  \phfnote@do@spacing
\fi

\phfnote@do@par{\phfnote@opt@par}

\ifphfnote@opt@hyperrefdefs
  \phfnote@do@pdfhyperrefdefs
\fi

\ifphfnote@opt@fontdefs
  \phfnote@do@fontdefs
\fi

\ifphfnote@opt@bibliographydefs
  \phfnote@do@bibliographydefs
\fi

\ifphfnote@opt@footnotedefs
  \phfnote@do@footnotedefs
\fi
\phfnote@hook@atendload
\endinput
%%
%% End of file `phfnote.sty'.
