%%
%% This is file `edmargin.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% edmargin.dtx  (with options: `package')
%% 
%% IMPORTANT NOTICE:
%% 
%% For the copyright see the source file.
%% 
%% Any modified versions of this file must be renamed
%% with new filenames distinct from edmargin.sty.
%% 
%% For distribution of the original source see the terms
%% for copying and modification in the file edmargin.dtx.
%% 
%% This generated file may be distributed as long as the
%% original source files, as listed above, are part of the
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
\NeedsTeXFormat{LaTeX2e}[1997/12/01]
\ProvidesPackage{edmargin}
   [2012/09/04 v1.2 edmargin file]



\providecommand*{\ifrefundefined}[1]{%
  \expandafter\ifx\csname r@#1\endcsname\relax
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
}
\providecommand*{\@extract@ref}[2]{%
  \expandafter\expandafter\expandafter#1\csname
r@#2\endcsname{}{}\@nil
}

\providecommand*{\@extractref}{%
  \@extract@ref\@car
}

\providecommand*{\@extractpageref}{%
  \@extract@ref\@secondcar
}

\long\def\@secondcar#1#2#3\@nil{#2}

\providecommand*{\setcounterfromref}[2]{%
  \ifrefundefined{#2}{%
    \protect\G@refundefinedtrue
    \@latex@warning{Reference `#2' on page \thepage \space
        undefined}%
    \setcounter{#1}{0}%
  }{%
    \setcounter{#1}{\@extractref{#2}}%
  }%
}
\providecommand*{\setcounterfrompageref}[2]{%
  \ifrefundefined{#2}{%
    \protect\G@refundefinedtrue
    \@latex@warning{Reference `#2' on page \thepage \space
        undefined}%
    \setcounter{#1}{0}%
  }{%
    \setcounter{#1}{\@extractpageref{#2}}%
  }%
}
\long\def\appendtomacro#1#2{%
\begingroup
    \toks@\expandafter{#1#2}%
    \xdef#1{\the\toks@}%
  \endgroup}
\newcounter{allendnotes}
\setcounter{allendnotes}{1}
\newcounter{notepageholder} \setcounter{notepageholder}{1}
\newtoks{\singlepageabbrev}
\singlepageabbrev={p.}
\newcommand{\changesinglepageabbrev}[1]{\singlepageabbrev={#1}}
\newtoks{\multiplepageabbrev}
\newcommand{\changemultiplepageabbrev}[1]{\multiplepageabbrev={#1}}
\newtoks{\chapternoteslinename}
\chapternoteslinename={Chapter}
\newcommand{\changechapternotesline}[1]{\chapternoteslinename={#1}}
\multiplepageabbrev{pp.}
\@ifclassloaded{memoir}{\newcommand{\mymarks}{%
   \ifthenelse{\equal{\rightmark}{\leftmark}}%
        {\unskip ~\the\singlepageabbrev~\rightmark}% if equal
        {\unskip ~\the\multiplepageabbrev~\rightmark--\leftmark}}%if not equal
}
{\newcommand{\mymarks}{%
   \ifthenelse{\equal{\firstmark}{\botmark}}%
        {\unskip ~\the\singlepageabbrev~\firstmark}% if equal
        {\unskip ~\the\multiplepageabbrev~\firstmark--\botmark}}%if not equal
}
\@ifclassloaded{memoir}{\makepagestyle{plain}
\makeevenhead{plain}{}{}{{\small\textrm{\thepage}}}
\makeoddhead{plain}{{\small\textrm{\thepage}}}{}{}
\makeevenfoot{plain}{}{}{}
\makeoddfoot{plain}{}{}{}
\makepagestyle{endnotesstyle}
\makeevenhead{endnotesstyle}{{\small\textrm{\thepage}}}
{{\small{\em \the\notesheadername~\mymarks}}}{}
\makeoddhead{endnotesstyle}{}{{\small{\em \the\notesheadername~\mymarks}}}
{{\small\textrm{\thepage}}}
\makeevenfoot{endnotesstyle}{}{}{}
\makeoddfoot{endnotesstyle}{}{}{}
}{\fancypagestyle{plain}{%
\fancyhf{}
\fancyhead[RO,LE]{{\small\textrm{\thepage}}}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
}
\fancypagestyle{endnotesstyle}{%
\fancyhf{}
\fancyhead[CO]{{\small{\em \the\notesheadername~\mymarks}}}
\fancyhead[CE]{{\small{\em \the\notesheadername~\mymarks}}}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\fancyhead[RO,LE]{{\small\textrm{\thepage}}}
}
}
\@ifclassloaded{memoir}{\newcommand{\checknoteheaders}{%
\string\setcounterfrompageref\string{notepageholder\string}%
\string{notl\theallendnotes\string}%
\string\markboth\string{\string\thenotepageholder
\string}\string{\string\thenotepageholder\string}%
}
}{\newcommand{\checknoteheaders}{%
\string\setcounterfrompageref\string{notepageholder\string}%
\string{notl\theallendnotes\string}%
\string\mark\string{\string\thenotepageholder\string}%
}
}

\newif\ifnotesincontentson \notesincontentsonfalse
\newcommand{\notesincontents}{\notesincontentsontrue}
\newcommand{\backmatterafterheadersink}{\leavevmode\vspace{11pt}}
\newcommand{\backmattertextfont}{\small}
\def\strip#1>{}
\newcommand{\literaltextnote}[1]{%
     \begingroup%
        \def\next{#1}%
        \newlinechar='40%
        \immediate\write\textnotes{\expandafter\strip\meaning\next}%
     \endgroup%
 }
\newcommand{\literalemend}[1]{%
     \begingroup%
        \def\next{#1}%
        \newlinechar='40%
        \immediate\write\emendations{\expandafter\strip\meaning\next}%
     \endgroup%
}
\newcommand{\literalexplain}[1]{%
     \begingroup%
        \def\next{#1}%
        \newlinechar='40%
        \immediate\write\explanations{\expandafter\strip\meaning\next}%
     \endgroup%
}
\newif\iftextnoteson \textnotesonfalse
\newif\ifexplanon \explanonfalse
\newif\ifemendationson \emendationsonfalse
\newtoks{\notesheadername}
\newtoks{\edmrgnotesname}
\edmrgnotesname={TEXTUAL NOTES}
\newcommand{\changetextnotesname}[1]{\edmrgnotesname={#1}}
\newtoks{\textnotesheadername}
\textnotesheadername={Textual Notes to}
\newcommand{\changetextnotesheader}[1]{\textnotesheadername={#1}}
\newtoks{\textnotescontentsname}
\textnotescontentsname={Textual Notes}
\newcommand{\changetextnotescontentsname}[1]{\textnotescontentsname={#1}}
\newcommand{\backmatterheadingfont}{\fontsize{16}{20}\selectfont}
\newcommand{\clearemptydoublepage}{\newpage{\pagestyle{empty}\cleardoublepage}}
\newcommand{\backmattersink}{\leavevmode\vspace{21.5pt}}
\newcommand{\maketextnotes}{\global\textnotesontrue
  \newwrite\textnotes
  \immediate\openout\textnotes=\jobname.ent
  \literaltextnote{{\par\clearpage
  {\pagestyle{empty}\cleardoublepage}
\thispagestyle{empty}}
\notesheadername={\the\textnotesheadername}
\pagestyle{endnotesstyle}
\mark{3}
\backmattersink
\begin{center}{\normalfont \backmatterheadingfont \the\edmrgnotesname}\end{center}
\label{textualnotes}
\normalfont \backmattertextfont}
\immediate\write\textnotes{\string\ifnotesincontentson}%
\immediate\write\textnotes{\string\addcontentsline\string{toc\string}
\string{chapter\string}\string{\string\the\string\textnotescontentsname\string}}%
\immediate\write\textnotes{\string\fi}
}

\newtoks{\emendationsname}
\emendationsname={EMENDATIONS}
\newcommand{\changeemendationsname}[1]{\emendationsname={#1}}
\newtoks{\emendationsheadername}
\emendationsheadername={Emendations to}
\newcommand{\changeemendationsheader}[1]{\emendationsheadername={#1}}
\newtoks{\emendationscontentsname}
\emendationscontentsname={Emendations}
\newcommand{\changeemendationscontentsname}[1]{%
\emendationscontentsname={#1}}
\newcommand{\makeemendations}{\global\emendationsontrue
  \newwrite\emendations
   \immediate\openout\emendations=\jobname.emd
   \literalemend{{\par\clearpage
   {\pagestyle{empty}\cleardoublepage}
\thispagestyle{empty}}
\notesheadername={\the\emendationsheadername}
\pagestyle{endnotesstyle}
\mark{3}
\backmattersink
\begin{center}{\normalfont \backmatterheadingfont
\the\emendationsname}\end{center}
\label{emendationnotes}
\normalfont \backmattertextfont}
\immediate\write\emendations{\string\ifnotesincontentson}%
\immediate\write\emendations{\string\addcontentsline\string{toc\string}
\string{chapter\string}\string{\string\the\string\emendationscontentsname\string}}%
\immediate\write\emendations{\string\fi}
}

\newtoks{\explanationsname}
\explanationsname={EXPLANATORY NOTES}
\newcommand{\changeexplanationsname}[1]{\explanationsname={#1}}
\newtoks{\explanationsheadername}
\explanationsheadername={Explanatory Notes to}
\newcommand{\changeexplanationsheader}[1]{\explanationsheadername={#1}}
\newtoks{\explanationscontentsname}
\explanationscontentsname={Explanatory Notes}
\newcommand{\changeexplanationscontentsname}[1]{%
\explanationscontentsname={#1}}
\newcommand{\makeexplanatorynotes}{\global\explanontrue
     \newwrite\explanations
     \immediate\openout\explanations=\jobname.enx
     \literalexplain{{\par\clearpage
 {\pagestyle{empty}\cleardoublepage}
\thispagestyle{empty}}
\notesheadername={\the\explanationsheadername}
\pagestyle{endnotesstyle}
\mark{3}
\backmattersink
\begin{center}{\normalfont \backmatterheadingfont
\the\explanationsname}\end{center}
\label{explanatorynotes}
\normalfont \backmattertextfont }
\immediate\write\explanations{\string\ifnotesincontentson}%
\immediate\write\explanations{\string\addcontentsline\string{toc\string}
\string{chapter\string}\string{\string\the\string\explanationscontentsname\string}}%
\immediate\write\explanations{\string\fi}
}

\newcommand{\argpageref}[1]{\pageref{#1}}
\newcommand{\@pagemarktotextnotes}[1]{%
\immediate\write\textnotes{\string\setcounterfrompageref\string{notepageholdertitle\string}%
\string{#1\string}\string\unskip}%
\immediate\write\textnotes{\string\mark%
\string{\string\thenotepageholdertitle\string}}%
}
\newcommand{\@poempagetotextnotes}[1]{%
\immediate\write\textnotes{\string\par\string\argpageref\string{#1\string}\string\unskip}%
\@pagemarktotextnotes{#1}}
\newcommand{\@poemtitletotextnotes}[1]{\literaltextnote{\textbf{#1}}}
\newif\ifendnoteheaderson \endnoteheadersonfalse
\newcommand{\setupendnoteheaders}{%
\endnoteheadersontrue
\maketextnotes
\makeexplanatorynotes
\makeemendations
}
\newcommand{\putemendations}{
\ifemendationson
   \clearemptydoublepage
   \immediate\closeout\emendations
   \input \jobname.emd
\else
 \relax
\fi}
\newcommand{\putexplanatory}{
\ifexplanon
   \clearemptydoublepage
   \immediate\closeout\explanations
   \input \jobname.enx
\else
 \relax
\fi}
\newcommand{\puttextnotes}{
\iftextnoteson
   \clearemptydoublepage
   \immediate\closeout\textnotes
   \input \jobname.ent
\else
 \relax
\fi}
\setlength{\marginparwidth}{2em}
\newcounter{margrefnumber}
\setcounter{margrefnumber}{1}
\newtoks{\margrefmarker}
\margrefmarker={\dag}
\newcommand{\setmargrefmarker}[1]{\margrefmarker={#1}}%
\newcommand{\makemargreflabel}{\string\label\string{margref\themargrefnumber\string}}
\newcommand{\setmargref}{%
\marginpar{\scriptsize{\the\margrefmarker~\the\singlepageabbrev~\pageref{margref\themargrefnumber}}}%
}
\newcommand{\margreftextnote}{%
\iftextnoteson\addtocounter{margrefnumber}{1}%
\immediate\write\textnotes{\makemargreflabel}%
\setmargref\else\relax\fi%
}
\newcommand{\margrefexplanatory}{%
\ifexplanon\addtocounter{margrefnumber}{1}%
\immediate\write\explanations{\makemargreflabel}%
\setmargref\else\relax\fi%
}
\newcommand{\margrefemendation}{%
\ifemendationson\addtocounter{margrefnumber}{1}%
\immediate\write\emendations{\makemargreflabel}%
\setmargref\else\relax\fi%
}
\newcommand{\margrefspecial}[1]{%
\marginpar{\scriptsize {\the\margrefmarker~\the\singlepageabbrev~\pageref{#1}}}
}
\newif\ifn@temarkinmargin%
\n@temarkinmargintrue%
\newif\ifn@temarkintext%
\n@temarkintextfalse%
\newcommand{\notemarkinmargin}{\n@temarkinmargintrue\n@temarkintextfalse}
\newcommand{\notemarkintext}{\n@temarkinmarginfalse\n@temarkintexttrue}
\newcounter{enmrnotescratchcount}%
\setcounter{enmrnotescratchcount}{0}
\newtoks{\enmrendnotemarker}%
\newcommand{\makeenmrendnotemarker}{%
\enmrendnotemarker={\the\margrefmarker\theenmrnotescratchcount}}%
\newcommand{\putenmrnotemarkerintext}{%
\hbox\textsuperscript{\scriptsize{\the\enmrendnotemarker}}}%
\newif{\iftextnotespara}{\textnotesparafalse}
\newcommand{\textnotesparamode}{\textnotesparatrue}
\newif{\ifemendationspara}{\emendationsparafalse}
\newcommand{\emendationsparamode}{\emendationsparatrue}
\newif{\ifexplanationspara}{\explanationsparafalse}
\newcommand{\explanationsparamode}{\explanationsparatrue}
\newcounter{enmrtextnotecount}
\newcommand{\textnote}[1]{%
\iftextnoteson%
\margrefmarker={t:}%
\ifn@temarkinmargin%n@temarkinmargin
\margreftextnote%
\else%
\stepcounter{enmrtextnotecount}%
\setcounter{enmrnotescratchcount}{\value{enmrtextnotecount}}%
\makeenmrendnotemarker%
\putenmrnotemarkerintext%
\fi%
\stepcounter{allendnotes}\label{notl\theallendnotes}%
\immediate\write\textnotes{\checknoteheaders}%
\ifn@temarkinmargin%
\iftextnotespara\relax\else%
\immediate\write\textnotes{\string\par}\fi%
\immediate\write\textnotes{\string{\string\textbf\string{\the\singlepageabbrev\
\string\pageref\string{notl\theallendnotes\string}\string}\string}}%
\else
\iftextnotespara\relax\else%
\immediate\write\textnotes{\string\par}\fi%
\immediate\write\textnotes{\string\textsuperscript\string{\theenmrnotescratchcount\string}%
}%
\fi
\literaltextnote{~#1}%
\fi
}
\newcounter{enmrexplanatorycount}
\newcommand{\explanatory}[1]{%
\ifexplanon%
\margrefmarker={c:}%
\ifn@temarkinmargin%
\margrefexplanatory%
\else%
\stepcounter{enmrexplanatorycount}%
\setcounter{enmrnotescratchcount}{\value{enmrexplanatorycount}}%
\makeenmrendnotemarker%
\putenmrnotemarkerintext%
\fi%
\stepcounter{allendnotes}\label{notl\theallendnotes}%
\immediate\write\explanations{\checknoteheaders}%
\ifn@temarkinmargin%
\ifexplanationspara\relax\else%
\immediate\write\explanations{\string\par}\fi%
\immediate\write\explanations{\string{\string\textbf\string{\the\singlepageabbrev\
\string\pageref\string{notl\theallendnotes\string}\string}\string}}%
\else%
\ifexplanationspara\relax\else%
\immediate\write\explanations{\string\par}\fi%
\immediate\write\explanations{\string%
\textsuperscript\string{\theenmrnotescratchcount\string}%
}%
\fi
\literalexplain{~#1}%
\fi}
\newcounter{enmremendationcount}
\newcommand{\emendation}[1]{%
\ifemendationson%
\margrefmarker={e:}%
\ifn@temarkinmargin%
\margrefemendation%
\else%
\stepcounter{enmremendationcount}%
\setcounter{enmrnotescratchcount}{\value{enmremendationcount}}%
\makeenmrendnotemarker%
\putenmrnotemarkerintext%
\fi%
\stepcounter{allendnotes}\label{notl\theallendnotes}%
\immediate\write\emendations{\checknoteheaders}%
\ifn@temarkinmargin%
\ifemendationspara\relax\else%
\immediate\write\emendations{\string\par}\fi%
\immediate\write\emendations{\string{\string\textbf\string{\the\singlepageabbrev\
\string\pageref\string{notl\theallendnotes\string}\string}\string}}%
\else%
\ifemendationspara\relax\else%
\immediate\write\emendations{\string\par}\fi%
\immediate\write\emendations{\string\textsuperscript\string{\theenmrnotescratchcount\string}%
}%
\fi
\literalemend{~#1}%
\fi}
\newif\iftitleinnotes \titleinnotestrue%
\newcommand{\styleforchapternotebegin}{%
}
\newcommand{\styleforchapternoteend}{%
}
\newcommand{\setstyleforchapternotebegin}[1]{%
\renewcommand{\styleforchapternotebegin}{#1}}
\newcommand{\setstyleforchapternoteend}[1]{%
\renewcommand{\styleforchapternoteend}{#1}}%
\setstyleforchapternotebegin{\begin{center}}
\setstyleforchapternoteend{\end{center}}
\newcommand{\resettextnotes}{%
\immediate\write\textnotes{\string\begingroup}%
\immediate\write\textnotes{\string\goodbreak}%
\immediate\write\textnotes{\string\Needspace\string{5\string\baselineskip\string}}%
\immediate\write\textnotes{\string\styleforchapternotebegin}%
\immediate\write\textnotes{\the\chapternoteslinename\string\ \thechapter\string~}%
\iftitleinnotes%
\immediate\write\textnotes{\string\titleref\string{chapter\thechapter\string}}%
\fi%
\immediate\write\textnotes{\string\styleforchapternoteend}%
\immediate\write\textnotes{\string\nopagebreak}%
\immediate\write\textnotes{\string\endgroup}%
}
\newcommand{\resetemendations}{%
\immediate\write\emendations{\string\begingroup}%
\immediate\write\emendations{\string\goodbreak}%
\immediate\write\emendations{\string\Needspace\string{5\string\baselineskip\string}}%
\immediate\write\emendations{\string\styleforchapternotebegin}%
\immediate\write\emendations{\the\chapternoteslinename\string\ \thechapter\string~}%
\iftitleinnotes%
\immediate\write\emendations{\string\titleref\string{chapter\thechapter\string}}%
\fi%
\immediate\write\emendations{\string\styleforchapternoteend}%
\immediate\write\emendations{\string\nopagebreak}%
\immediate\write\emendations{\string\endgroup}%
}
\newcommand{\resetexplanatory}{%
\immediate\write\explanations{\string\begingroup}%
\immediate\write\explanations{\string\goodbreak}%
\immediate\write\explanations{\string\Needspace\string{5\string\baselineskip\string}}%
\immediate\write\explanations{\string\styleforchapternotebegin}%
\immediate\write\explanations{\the\chapternoteslinename\string\ \thechapter\string~}%
\iftitleinnotes%
\immediate\write\explanations{\string\titleref\string{chapter\thechapter\string}}%
\fi%
\immediate\write\explanations{\string\styleforchapternoteend}%
\immediate\write\explanations{\string\nopagebreak}%
\immediate\write\explanations{\string\endgroup}%
}
\newcommand{\resetendnotes}{%
\resettextnotes%
\resetemendations%
\resetexplanatory}
\newif\ifnotesbychapteron \notesbychapteronfalse
\@ifclassloaded{memoir}{\newcommand{\notesbychapter}{\notesbychapterontrue}
\addtoiargdef{\chapter}{}{ \iftitleinnotes%
   \label{chapter\thechapter}%
    \fi%
    \ifnotesbychapteron%
    \relax%
    \resetendnotes%
    \fi}
}{\newcommand{\notesbychapter}{\notesbychapterontrue}
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
                       \if@mainmatter
                         \refstepcounter{chapter}%
                         \typeout{\@chapapp\space\thechapter.}%
                         \addcontentsline{toc}{chapter}%
                                   {\protect\numberline{\thechapter}#1}%
                       \else
                         \addcontentsline{toc}{chapter}{#1}%
                       \fi
                    \else
                      \addcontentsline{toc}{chapter}{#1}%
                    \fi
                    \chaptermark{#1}%
                    \addtocontents{lof}{\protect\addvspace{10\p@}}%
                    \addtocontents{lot}{\protect\addvspace{10\p@}}%
                    \if@twocolumn
                      \@topnewpage[\@makechapterhead{#2}]%
                    \else
                      \@makechapterhead{#2}%
                      \@afterheading
                    \fi
    \iftitleinnotes%
    \label{chapter\thechapter}%
    \fi%
    \ifnotesbychapteron%
    \relax%
    \resetendnotes%
    \fi}
}
\newcommand{\m@kenewnoteif}[1]{%
\expandafter\newif\csname if#1son\endcsname%
\global\csname #1sontrue\endcsname%
\expandafter\newif\csname ifno#1yet\endcsname%
\csname no#1yettrue\endcsname%
}
\newcommand{\n@woutputstream}[2]{%
\expandafter\newwrite\csname #1s\endcsname%
\immediate\expandafter\openout\csname #1s\endcsname=\expandafter\jobname .#2%
}
\newcommand{\n@wliteralwrite}[1]{%
\expandafter\newcommand\csname literal#1\endcsname[1]{%
\begingroup%
\def\next{##1}%
\newlinechar='40
\immediate\write\expandafter\csname #1s\endcsname{\expandafter\strip\meaning\next}%
\endgroup}
}
\newcommand{\n@wnoteheadingmaterial}[3]{%
\csname literal#1\endcsname{%
\par\clearpage%
{\pagestyle{empty}\cleardoublepage}%
\thispagestyle{empty}%
}
\immediate\write\csname #1s\endcsname{%
\string\notesheadername=\string{#2\string}%
\string\pagestyle\string{endnotesstyle\string}%
}
\immediate\write\csname #1s\endcsname{%
\string\mark\string{3\string}%
\string\backmattersink%
\string\begin\string{center\string}%
\string{\string\normalfont \string%
\backmatterheadingfont\ #3\string}\string\end\string{center\string}%
}
\immediate\write\csname #1s\endcsname{\string\label\string{#3\string}}%
\immediate\write\csname #1s\endcsname{\string\normalfont\string\backmattertextfont}%
\immediate\write\csname #1s\endcsname{\string\paramodefalse}%
}
\newcommand{\n@wentryfortoc}[2]{%
\immediate\write\csname #1s\endcsname{\string\ifnotesincontentson}%
\immediate\write\csname #1s\endcsname{\string\addcontentsline\string{toc\string}%
\string{chapter\string}\string{#2\string}}%
\immediate\write\csname #1s\endcsname{\string\fi}%
}
\newcommand{\n@wmargrefkind}[1]{%
\expandafter\newcommand\csname margref#1\endcsname[1]{%
\addtocounter{margrefnumber}{1}%
\immediate\write\csname #1s\endcsname{\makemargreflabel}%
\setmargref%
}
}
\newcommand{\n@wnotecounter}[1]{%
\expandafter\newcounter{enmr#1count}%
}
\newcommand{\n@wparaboolean}[1]{%
\expandafter\newif\csname if#1spara\endcsname}%
\newcommand{\n@wputmargref}[1]{%
\expandafter\csname margref#1\endcsname%
}
\newcommand{\n@wputnotenum}[1]{%
\expandafter\stepcounter{enmr#1count}%
\setcounter{enmrnotescratchcount}{\expandafter\value{enmr#1count}}%
\makeenmrendnotemarker%
\putenmrnotemarkerintext%
}
\newif\ifparamode \paramodefalse%
\newcommand{\n@wsetparamode}[1]{%
\expandafter\newcommand\csname #1sparamode\endcsname{%
\immediate\write\expandafter\csname #1s\endcsname{\string\paramodetrue}%
}
}
\newcommand{\enmrconditionalpar}{%
\ifparamode%
\relax%
\else%
\par%
\fi%
}
\newcommand{\n@wnotecommand}[2]{%
\expandafter\newcommand\csname #1\endcsname[1]{%
\margrefmarker={#2:}%
\ifn@temarkinmargin%
\n@wputmargref{#1}%
\fi%
\ifn@temarkintext%
\n@wputnotenum{#1}%
\fi%
\stepcounter{allendnotes}\label{notl\theallendnotes}%
\immediate\write\expandafter\csname #1s\endcsname{\checknoteheaders}%
\ifn@temarkinmargin%
\immediate\write\expandafter\csname #1s\endcsname{\string\enmrconditionalpar}%
\immediate\write\expandafter\csname #1s\endcsname{\string{\string\textbf\string{\the\singlepageabbrev\
\string\pageref\string{notl\theallendnotes\string}\string}\string}}%
\else%
\immediate\write\expandafter\csname #1s\endcsname{\string\enmrconditionalpar}%
\immediate\write\csname #1s\endcsname{%
\string\textsuperscript\string{\theenmrnotescratchcount\string}%
}%
\fi
\expandafter\csname literal#1\endcsname{~##1}%
}}
%%%%%%%%%%%%%%
\newcommand{\definenewnotetype}[6]{%
\m@kenewnoteif{#1}%
\n@woutputstream{#1}{#2}%
\n@wliteralwrite{#1}%
\n@wnoteheadingmaterial{#1}{#3}{#4}%
\n@wentryfortoc{#1}{#5}%
\n@wmargrefkind{#1}%
\n@wnotecounter{#1}
\n@wparaboolean{#1}
\n@wsetparamode{#1}
\n@wnotecommand{#1}{#6}
\expandafter\newcommand\csname reset#1s\endcsname[1]{%
\immediate\write\csname #1s\endcsname{\string\begingroup}%
\immediate\write\csname #1s\endcsname{\string\goodbreak}%
\immediate\write\csname #1s\endcsname{\string\Needspace\string{5\string\baselineskip\string}}%
\immediate\write\csname #1s\endcsname{\string\styleforchapternotebegin}%
\immediate\write\csname #1s\endcsname{\the\chapternoteslinename\string\ \thechapter\string~}%
\iftitleinnotes%
\immediate\write\csname #1s\endcsname{\string\titleref\string{chapter\thechapter\string}}%
\fi%
\immediate\write\csname #1s\endcsname{\string\styleforchapternoteend}%
\immediate\write\csname #1s\endcsname{\string\nopagebreak}%
\immediate\write\csname #1s\endcsname{\string\endgroup}%
}
\appendtomacro{\resetendnotes}{\expandafter\csname reset#1s\endcsname}%
\expandafter\newcommand\csname put#1s\endcsname{%
\immediate\expandafter\closeout\csname #1s\endcsname%
\expandafter\input \jobname.#2%
}%
}
\endinput
%%
%% End of file `edmargin.sty'.
