%%% Some article styles and page layout tweaks for the memoir class
%%% Choose these as article or pagestyles for your memoir document. 
%%% Kieran Healy


%%% --------------------------------------------------
%%% Some useful bits and pieces
%%% --------------------------------------------------
%% Blank footnote command.
% Use \symbolfootnote[0]{Footnote text} for a blank footnote. 
% Useful for an initial acknowledgment note.
\long\def\symbolfootnote[#1]#2{\begingroup%
\def\thefootnote{\fnsymbol{footnote}}\footnote[#1]{#2}\endgroup}

%% Redefine \and and \andnext to remove tabular environment.
%% Needed below for custom article-styles when multiple authors are present. 
\renewcommand{\and}{\, }
\renewcommand*{\andnext}{%
  \\\medskip }

%% Custom hanging indent for vita items
\def\mybibind{\hangindent=1 true cm\hangafter=1 \noindent}


%%% --------------------------------------------------
%%% Style: memo-comments
%%% For short notes.
%%% --------------------------------------------------

% Make the style for Chapters and sections
\makechapterstyle{memo-comments}{
  \renewcommand\thesection{\arabic{section}} 
  \setsecheadstyle{\Large\sffamily\bfseries} 
  \setsubsecheadstyle{\large\sffamily\itshape} 
  \setsubsubsecheadstyle{\normalsize\sffamily} 
  \renewcommand{\printchaptername}{} 
  \renewcommand{\chapternamenum}{}
  \renewcommand{\chaptitlefont}{\normalfont\Huge\fontseries{bx}\sffamily\color{pagesectioning}}
  \renewcommand{\chapnumfont}{\chaptitlefont} 
  \renewcommand{\printchapternum}{\chapnumfont \thechapter\space} 
  \renewcommand{\afterchapternum}{} 
  \renewcommand{\printchaptername}{\secheadstyle}
  \renewcommand{\cftchapterfont}{\normalfont} 
  \renewcommand{\cftchapterpagefont}{\normalfont\sffamily}
  \renewcommand{\cftsectionpagefont}{\normalfont\sffamily} 
  \renewcommand{\cftchapterpresnum}{\sffamily} 
  % \renewcommand{\cftchapterleader}{} 
  % \renewcommand{\cftchapterafterpnum}{\cftparfillskip}
  \captiontitlefont{\small}
  \settocdepth{chapter}
  \maxsecnumdepth{chapter} 
  \setsecnumdepth{chapter}

  % reduce skip after section heading
  \setaftersecskip{1.7ex}
  
  % Title 
  \pretitle{\begin{flushleft}\LARGE\sffamily\bfseries}
    \posttitle{\end{flushleft}\par\vskip 0.5em}
  \preauthor{\begin{flushleft}\Large\sffamily}
    \postauthor{\end{flushleft}}
  \predate{\begin{flushleft}\sffamily\footnotesize\vspace{0.9em}}
    \postdate{\end{flushleft}\par\vskip 2em}
}

%%% --------------------------------------------------
%%% Style: article-1 
%%% --------------------------------------------------
\makechapterstyle{article-1}{
  \setsecheadstyle{\Large\scshape} 
  \setsubsecheadstyle{\normalsize\itshape} 
  \renewcommand{\printchaptername}{} 
  \renewcommand{\chapternamenum}{} 
  \renewcommand{\chapnumfont}{\chaptitlefont} 
  \renewcommand{\printchapternum}{\chapnumfont \thechapter\space} 
  \renewcommand{\afterchapternum}{} 
  \renewcommand{\printchaptername}{\secheadstyle}
  \renewcommand{\cftchapterfont}{\normalfont} 
  \renewcommand{\cftchapterpagefont}{\normalfont\scshape} 
  \renewcommand{\cftchapterpresnum}{\scshape} 
  % \renewcommand{\cftchapterleader}{} 
  % \renewcommand{\cftchapterafterpnum}{\cftparfillskip}
  \captiontitlefont{\small}
  % \settocdepth{chapter}
  % \maxsecnumdepth{section} 
  % \setsecnumdepth{section}

  % reduce skip after section heading
  \setaftersecskip{1.7ex}
  
  % set name of bibliography to 'references'
  % \renewcommand{\bibname}{\mdseries\Large\scshape\MakeLowercase References}

  \pretitle{\newline\centering \LARGE\scshape \MakeLowercase }
  \posttitle{\par\vskip 1em}
  \predate{\footnotesize \centering}
  \postdate{\par\vskip 1em}
  
  % 'abstract' title, bigger skip from title
  \addto\captionsamerican{\renewcommand{\abstractname}{}}
  \abstractrunin
}
     
%%% --------------------------------------------------
%%% Style: article-2 
%%% --------------------------------------------------

% Make the style for Chapters and sections
\makechapterstyle{article-2}{
  \setsecheadstyle{\Large\sffamily} 
  \setsubsecheadstyle{\normalsize\sffamily\itshape} 
  \setaftersubsubsecskip{-1em}
  \setsubsubsecheadstyle{\small\bfseries}
  \renewcommand{\printchaptername}{} 
  \renewcommand{\chapternamenum}{} 
  \renewcommand{\chapnumfont}{\chaptitlefont} 
  \renewcommand{\printchapternum}{\chapnumfont \thechapter\space} 
  \renewcommand{\afterchapternum}{} 
  \renewcommand{\printchaptername}{\secheadstyle}
  \renewcommand{\cftchapterfont}{\normalfont} 
  \renewcommand{\cftchapterpagefont}{\normalfont\scshape} 
  \renewcommand{\cftchapterpresnum}{\scshape} 
  % \renewcommand{\cftchapterleader}{} 
  % \renewcommand{\cftchapterafterpnum}{\cftparfillskip}
  \captiontitlefont{\small}
  % \settocdepth{chapter}
  \maxsecnumdepth{chapter} 
  \setsecnumdepth{chapter}

  % reduce skip after section heading
  \setaftersecskip{1.7ex}
  
  % set name of bibliography to 'references'
  % \renewcommand{\bibname}{\mdseries\Large\scshape\MakeLowercase References}

  % Title flush left
  \pretitle{\begin{flushleft}\LARGE\sffamily}
    \posttitle{\end{flushleft}\par\vskip 0.5em}
  \preauthor{\begin{flushleft}\sffamily\itshape  \Large \vspace{0.5em}}
    \postauthor{\end{flushleft}}
  \predate{\begin{flushleft}\sffamily\footnotesize\vspace{0.9em}}
    \postdate{\end{flushleft}\par\vskip 2em}
  
  % 'abstract' title, bigger skip from title
  \addto\captionsamerican{\renewcommand{\abstractname}{Abstract:}}
  \renewcommand{\abstractnamefont}{\normalfont\scriptsize\itshape}
  \renewcommand{\abstracttextfont}{\normalfont\scriptsize}
  \abstractrunin

}

%%% --------------------------------------------------
%%% Style: article-3 
%%% --------------------------------------------------

% Make the style for Chapters and sections
\makechapterstyle{article-3}{
  \renewcommand\thesection{\arabic{section}} 
  \setsecheadstyle{\Large\sffamily} 
  \setsubsecheadstyle{\large\sffamily} 
  \setsubsubsecheadstyle{\normalsize\sffamily\itshape} 
  \renewcommand{\printchaptername}{} 
  \renewcommand{\chapternamenum}{} 
  \renewcommand{\chapnumfont}{\chaptitlefont} 
  \renewcommand{\printchapternum}{\chapnumfont \thechapter\space} 
  \renewcommand{\afterchapternum}{} 
  \renewcommand{\printchaptername}{\secheadstyle}
  \renewcommand{\cftchapterfont}{\normalfont} 
  \renewcommand{\cftchapterpagefont}{\normalfont\sffamily} 
  \renewcommand{\cftchapterpresnum}{\sffamily} 
  % \renewcommand{\cftchapterleader}{} 
  % \renewcommand{\cftchapterafterpnum}{\cftparfillskip}
  \captiontitlefont{\small}
  \settocdepth{chapter}
  \maxsecnumdepth{chapter} 
  \setsecnumdepth{chapter}

  % reduce skip after section heading
  \setaftersecskip{1.7ex}
  
  % set name of bibliography to 'references'
  % \renewcommand{\bibname}{\mdseries\Large\sffamily\MakeLowercase References}

  % Title 
  \pretitle{\par\vskip 3em 
    \begin{flushleft}\Huge\bfseries\sffamily}
    \posttitle{\end{flushleft}\par\vskip 0.5em}
  \preauthor{\begin{flushleft}\Large\bigskip}
    \postauthor{\end{flushleft}}
  \predate{\begin{flushleft}\normalsize}
    \postdate{\end{flushleft}}

  % \pretitle{\LARGE \sffamily}
  % \posttitle{\par\vskip 0.5em}
  % \preauthor{\large \sffamily \lineskip 1em}
  % \postauthor{\par\lineskip 1em}
  % \predate{\sffamily\footnotesize\vspace{0.65em}}
  % \postdate{\par\vskip 2em}

    % 'abstract' bigger skip from title
  \addto\captionsamerican{\renewcommand{\abstractname}{}}
  \renewcommand{\abstractname}{\normalfont\small\emph{Abstract:}}
  \renewcommand{\abstracttextfont}{\normalfont\small}
  \abstractrunin


}     

%%% --------------------------------------------------
%%% Style: article-4 (AJS) 
%%% --------------------------------------------------

%% Make the style for Chapters and sections
\makechapterstyle{article-4}{
  \setsecheadstyle{\Large\scshape\MakeLowercase} 
  \setsubsecheadstyle{\normalsize\itshape} 
  \setaftersubsubsecskip{-1em}
  \setsubsubsecheadstyle{\small\bfseries}
  \renewcommand{\printchaptername}{} 
  \renewcommand{\chapternamenum}{} 
  \renewcommand{\chapnumfont}{\chaptitlefont} 
  \renewcommand{\printchapternum}{\chapnumfont \thechapter\space} 
  \renewcommand{\afterchapternum}{} 
  \renewcommand{\printchaptername}{\secheadstyle}
  \renewcommand{\cftchapterfont}{\normalfont} 
  \renewcommand{\cftchapterpagefont}{\normalfont\scshape} 
  \renewcommand{\cftchapterpresnum}{\scshape} 
  % \renewcommand{\cftchapterleader}{} 
  % \renewcommand{\cftchapterafterpnum}{\cftparfillskip}
  %\renewcommand{\bibsection}{\section*{\bibname}\prebibhook}   % \settocdepth{chapter}
  \maxsecnumdepth{chapter} 
  \setsecnumdepth{chapter}

  % reduce skip after section heading
  \setaftersecskip{1.7ex}
  
  % set name of bibliography to 'references'
  % \renewcommand{\bibname}{\mdseries\Large\scshape\MakeLowercase References}

  % % Title flush left
  \pretitle{\par\vskip 3em 
    \begin{flushleft}\LARGE\bfseries}
    \posttitle{\end{flushleft}\par\vskip 0.5em}
  \preauthor{\begin{flushleft}\normalsize\bigskip}
    \postauthor{\end{flushleft}}
  \predate{\begin{flushleft}\normalsize}
    \postdate{\end{flushleft}}

  % 'abstract' bigger skip from title
  \addto\captionsamerican{\renewcommand{\abstractname}{}}
  \renewcommand{\abstractname}{\normalfont\small\emph{Abstract:}}
  \renewcommand{\abstracttextfont}{\normalfont\small}
  \abstractrunin


  % % 'abstract' bigger skip from title
  % \addto\captionsamerican{\renewcommand{\abstractname}{}}
  % \renewcommand{\abstractname}{}
  % \renewcommand{\abstracttextfont}{\normalfont\scriptsize}
  % \abstractrunin
}


%%% --------------------------------------------------
%%% article-4-sans (AJS, but sans-serif headings) 
%%% --------------------------------------------------

%% Make the style for Chapters and sections
\makechapterstyle{article-4-sans}{
  \setsecheadstyle{\sffamily\bfseries} 
  \setsubsecheadstyle{\normalsize\sffamily\itshape} 
  \setaftersubsubsecskip{-1em}
  \setsubsubsecheadstyle{\small}
  \renewcommand{\printchaptername}{} 
  \renewcommand{\chapternamenum}{} 
  \renewcommand{\chapnumfont}{\chaptitlefont} 
  \renewcommand{\printchapternum}{\chapnumfont \thechapter\space} 
  \renewcommand{\afterchapternum}{} 
  \renewcommand{\printchaptername}{\secheadstyle}
  \renewcommand{\cftchapterfont}{\normalfont} 
  \renewcommand{\cftchapterpagefont}{\normalfont\sffamily} 
  \renewcommand{\cftchapterpresnum}{\sffamily} 
  % \renewcommand{\cftchapterleader}{} 
  % \renewcommand{\cftchapterafterpnum}{\cftparfillskip}
  \captiontitlefont{\small}
  % \settocdepth{chapter}
  \maxsecnumdepth{chapter} 
  \setsecnumdepth{chapter}

  %% reduce skip after section heading
  \setaftersecskip{1.7ex}
  
  %% set name of bibliography to 'references'
  %% \renewcommand{\bibname}{\mdseries\Large\sffamily References}

  % % Title flush left
  \pretitle{\par\vskip 3em 
    \begin{flushleft}\LARGE\sffamily\bfseries}
    \posttitle{\end{flushleft}\par\vskip 0.5em}
  \preauthor{\begin{flushleft}\Large}
    \postauthor{\end{flushleft}}
  \predate{\begin{flushleft}\normalsize}
    \postdate{\end{flushleft}}
  
  %% 'abstract' bigger skip from title
  \addto\captionsamerican{\renewcommand*{\abstractname}{}}
  \renewcommand{\abstractnamefont}{\normalfont\scriptsize}
  \renewcommand{\abstracttextfont}{\normalfont\scriptsize}
  \abstractrunin

  
}


%%% --------------------------------------------------
%%% Style: article-5 (Bold main heads)
%%% Requires xelatex defs in .tex file
%%% --------------------------------------------------

%% Make the style for Chapters and sections
\makechapterstyle{article-5}{
  \setsecheadstyle{\Large\secfont} 
  \setsubsecheadstyle{\normalsize\itshape} 
  \setaftersubsubsecskip{-1em}
  \setsubsubsecheadstyle{\small\bfseries}
  \renewcommand{\printchaptername}{} 
  \renewcommand{\chapternamenum}{} 
  \renewcommand{\chapnumfont}{\chaptitlefont} 
  \renewcommand{\printchapternum}{\chapnumfont \thechapter\space} 
  \renewcommand{\afterchapternum}{} 
  \renewcommand{\printchaptername}{\secheadstyle}
  \renewcommand{\cftchapterfont}{\normalfont} 
  \renewcommand{\cftchapterpagefont}{\normalfont\textbf} 
  \renewcommand{\cftchapterpresnum}{\textbf} 
  % \renewcommand{\cftchapterleader}{} 
  % \renewcommand{\cftchapterafterpnum}{\cftparfillskip}
  \captiontitlefont{\small}
  % \settocdepth{chapter}
  \maxsecnumdepth{chapter} 
  \setsecnumdepth{chapter}

  % reduce skip after section heading
  \setaftersecskip{1.7ex}
  
  % set name of bibliography to 'references'
  % \renewcommand{\bibname}{\mdseries\Large\scshape\MakeLowercase References}

  % % Title flush left
  \pretitle{\par\vskip 3em 
    \begin{flushleft}\LARGE\bfseries}
    \posttitle{\end{flushleft}\par\vskip 0.5em}
  \preauthor{\begin{flushleft}\normalsize\bigskip}
    \postauthor{\end{flushleft}}
  \predate{\begin{flushleft}\normalsize}
    \postdate{\end{flushleft}}

  % 'abstract' bigger skip from title
  \addto\captionsamerican{\renewcommand{\abstractname}{}}
  \renewcommand{\abstractname}{}
  \renewcommand{\abstracttextfont}{\normalfont\scriptsize}
  \abstractrunin
}


%%% --------------------------------------------------
%%% Style: article-6 (bookdown) 
%%% --------------------------------------------------

%% For bookdown ``books'' that you want typeset as articles.
%% Make the style for Chapters and sections
\makechapterstyle{article-6}{
  \setsecheadstyle{\normalsize\itshape} 
  \setaftersubsubsecskip{-1em}
  \setsubsubsecheadstyle{\small\bfseries}
  \renewcommand{\printchaptername}{}
  \renewcommand{\printchaptertitle}[1]{%
    \raggedright\Large\scshape\MakeLowercase{##1}}
  \renewcommand{\chapternamenum}{}
  \renewcommand{\chapnumfont}{\chaptitlefont}
  \renewcommand{\chaptitlefont}{\normalfont} 
  \renewcommand{\printchapternum}{} 
  \renewcommand{\afterchapternum}{} 
  \renewcommand{\printchaptername}{\normalfont}
  \renewcommand{\cftchapterfont}{\normalfont} 
  \renewcommand{\cftchapterpagefont}{\normalfont\scshape} 
  \renewcommand{\cftchapterpresnum}{\scshape} 
  % \renewcommand{\cftchapterleader}{} 
  % \renewcommand{\cftchapterafterpnum}{\cftparfillskip}
  \captiontitlefont{\small}
  % \settocdepth{chapter}
  \maxsecnumdepth{chapter} 
  \setsecnumdepth{chapter}

  % reduce skip after chapter and section headings
  \renewcommand{\afterchapskip}{1.7ex}
  \renewcommand{\beforechapskip}{1.7ex}

  \setaftersecskip{1.7ex}
  
  % set name of bibliography to 'references'
  % \renewcommand{\bibname}{\mdseries\Large\scshape\MakeLowercase References}

  % % Title flush left
  \pretitle{\par\vskip 3em 
    \begin{flushleft}\LARGE\bfseries}
    \posttitle{\end{flushleft}\par\vskip 0.5em}
  \preauthor{\begin{flushleft}\normalsize\bigskip}
    \postauthor{\end{flushleft}}
  \predate{\begin{flushleft}\normalsize}
    \postdate{\end{flushleft}}

  % 'abstract' bigger skip from title
  \addto\captionsamerican{\renewcommand{\abstractname}{}}
  \renewcommand{\abstractname}{}
  \renewcommand{\abstracttextfont}{\normalfont\scriptsize}
  \abstractrunin
}


%%% --------------------------------------------------
%%% Style: minionbook ()
%%% --------------------------------------------------

%% Make the style for Chapters and sections
\makechapterstyle{minionbook}{
  % \phantomsection is needed because the case change
  % will break toc labels otherwise. See https://groups.google.com/g/comp.text.tex/c/74OTqXBN60A
  % and Memoir manual sec 9.2ff
  \setsecheadstyle{\phantomsection\Large\scshape\MakeTextLowercase}
  \setsubsecheadstyle{\normalsize\itshape}
  \setaftersubsubsecskip{-1em}
  \setsubsubsecheadstyle{\small\bfseries}
  \renewcommand{\printchaptername}{}
  \renewcommand{\chapternamenum}{}
  \renewcommand{\chaptitlefont}{\huge\bfseries}
  \renewcommand{\chapnumfont}{\chaptitlefont}
  \renewcommand{\printchapternum}{\chapnumfont \normalsize Chapter \thechapter\space \newline}
  \renewcommand{\afterchapternum}{}
%  \renewcommand{\printchaptername}{\secheadstyle}
  \renewcommand{\cftchapterfont}{\normalfont\bfseries}
  \renewcommand{\cftsectionfont}{\normalfont\itshape}
  \renewcommand{\cftchapterpagefont}{\normalfont\scshape}
  \renewcommand{\cftchapterpresnum}{\scshape}
  % \renewcommand{\cftchapterleader}{}
  % \renewcommand{\cftchapterafterpnum}{\cftparfillskip}
  \captiontitlefont{\small}
  %%% Let pandoc/ toc-depth override
  %%\settocdepth{chapter}
  %%\maxsecnumdepth{chapter}
  %%\setsecnumdepth{chapter}

  % reduce skip after section heading
  \setaftersecskip{1.7ex}

  % set name of bibliography to 'references'
  % \renewcommand{\bibname}{\mdseries\Large\scshape\MakeLowercase References}

  % % Title flush left
  \pretitle{\par\vskip 3em
    \begin{flushleft}\HUGE\bfseries}
    \posttitle{\end{flushleft}\par\vskip 0.5em}
  \preauthor{\begin{flushleft}\normalsize\bigskip}
    \postauthor{\end{flushleft}}
  \predate{\begin{flushleft}\normalsize}
    \postdate{\end{flushleft}}

  % 'abstract' bigger skip from title
  \addto\captionsamerican{\renewcommand{\abstractname}{}}
  \renewcommand{\abstractname}{}
  \renewcommand{\abstracttextfont}{\normalfont\scriptsize}
  \abstractrunin
}




%% Make the style for unnumbered introduction
\makechapterstyle{minionbookin}{
    % \phantomsection is needed because the case change
  % will break toc labels otherwise. See https://groups.google.com/g/comp.text.tex/c/74OTqXBN60A
  % and Memoir manual sec 9.2ff
  \setsecheadstyle{\phantomsection\Large\scshape\MakeTextLowercase}
  \setsubsecheadstyle{\normalsize\itshape}
  \setaftersubsubsecskip{-1em}
  \setsubsubsecheadstyle{\small\bfseries}
  \renewcommand{\printchaptername}{}
  \renewcommand{\chapternamenum}{}
  \renewcommand{\chaptitlefont}{\huge\bfseries}
  \renewcommand{\chapnumfont}{\chaptitlefont}

  \renewcommand\printchapternonum{\chapnumfont \normalsize Introduction \newline}
  \renewcommand{\afterchapternum}{}
%  \renewcommand{\printchaptername}{\secheadstyle}
  \renewcommand{\cftchapterfont}{\normalfont\bfseries}
  \renewcommand{\cftsectionfont}{\normalfont\itshape}
  \renewcommand{\cftchapterpagefont}{\normalfont\scshape}
  \renewcommand{\cftchapterpresnum}{\scshape}
  % \renewcommand{\cftchapterleader}{}
  % \renewcommand{\cftchapterafterpnum}{\cftparfillskip}
  \captiontitlefont{\small}
  %%% Let pandoc/ toc-depth override
  %%\settocdepth{chapter}
  %%\maxsecnumdepth{chapter}
  %%\setsecnumdepth{chapter}

  % reduce skip after section heading
  \setaftersecskip{1.7ex}

  % set name of bibliography to 'references'
  % \renewcommand{\bibname}{\mdseries\Large\scshape\MakeLowercase References}

  % % Title flush left
  \pretitle{\par\vskip 3em
    \begin{flushleft}\HUGE\bfseries}
    \posttitle{\end{flushleft}\par\vskip 0.5em}
  \preauthor{\begin{flushleft}\normalsize\bigskip}
    \postauthor{\end{flushleft}}
  \predate{\begin{flushleft}\normalsize}
    \postdate{\end{flushleft}}

  % 'abstract' bigger skip from title
  \addto\captionsamerican{\renewcommand{\abstractname}{}}
  \renewcommand{\abstractname}{}
  \renewcommand{\abstracttextfont}{\normalfont\scriptsize}
  \abstractrunin
}


%% Make the style for unnumbered conclusion
\makechapterstyle{minionbookout}{
    % \phantomsection is needed because the case change
  % will break toc labels otherwise. See https://groups.google.com/g/comp.text.tex/c/74OTqXBN60A
  % and Memoir manual sec 9.2ff
  \setsecheadstyle{\phantomsection\Large\scshape\MakeTextLowercase}
  \setsubsecheadstyle{\normalsize\itshape}
  \setaftersubsubsecskip{-1em}
  \setsubsubsecheadstyle{\small\bfseries}
  \renewcommand{\printchaptername}{}
  \renewcommand{\chapternamenum}{}
  \renewcommand{\chaptitlefont}{\huge\bfseries}
  \renewcommand{\chapnumfont}{\chaptitlefont}
  \renewcommand\printchapternonum{\chapnumfont \normalsize Conclusion \newline}
  \renewcommand{\printchapternum}{\chapnumfont \normalsize Chapter \thechapter\space \newline}
  \renewcommand{\afterchapternum}{}
%  \renewcommand{\printchaptername}{\secheadstyle}
  \renewcommand{\cftchapterfont}{\normalfont\bfseries}
  \renewcommand{\cftsectionfont}{\normalfont\itshape}
  \renewcommand{\cftchapterpagefont}{\normalfont\scshape}
  \renewcommand{\cftchapterpresnum}{\scshape}
  % \renewcommand{\cftchapterleader}{}
  % \renewcommand{\cftchapterafterpnum}{\cftparfillskip}
  \captiontitlefont{\small}
  %%% Let pandoc/ toc-depth override
  %%\settocdepth{chapter}
  %%\maxsecnumdepth{chapter}
  %%\setsecnumdepth{chapter}

  % reduce skip after section heading
  \setaftersecskip{1.7ex}

  % set name of bibliography to 'references'
  % \renewcommand{\bibname}{\mdseries\Large\scshape\MakeLowercase References}

  % % Title flush left
  \pretitle{\par\vskip 3em
    \begin{flushleft}\HUGE\bfseries}
    \posttitle{\end{flushleft}\par\vskip 0.5em}
  \preauthor{\begin{flushleft}\normalsize\bigskip}
    \postauthor{\end{flushleft}}
  \predate{\begin{flushleft}\normalsize}
    \postdate{\end{flushleft}}

  % 'abstract' bigger skip from title
  \addto\captionsamerican{\renewcommand{\abstractname}{}}
  \renewcommand{\abstractname}{}
  \renewcommand{\abstracttextfont}{\normalfont\scriptsize}
  \abstractrunin
}


%% Make the style for unnumbered acknowledgments after conclusion
\makechapterstyle{minionbookacknow}{
    % \phantomsection is needed because the case change
  % will break toc labels otherwise. See https://groups.google.com/g/comp.text.tex/c/74OTqXBN60A
  % and Memoir manual sec 9.2ff
  \setsecheadstyle{\phantomsection\Large\scshape\MakeTextLowercase}
  \setsubsecheadstyle{\normalsize\itshape}
  \setaftersubsubsecskip{-1em}
  \setsubsubsecheadstyle{\small\bfseries}
  \renewcommand{\printchaptername}{}
  \renewcommand{\chapternamenum}{}
  \renewcommand{\chaptitlefont}{\huge\bfseries}
  \renewcommand{\chapnumfont}{\chaptitlefont}
  \renewcommand\printchapternonum{\chapnumfont \normalsize Acknowledgements \newline}
  \renewcommand{\printchapternum}{\chapnumfont \normalsize Chapter \thechapter\space \newline}
  \renewcommand{\afterchapternum}{}
%  \renewcommand{\printchaptername}{\secheadstyle}
  \renewcommand{\cftchapterfont}{\normalfont\bfseries}
  \renewcommand{\cftsectionfont}{\normalfont\itshape}
  \renewcommand{\cftchapterpagefont}{\normalfont\scshape}
  \renewcommand{\cftchapterpresnum}{\scshape}
  % \renewcommand{\cftchapterleader}{}
  % \renewcommand{\cftchapterafterpnum}{\cftparfillskip}
  \captiontitlefont{\small}
  %%% Let pandoc/ toc-depth override
  %%\settocdepth{chapter}
  %%\maxsecnumdepth{chapter}
  %%\setsecnumdepth{chapter}

  % reduce skip after section heading
  \setaftersecskip{1.7ex}

  % set name of bibliography to 'references'
  % \renewcommand{\bibname}{\mdseries\Large\scshape\MakeLowercase References}

  % % Title flush left
  \pretitle{\par\vskip 3em
    \begin{flushleft}\HUGE\bfseries}
    \posttitle{\end{flushleft}\par\vskip 0.5em}
  \preauthor{\begin{flushleft}\normalsize\bigskip}
    \postauthor{\end{flushleft}}
  \predate{\begin{flushleft}\normalsize}
    \postdate{\end{flushleft}}

  % 'abstract' bigger skip from title
  \addto\captionsamerican{\renewcommand{\abstractname}{}}
  \renewcommand{\abstractname}{}
  \renewcommand{\abstracttextfont}{\normalfont\scriptsize}
  \abstractrunin
}




%%% --------------------------------------------------
%%% Style: microdoc
%%% --------------------------------------------------

%% Definitions
\RequirePackage{color}
 \definecolor{pagered}    {rgb} {0.65,0.04,0.07}
 \definecolor{pagegreen}  {rgb} {0.06,0.44,0.08}
 \definecolor{pageblue}   {rgb} {0.02,0.04,0.48}
 \definecolor{pagesectioning}{gray}{0.44}
 \definecolor{pagethegrey}   {gray}{0.5}
 \definecolor{pageframe}  {gray}{0.75}
 \definecolor{pageshade}  {gray}{0.94}


%% Make the style for Chapters and sections
\makechapterstyle{microdoc}{
  \setsecheadstyle{\Large\fontseries{bx}\sffamily\color{pagesectioning}} 
  \setsubsecheadstyle{\normalsize\fontseries{bx}\sffamily\color{pagesectioning}} 
  \setaftersubsubsecskip{-1em}
  \setsubsubsecheadstyle{\small\sffamily\color{pagesectioning}}
  \renewcommand{\printchaptername}{} 
  \renewcommand{\chapternamenum}{} 
  \renewcommand{\chapnumfont}{\chaptitlefont} 
  \renewcommand{\printchapternum}{\chapnumfont \thechapter\space} 
  \renewcommand{\afterchapternum}{} 
  \renewcommand{\printchaptername}{\secheadstyle}
  \renewcommand{\chapnumfont}{\normalfont\HUGE\fontseries{bx}\sffamily\color{pagesectioning}}
  \renewcommand{\chaptitlefont}{\normalfont\huge\fontseries{bx}\sffamily\color{pagesectioning}}
  \renewcommand{\cftchapterfont}{\normalfont\fontseries{bx}\sffamily\color{pagesectioning}} 
  \renewcommand{\cftchapterpagefont}{\normalfont\sffamily}
  \renewcommand{\cftsectionpagefont}{\normalfont\sffamily}
  \renewcommand{\cftsubsectionpagefont}{\normalfont\sffamily} 
  \renewcommand{\cftchapterpresnum}{\scshape} 
  % \renewcommand{\cftchapterleader}{} 
  % \renewcommand{\cftchapterafterpnum}{\cftparfillskip}
  \captiontitlefont{\small}
  % \settocdepth{chapter}
  \maxsecnumdepth{chapter} 
  \setsecnumdepth{chapter}

  % reduce skip after section heading
  \setaftersecskip{1.7ex}
  
  % set name of bibliography to 'references'
  % \renewcommand{\bibname}{\mdseries\Large\scshape\MakeLowercase References}

  % % Title flush left
  \pretitle{\par\vskip 3em 
    \begin{flushleft}\LARGE\fontseries{bx}\sffamily\color{pagesectioning}}
    \posttitle{\end{flushleft}\par\vskip 0.5em}
  \preauthor{\begin{flushleft}\normalsize\fontseries{bx}\sffamily\color{pagesectioning}\bigskip}
    \postauthor{\end{flushleft}}
  \predate{\begin{flushleft}\normalsize\sffamily\color{pagesectioning}}
    \postdate{\end{flushleft}}

  % 'abstract' bigger skip from title
  \addto\captionsamerican{\renewcommand{\abstractname}{}}
  \renewcommand{\abstractname}{}
  \renewcommand{\abstracttextfont}{\normalfont\scriptsize}
  \abstractrunin
}


%%% --------------------------------------------------
%%% Style: severance
%%% --------------------------------------------------
%% Definitions
\RequirePackage{color}
 \definecolor{pagered}    {rgb} {0.65,0.04,0.07}
 \definecolor{pagegreen}  {rgb} {0.06,0.44,0.08}
 \definecolor{pageblue}   {rgb} {0.02,0.04,0.48}
 \definecolor{pagesectioning}{gray}{0.6}
 \definecolor{pagethegrey}   {gray}{0.5}
 \definecolor{pageframe}  {gray}{0.75}
 \definecolor{pageshade}  {gray}{0.94}

% Make the style for Chapters and sections
\makechapterstyle{severance}{
  \renewcommand\thesection{\arabic{section}}
  \setsecheadstyle{\Large\sffamily\bfseries\color{pageblue}}
  \setsubsecheadstyle{\large\sffamily\fontseries{b}\color{pageblue}}
  \setsubsubsecheadstyle{\normalsize\bfseries\color{pagered}}
  \renewcommand{\printchaptername}{}
  \renewcommand{\chapternamenum}{}
  \renewcommand{\chapnumfont}{\chaptitlefont}
  \renewcommand{\printchapternum}{\chapnumfont \thechapter\space}
  \renewcommand{\afterchapternum}{}
  \renewcommand{\printchaptername}{\secheadstyle}
  \renewcommand{\cftchapterfont}{\normalfont}
  \renewcommand{\cftchapterpagefont}{\normalfont\sffamily}
  \renewcommand{\cftchapterpresnum}{\sffamily}
  % \renewcommand{\cftchapterleader}{}
  % \renewcommand{\cftchapterafterpnum}{\cftparfillskip}
  \captiontitlefont{\small}
  \settocdepth{chapter}
  \maxsecnumdepth{chapter}
  \setsecnumdepth{chapter}

  % reduce skip after section heading
  \setaftersecskip{1.7ex}

  % set name of bibliography to 'references'
  % \renewcommand{\bibname}{\mdseries\Large\sffamily\MakeLowercase References}

  % Title
  \pretitle{\par\vskip 3em
    \begin{flushleft}\Huge\bfseries\sffamily\color{pageblue}}
    \posttitle{\end{flushleft}\par\vskip 0.5em}
  \preauthor{\begin{flushleft}\Large\color{pageblue}\bigskip}
    \postauthor{\end{flushleft}}
  \predate{\begin{flushleft}\normalsize\color{pageblue}}
    \postdate{\end{flushleft}}

  % \pretitle{\LARGE \sffamily}
  % \posttitle{\par\vskip 0.5em}
  % \preauthor{\large \sffamily \lineskip 1em}
  % \postauthor{\par\lineskip 1em}
  % \predate{\sffamily\footnotesize\vspace{0.65em}}
  % \postdate{\par\vskip 2em}

  % 'abstract' title, bigger skip from title
  \addto\captionsamerican{\renewcommand{\abstractname}{Abstract:}}
  \renewcommand{\abstractnamefont}{\normalfont\scriptsize}
  \renewcommand{\abstracttextfont}{\normalfont\scriptsize}
  \abstractrunin

}



%%% --------------------------------------------------
%%% Style: membook
%%% A book style
%%% --------------------------------------------------

%% Make the style for Chapters and sections
   % \makechapterstyle{membook}{
   %  \setsecheadstyle{\Large\sffamily\bfseries} 
   %  \setsubsecheadstyle{\normalsize\sffamily\itshape} 
   %      \setaftersubsubsecskip{-1em}
   %  \setsubsubsecheadstyle{\small\sffamily\bfseries}
   %  \renewcommand{\printchaptername}{\sffamily} 
   %  \renewcommand{\chapternamenum}{\sffamily} 
   %  \renewcommand{\chapnumfont}{\chaptitlefont\sffamily} 
   %  \renewcommand{\printchapternum}{\chapnumfont \thechapter\space} 
   %  \renewcommand{\afterchapternum}{} 
   %  \renewcommand{\printchaptername}{\secheadstyle}
   %  \renewcommand{\cftchapterfont}{\normalfont} 
   %  \renewcommand{\cftchapterpagefont}{\normalfont\sffamily} 
   %  \renewcommand{\cftchapterpresnum}{\sffamily} 
   %  \renewcommand{\cftchapterleader}{\sffamily} 
   %  \renewcommand{\cftchapterafterpnum}{\cftparfillskip}
   %  \captiontitlefont{\small}
   %  %\settocdepth{chapter}
   %  \maxsecnumdepth{chapter} 
   %  \setsecnumdepth{chapter}

   %  % reduce skip after section heading
   %  \setaftersecskip{1.7ex}
    
   %  % set name of bibliography to 'references'
   %  %\renewcommand{\bibname}{\mdseries\Large\scshape\MakeLowercase References}

   %  % % Title flush left
   %  \pretitle{\par\vskip 3em 
   %      \begin{flushleft}\LARGE\sffamily\bfseries}
   %  \posttitle{\end{flushleft}\par\vskip 0.5em}
   %  \preauthor{\begin{flushleft}\normalsize\sffamily\bigskip}
   %  \postauthor{\end{flushleft}}
   %  \predate{\begin{flushleft}\normalsize\sffamily}
   %  \postdate{\end{flushleft}}

   %  % 'abstract' bigger skip from title
   %  \addto\captionsamerican{\renewcommand{\abstractname}{}}
   %  \renewcommand{\abstractname}{}
   %  \renewcommand{\abstracttextfont}{\normalfont\scriptsize}
   %  \abstractrunin
   % }


%\RequirePackage[usenames,dvipsnames]{color}
%\RequirePackage{calc}
%\RequirePackage{color,calc}
%\newsavebox{\ChpNumBox}
%\definecolor{ChapBlue}{rgb}{0.00,0.65,0.65}
%\makeatletter
% \newcommand*{\thickhrulefill}{%
%   \leavevmode\leaders\hrule height 1\p@ \hfill \kern \z@}
% \newcommand*\BuildChpNum[2]{%
%   \begin{tabular}[t]{@{}c@{}}
%     \makebox[0pt][c]{#1\strut}  \\[.5ex]
%     \colorbox{BrickRed}{%
%       \rule[-10em]{0pt}{0pt}%
%       \rule{1ex}{0pt}\color{black}#2\strut
%       \rule{1ex}{0pt}}%
%   \end{tabular}}
% \makechapterstyle{BlueBox}{%
%   \renewcommand{\chapnamefont}{\large\sffamily}
%   \renewcommand{\chapnumfont}{\Huge\sffamily}
%   \renewcommand{\chaptitlefont}{\raggedright\Huge\sffamily}
%   \setlength{\beforechapskip}{20pt}
%   \setlength{\midchapskip}{26pt}
%   \setlength{\afterchapskip}{40pt}
%   \renewcommand{\printchaptername}{\sffamily}
%   \renewcommand{\chapternamenum}{\sffamily}
%   \renewcommand{\printchapternum}{%
%     \sbox{\ChpNumBox}{%
%       \BuildChpNum{\chapnamefont\@chapapp}%
%       {\chapnumfont\thechapter}}}
%   \renewcommand{\printchapternonum}{%
%     \sbox{\ChpNumBox}{%
%       \BuildChpNum{\chapnamefont\vphantom{\@chapapp}}%
%       {\chapnumfont\hphantom{\thechapter}}}}
% \renewcommand{\afterchapternum}{}
% \renewcommand{\printchaptertitle}[1]{%
%   \usebox{\ChpNumBox}\hfill
%   \parbox[t]{\hsize-\wd\ChpNumBox-1em}{%
%     \vspace{\midchapskip}%
%     \thickhrulefill\par
%     \chaptitlefont ##1\par}}%
%     \pretitle{\par\vskip 3em 
%         \begin{flushleft}\LARGE\sffamily\bfseries}
%     \posttitle{\end{flushleft}\par\vskip 0.5em}
%     \preauthor{\begin{flushleft}\normalsize\sffamily\bigskip}
%     \postauthor{\end{flushleft}}
%     \predate{\begin{flushleft}\normalsize}
%     \postdate{\end{flushleft}}

% }





%%% -------------------------------------------------- 
%%% Custom styles for headers and footers The chapterstyles above
%%% style sections/subsections and titles, etc. These pagestyles
%%% control the running headers and footers. So far there's just one.
%%% --------------------------------------------------
   
%%%
%%% Basic 
%%%
\makepagestyle{kjh}
%\makeevenfoot{kjh}{\thepage}{}{}
%\makeoddfoot{kjh}{}{}{\thepage}
%\makeheadrule{kjh}{\textwidth}{\normalrulethickness}
\newcommand{\@kjhmarks}{%
  \let\@mkboth\markboth
  \def\chaptermark##1{%
    \markboth{%
      \ifnum \c@secnumdepth >\m@ne
        \if@mainmatter
          \thechapter. \ %
        \fi
      \fi
      ##1}{}}
  \def\sectionmark##1{%
    \markright{##1}}
}
\makepsmarks{kjh}{\@kjhmarks}
\makepsmarks{kjh}{}
\makeevenhead{kjh}{}{}{\scshape\thepage}
\makeoddhead{kjh}{}{}{\scshape\thepage}


%%%
%%% Basic + running head
%%%
\makepagestyle{kjhbook}
%\makeevenfoot{kjhbook}{\thepage}{}{}
%\makeoddfoot{kjhbook}{}{}{\thepage}
%\makeheadrule{kjhbook}{\textwidth}{\normalrulethickness}
\newcommand{\@kjhbookmarks}{%
  \let\@mkboth\markboth
  \def\chaptermark##1{%
    \markboth{%
      \ifnum \c@secnumdepth >\m@ne
        \if@mainmatter
          \thechapter. \ %
        \fi
      \fi
      ##1}{}}
  \def\sectionmark##1{%
    \markright{##1}}
}
\makepsmarks{kjhbook}{\@kjhbookmarks}
\makeevenhead{kjhbook}{\scshape\thepage \  \footnotesize\scshape chapter \thechapter \ }{}{}
\makeoddhead{kjhbook}{}{}{\footnotesize\itshape\rightmark\normalsize\ \ \scshape\thepage}

\makepagestyle{kjhbookin}
\newcommand{\@kjhbookmarksin}{%
  \let\@mkboth\markboth
  \def\chaptermark##1{%
    \markboth{%
      \ifnum \c@secnumdepth >\m@ne
        \if@mainmatter
          \thechapter. \ %
        \fi
      \fi
      ##1}{}}
  \def\sectionmark##1{%
    \markright{##1}}
}
\makepsmarks{kjhbookin}{\@kjhbookmarksin}
\makeevenhead{kjhbookin}{\scshape\thepage \  \footnotesize\scshape introduction}{}{}
\makeoddhead{kjhbookin}{}{}{\footnotesize\itshape\rightmark\normalsize\ \ \scshape\thepage}

\makepagestyle{kjhbookout}
\newcommand{\@kjhbookmarksout}{%
  \let\@mkboth\markboth
  \def\chaptermark##1{%
    \markboth{%
      \ifnum \c@secnumdepth >\m@ne
        \if@mainmatter
          \thechapter. \ %
        \fi
      \fi
      ##1}{}}
  \def\sectionmark##1{%
    \markright{##1}}
}
\makepsmarks{kjhbookout}{\@kjhbookmarksout}
\makeevenhead{kjhbookout}{\scshape\thepage \ \footnotesize\scshape conclusion}{}{}
\makeoddhead{kjhbookout}{}{}{\footnotesize\itshape\rightmark\normalsize\ \ \scshape\thepage}



\makepagestyle{kjhbookack}
\newcommand{\@kjhbookackmarksout}{%
  \let\@mkboth\markboth
  \def\chaptermark##1{%
    \markboth{%
      \ifnum \c@secnumdepth >\m@ne
        \if@mainmatter
          \thechapter. \ %
        \fi
      \fi
      ##1}{}}
  \def\sectionmark##1{%
    \markright{##1}}
}
\makepsmarks{kjhbookack}{\@kjhbookackmarksout}
\makeevenhead{kjhbookack}{\scshape\thepage \ \footnotesize\scshape acknowledgments}{}{}
\makeoddhead{kjhbookack}{}{}{\footnotesize\itshape Acknowledgments\normalsize\ \ \scshape\thepage}


\makepagestyle{kjhbookbib}
\newcommand{\@kjhbookmarksbib}{%
  \let\@mkboth\markboth
  \def\chaptermark##1{%
    \markboth{%
      \ifnum \c@secnumdepth >\m@ne
        \if@mainmatter
          \thechapter. \ %
        \fi
      \fi
      ##1}{}}
  \def\sectionmark##1{%
    \markright{##1}}
}
\makepsmarks{kjhbookbib}{\@kjhbookmarksbib}
\makeevenhead{kjhbookbib}{\scshape\thepage \ \footnotesize references}{}{}
\makeoddhead{kjhbookbib}{}{}{\footnotesize\itshape References \normalsize\ \ \scshape\thepage}


%%%
%%% RCS in footer 
%%%

% Make the style for RCS revision control headers and footers
\makepagestyle{kjhrcs}
% \makeheadrule{kjhrcs}{\textwidth}{\normalrulethickness}
\newcommand{\@kjhrcsmarks}{%
  \let\@mkboth\markboth
  \def\chaptermark##1{%
    \markboth{%
      \ifnum \c@secnumdepth >\m@ne
        \if@mainmatter
          \thechapter. \ %
        \fi
      \fi
      ##1}{}}
  \def\sectionmark##1{%
    \markright{##1}}
}
\makepsmarks{kjhrcs}{\@kjhrcsmarks}
%\makeevenhead{kjhrcs}{\footnotesize\scshape\leftmark}{}{\scshape\thepage}
%\makeoddhead{kjhrcs}{}{}{\footnotesize\rightmark\normalsize\ \ \scshape\thepage}
\makeevenfoot{kjhrcs}{\texttt{\footnotesize\rcsInfoFile}}{\scshape\thepage}{\footnotesize \emph{Rev} \texttt{\rcsInfoRevision \  \rcsInfoDate}}
\makeoddfoot{kjhrcs}{\texttt{\footnotesize\rcsInfoFile}}{\scshape\thepage}{\footnotesize \emph{Rev} \texttt{\rcsInfoRevision \ \rcsInfoDate}}



%%%
%%% Mercurial rev info in footers 
%%%

% Make the style for hg revision control headers and footers
\makepagestyle{kjhhg}
% \makeheadrule{kjhhg}{\textwidth}{\normalrulethickness}
\newcommand{\@kjhhgmarks}{%
  \let\@mkboth\markboth
  \def\chaptermark##1{%
    \markboth{%
      \ifnum \c@secnumdepth >\m@ne
        \if@mainmatter
          \thechapter. \ %
        \fi
      \fi
      ##1}{}}
  \def\sectionmark##1{%
    \markright{##1}}
}
\makepsmarks{kjhhg}{\@kjhhgmarks}
%\makeevenhead{kjhhg}{\footnotesize\scshape\leftmark}{}{\scshape\thepage}
%\makeoddhead{kjhhg}{}{}{\footnotesize\rightmark\normalsize\ \ \scshape\thepage}
\makeevenfoot{kjhhg}{\texttt{\footnotesize \hgkw{Filename}}}{\scshape\thepage}{\texttt{\footnotesize Rev \hgkw{LastChangedRevision} on \hgfilemonth\ \hgfileday, \hgfileyear}}
\makeoddfoot{kjhhg}{\texttt{\footnotesize \hgkw{Filename}}}{\scshape\thepage}{\texttt{\footnotesize Rev \hgkw{LastChangedRevision} on \hgfilemonth\ \hgfileday, \hgfileyear}}



%%%
%%% Git info in footers; requires vc package 
%%%

% Make the style for vc-git revision control headers and footers
\makepagestyle{kjhgit}
% \makeheadrule{kjhgit}{\textwidth}{\normalrulethickness}
\newcommand{\@kjhgitmarks}{%
  \let\@mkboth\markboth
  \def\chaptermark##1{%
    \markboth{%
      \ifnum \c@secnumdepth >\m@ne
        \if@mainmatter
          \thechapter. \ %
        \fi
      \fi
      ##1}{}}
  \def\sectionmark##1{%
    \markright{##1}}
}
\makepsmarks{kjhgit}{\@kjhgitmarks}
%\makeevenhead{kjhgit}{\footnotesize\scshape\leftmark}{}{\scshape\thepage}
%\makeoddhead{kjhgit}{}{}{\footnotesize\rightmark\normalsize\ \ \scshape\thepage}
\makeevenfoot{kjhgit}{}{\scshape\thepage}{\texttt{\footnotesize \VCRevision\ on \VCDateTEX}}
\makeoddfoot{kjhgit}{}{\scshape\thepage}{\texttt{\footnotesize \VCRevision\ on \VCDateTEX}}            

%%% 
%%% Custom appendix 
%%%

% % Make the style for headers and footers in the Appendix
% \makepagestyle{kjhappendix}
% %\makeevenfoot{kjh}{\thepage}{}{}
% %\makeoddfoot{kjh}{}{}{\thepage}
% \makeheadrule{kjhapp}{\textwidth}{\normalrulethickness}
% \newcommand{\@kjhappmarks}{%
%   \let\@mkboth\markboth
%   \def\chaptermark##1{%
%     \markboth{%
%       \ifnum \c@secnumdepth >\m@ne
%         \if@mainmatter
%           \thechapter. \ %
%         \fi
%       \fi
%       ##1}{}}
%   \def\sectionmark##1{%
%     \markright{##1}}
% }
% \makepsmarks{kjhappendix}{\@kjhappmarks}
% \makeevenhead{kjhappendix}{\footnotesize\scshape Appendix}{}{\scshape\thepage}
% \makeoddhead{kjhappendix}{}{}{\footnotesize Data and Methods for \rightmark\normalsize\ \ \scshape\thepage}

%% Create a command to make a note at the top of the first page describing the
%% publication status of the paper. 
\newcommand{\published}[1]{% 
   \gdef\puB{#1}} 
   \newcommand{\puB}{} 
   \renewcommand{\maketitlehooka}{% 
       \par\noindent\footnotesize \puB} 

\endinput