% a class for formatting articles for submission to York Papers in
% Linguistics Series 2 (YPL2)
% Gareth Walker, 2005, 2006
% Justin Lo, 2018

% updates:
% 23/01/06 - fixed typo which broke endnotes.
% 06/10/18 - fixed typo which affected reference formatting

\ProvidesClass{ypl2}

\usepackage{graphicx}

% page layout
\LoadClass[a4paper,12pt]{article}
\RequirePackage[margin=2.5cm]{geometry}
\pagestyle{empty}
\sloppy

%2009 adds:
\setlength{\parskip}{6pt}
\parindent=0pt

% fonts
\RequirePackage{times}


% document title
\def\maketitle{%
  \noindent
  \begin{minipage}[h]{\textwidth}
    \flushright\textbf{\scshape\@title}
    \flushright{\scshape\@author}
  \end{minipage}
}
\date{}


% titles
\RequirePackage{titlesec}
  \titleformat{\section}{\normalsize\itshape}%
      {\thesection. }{0pt}{}
  \titleformat{\subsection}{\normalsize\itshape}%
      {\thesubsection. }{0pt}{}
  \titleformat{\subsubsection}{\normalsize\itshape}%
      {\thesubsubsection. }{0pt}{}
  \titlespacing*{\section}{0pt}{2em}{1em}
  \titlespacing*{\subsection}{0pt}{2em}{1em}
  \titlespacing*{\subsubsection}{0pt}{2em}{1em}

% so quotes are indented on the right but not on the left
%\renewenvironment{quote}
%               {\list{}{\rightmargin 0em\leftmargin \parindent}%
%                \item\relax}
%               {\endlist}

% compact lists
\newenvironment{description*}%
  {\begin{description}%
  \setlength{\itemsep}{0pt}%
  \setlength{\parskip}{0pt}}%
  {\end{description}}
\newenvironment{list*}%
  {\begin{list}%
  \setlength{\itemsep}{0pt}%
  \setlength{\parskip}{0pt}}%
  {\end{list}}
\newenvironment{itemize*}%
  {\begin{itemize}%
  \setlength{\itemsep}{0pt}%
  \setlength{\parskip}{0pt}%
  \setlength{\leftmargin}{6cm}}%
  {\end{itemize}}
\newenvironment{enumerate*}%
  {\begin{enumerate}%
  \setlength{\itemsep}{0pt}%
  \setlength{\parskip}{0pt}}%
  {\end{enumerate}}



\newenvironment{YPLAbstract}%
{\section*{Abstract}\begin{quote}\small}
{\normalsize\end{quote}}%

\newenvironment{YPLAcknowledgements}%
{\section*{Acknowledgements}\small}
{\normalsize}%

\newenvironment{YPLAuthorContactDetails}
{\vfill\flushright}
{\\}

\newenvironment{YPLReferences}%
{\section*{References}\setlength{\parskip}{0pt}}
{}

%\setlength{\parskip}{0pt}
%\setlength{\parindent}{0pt}
%}
%{}%

% Repurpose the equation counter for examples
\newcommand{\YPLExampleNo}{\refstepcounter{equation}\theequation}

\newcommand{\YPLExample}[1]{\begin{YPLExampleList}\item #1\end{YPLExampleList}}

% Adapted from covington.sty
\newcounter{equationsave}          % used in trick with equation number

\newenvironment{YPLExampleList}%
{%
\begin{list}{(\theequation)}%
{%
\setcounter{equationsave}{\arabic{equation}}%
\usecounter{equation}%                          % sets it to zero, unwantedly
\setcounter{equation}{\arabic{equationsave}}%   % restores previous value
\setlength{\listparindent}{0pt}%
\def\makelabel##1{##1\hfil}%       % put labels flushleft in space available
}%
\raggedright}%                     % text is flushleft, not justified
{\end{list}}


\newcommand{\YPLEmphasis}[1]{\textit{#1}}
\newcommand{\YPLEmphasisAuthorOrEditor}[1]{\textsc{#1}}
\newcommand{\YPLFigure}[3]{\begin{figure}[h!]\centering\caption{#2}\label{#3}\includegraphics{#1}\end{figure}}
\newcommand{\YPLQuotation}[2]{\begin{quote}#1\par\flushright \small(#2)\normalsize\end{quote}}



\newcommand{\YPLReference}[1]{\hangindent=0.5in #1\par}
\newcommand{\YPLURL}[1]{\small{\texttt{#1}}}


% Used for the reference doc itself
\newcommand{\YPLCommand}[1]{\small\texttt{\textbackslash#1}\normalsize}
\newcommand{\YPLEnvironment}[1]{\small\texttt{#1}\normalsize}
\newcommand{\YPLNewline}[0]{\small\texttt{\textbackslash\textbackslash}\normalsize}



\def\setelem#1{\expandafter\def\csname myarray(#1)\endcsname}
\def\dispsymbol#1{\csname myarray(#1)\endcsname}


% footnotes/endnotes
\RequirePackage{endnotes}
\let\footnote=\endnote
\newcommand{\YPLGenerateNotes}{%
  \begingroup
  \theendnotes
  \endgroup}
\renewcommand\enoteformat{\normalsize\noindent \@theenmark. }


% bibliography
%\RequirePackage[sort,longnamesfirst]{natbib}
%  \bibpunct[:\,]{(}{)}{;}{a}{}{,}
%\bibliographystyle{ypl2}
