% \iffalse
%<*gobble>
% $Id: afparticle.dtx,v 1.14 2014-12-23 17:13:00 boris Exp $
%
% Copyright 2014, Boris Veytsman <boris@varphi.com>
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3 of this license or (at your option) any 
% later version.
% The latest version of the 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.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Boris Veytsman
%
% This work consists of the file afparticle.dtx and the
% derived file afparticle.cls
%
% \fi 
% \CheckSum{689}
%
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~} 
%
% \iffalse
%
%
%\section{Identification}
%\label{sec:ident}
%
% We start with the declaration who we are
%    \begin{macrocode}
%</gobble>
%<class>\NeedsTeXFormat{LaTeX2e}
%<*gobble>
\ProvidesFile{afparticle.dtx}
%</gobble>
%<class>\ProvidesClass{afparticle}
[2014/12/23 v1.3 Typesetting articles for Archives of Forensic Psychology]
%<*gobble>
%    \end{macrocode}
%
%
% \fi
%
%\iffalse
%    \begin{macrocode}
\documentclass{ltxdoc}
\usepackage{array}
\usepackage{url}
\usepackage{hypdoc}
\hypersetup{breaklinks,colorlinks,linkcolor=black,citecolor=black,
            pagecolor=black,urlcolor=black,hyperindex=false}
\PageIndex
\CodelineIndex
\RecordChanges
\EnableCrossrefs
\begin{document}
  \DocInput{afparticle.dtx}
\end{document}
%    \end{macrocode}
%</gobble> 
%<*class>
% \fi
% \MakeShortVerb{|}
% \GetFileInfo{afparticle.dtx}
% \title{Typesetting Articles for \emph{Archives of Forensic Psychology}\thanks{\copyright 2014, Boris Veytsman}} 
% \author{Boris Veytsman\thanks{%
% \href{mailto:borisv@lk.net}{\texttt{borisv@lk.net}},
% \href{mailto:boris@varphi.com}{\texttt{boris@varphi.com}}}} 
% \date{\filedate, \fileversion}
% \maketitle
% \begin{abstract}
%   This package provides a class for typesetting articles for the
%   journal \emph{Archives of Forensic Psychology},
%   \url{http://www.archivesofforensicpsychology.com}.
% \end{abstract}
% \tableofcontents
%
% \clearpage
%
%
%\section{Introduction}
%\label{sec:intro}
%
% \emph{Archives of Forensic Psychology} is an Open Access journal.
% It is described on its Web
% page\footnote{\url{http://www.archivesofforensicpsychology.com}} in
% the following way:
% \begin{quotation}
%   Archives of Forensic Psychology (AFP) is an innovative,
%   peer-reviewed journal published twice per year. Our mission is to
%   link the science and practice of forensic psychology, by making
%   research and clinical resources freely available to all mental
%   health, correctional, and legal professionals. AFP welcomes
%   empirical research, book and instrument reviews, case studies,
%   commentaries, literature reviews, and policy
%   recommendations. Particularly encouraged is the submission of
%   non-significant results as well as the findings of government
%   reports, conference presentations, Master's theses, and
%   doctoral dissertations. 
% \end{quotation}
% 
% The class |afparticle| is based on the |elsarticle|
% class~\cite{elsarticle} with the following changes:
% \begin{enumerate}
% \item Some formatting changes: unnumbered sections and paragraphs
% and others.
% \item A different formatting of the title page.
% \item Creation of the special file with the metadata used for the
% Crossref submission.
% \item Consistent use of APA~6 citation style.
% \end{enumerate}
% Most of these changes should be transparent for the user;  in the
% next section we discuss the user-visible ones in more detail.
%
%
%\section{User Manual}
%\label{sec:manual}
%
% The user should consult the manual of
% |elsarticle|~\cite{elsarticle};  below we describe only the features
% different for |afparticle| class.  
% 
%\subsection{Invocation}
%\label{sec:invocation}
%
%
% To use the class put in the preamble of your document
% \begin{verbatim}
% \documentclass{afparticle}
% \end{verbatim}
% The class supports the same options as |elsarticles| with the
% following restrictions:
% \begin{enumerate}
% \item Options |3p| and |5p| are suppressed.  The
% journal uses only |1p| one-column design. Use options |preprint| and
% |review| to typeset the article for submission, and |1p| for the
% final typesetting.
% \item Options |authoryear|, |number|, |sort&compress| are
% suppressed.  The journal uses |apacite| package~\cite{Meijer:Apacite} for the
% bibliography (see below).
% \end{enumerate}
% 
% 
% To add line numbers to the manuscript, use
% \begin{verbatim}
% \usepackage{lineno}
% \end{verbatim}
% and then either
% \begin{verbatim}
% \begin{linenumbers}
% ...
% \end{linenumbers}
% \end{verbatim}
% or the global command
% \begin{verbatim}
% \linenumbers
% \end{verbatim}
% 
%
%\subsection{Front Matter}
%\label{sec:ug:frontmatter}
%
% \DescribeMacro{\maketitle}
% Unlike |elsartclass|, |afparticle| does \emph{not} usesthe
% environment |frontmatter|.  Instead, use \cs{maketitle} like you do
% in the standard \LaTeX\ article.
%
% \emph{Archives of Forensic Psychology} normally uses the
% ``second type of frontmatter coding''~\cite{elsarticle}: the authors
% with the same affiliation are grouped together, and the affiliation
% follows the group.
%
% \DescribeMacro{\tnoteref}
% \DescribeMacro{\corref}
% \DescribeMacro{\fnref}
% As different from |elsarticle|, the frontmatter commands
% \emph{do not allow footnotes inside their arguments.}  Thus the commands
% \cs{tnoteref}, \cs{corref}, \cs{fnref} are not allowed and produce
% errors.  Please do not use them.
%
% \DescribeMacro{\author*}
% Of course, there should be a way to show the corresponding author of
% the manuscript.  For this purpose the command \cs{author} has a
% starred form \cs{author}:
% \begin{verbatim}
% \author*{John Doe}   % Corresponding author
% \address{George Mason University, Mailstop 76A12,
%          Fairfax, VA, 22030, USA, 
%          \path{jdoe@gmu.edu}}
% \author{Alexander Hamilton}  % Other author
% \address{George Washington University}
% \end{verbatim}
% Please note that the journal requires the corresponding author to
% indicate her full mailing address and e-mail.
%
% \DescribeMacro{\shortauthors}
% \LaTeX\ automatically puts the names of the authors into a running
% head on even pages.  Sometimes when the list of authors is too
% large, it does not fit there.  In this case put after all
% \cs{author} definitions the line
% \begin{verbatim}
% \renewcommand{\shortauthors}{SHORT LIST}
% \end{verbatim}
% for example,
% \begin{verbatim}
% \renewcommand{\shortauthors}{John Doe et. al.}
% \end{verbatim}
% 
% \DescribeMacro{\title}
% Unlike \cs{title} in the standard \LaTeX\ and |elsarticle|, our
% \cs{title} has two arguments: the mandatory one and the optional
% one.  The reason is, the class uses title for running heads on odd
% pages.  If the title is too long, it may not fit, and then the
% optional argument is used for running heads:
% \begin{verbatim}
% \title{Notes on evidence}   % Running head and title coincide
% \title[Notes on evidence]{Some notes on evidence as presented to the
% juries}                     % Running head and title are different 
% \end{verbatim}
%
% \DescribeMacro{\volumenumber}
% \DescribeMacro{\issuenumber}
% \DescribeMacro{\publicationyear}
% \DescribeMacro{\publicationmonth}
% \DescribeMacro{\papernumber}
% \DescribeMacro{\startpage}
% \DescribeMacro{\endpage}
%  The macros |\volumenumber|, |\issuenumber|, |\publicationyear|,
%  |\publicationmonth|, |\papernumber|, |\startpage|, |\endpage| set up the
%  corresponding 
%  data for the paper, for example:
% \begin{verbatim}
% \volumenumber{88}
% \issuenumber{1--2}
% \publicationyear{2012}
% \publicationmonth{January--February}
% \papernumber{2}
% \startpage{1}
% \endpage{39}
% \end{verbatim}
% Note that if the argument of |\endpage| is empty, \LaTeX{} tries to
% calculate the last page number as best as it can.
%
% \DescribeMacro{\received}
% \DescribeMacro{\revised}
% \DescribeMacro{\accepted}
% The macros \cs{received}\marg{date}, \cs{revised}\marg{date},
% \cs{accepted}\marg{date} are used by the editorial staff for
% techincal information about the paper.  These macros can be
% repeated.  
%
%
% \DescribeMacro{\doinumber}
% Normally you do not need to set the DOI of the paper: \TeX{} will
% construct the number using the paper data (including paper number in
% the current issue).  However, you \emph{may} override its decision
% using the command |\doinumber| which sets the DOI explicitly, for
% example, |\doinumber|\marg{12.234/afp.2013.01.01}.
% You probably  should not use this macro.
%
% \DescribeMacro{\prevpaper}
% Instead of setting |\startpage|, one can use the the command
% |\prevpaper|\marg{previous paper}, with the argument being the
% location and file name of the previous paper in the journal, for example:
% \begin{verbatim}
% \prevpaper{../evidence/rules_of_evidence}
% \end{verbatim}
% Note that the |.tex| suffix should \emph{not} be used.  The previous
% paper must be processed by |latex| prior to the current one.  In
% this case |latex| will read the last page of the previous paper, and
% start the current one from the proper page number.  
% 
%
%\subsection{Back matter}
%\label{sec:ug_back}
%
% \DescribeMacro{\printbackmatter}
% The last command of the article must be \cs{printbackmatter}.  It
% prints the technical information about the paper.
%
%\subsection{Sectioning}
%\label{sec:ug:sectioning}
%
% The class uses unnumbered sections, subsections and subsubsections.
% Never use period (.) at the end of the title: it is not allowed for
% sections and subsections and is automatically added by
% subsubsectons.  
%
%
%\subsubsection{Tables and Figures}
%\label{sec:ug_floats}
%  
% You may use tables and figures in the manuscript.  Remember that
% table caption must \emph{precede} the table while figure captions
% follow the contents.
%
% 
%
%\subsection{Bibliography}
%\label{sec:biblio}
%
% The class uses |apacite|~\cite{Meijer:Apacite} for bibliography with
% |natbibapa| option.  The format of the bibliographic commands is
% described in the manuals~\cite{Meijer:Apacite}
% and~\cite{Daly07:Natbib}.  Basically you need the commands
% \cs{citet}\marg{key} for textual citations like ``John Doe (2012) wrote
% that\ldots'' and \cs{citep}\marg{key} for parentetical citations
% like ``As shown in the literature (John Doe, 2012)\ldots''.  
%
% If you use \textsc{Bib}\TeX, add to your file
% \cs{bibliography}\marg{bibfiles} and |\bibliography{apacite}|.  For
% manual bibliographies you must use APA6 citation style.
%
% \StopEventually{\clearpage
% \bibliography{tex}
% \bibliographystyle{unsrt}}
% 
% \clearpage
%
%
%\section{Implementation}
%\label{sec:impl}
%
%
%
%\subsection{Auxillary Macros}
%\label{sec:aux}
%
% \begin{macro}{AFP@DisableMacro}
%   Some commands are disabled
%    \begin{macrocode}
\def\AFP@DisableMacro#1{\ClassError{afparticle}{The macro 
    \expandafter\protect\csname#1\endcsname\space
    is disabled}{The command
    \expandafter\protect\csname#1\endcsname\space
    is introduced in the
    elsarticle class.\MessageBreak  It is disabled in afpartcile
    class}}
%    \end{macrocode}
%   
% \end{macro}
% \begin{macro}{\@nx}
% \begin{macro}{\@xp}
% \begin{macro}{\@ifnotempty}
%   From |amsart|
%    \begin{macrocode}
\let\@xp=\expandafter
\let\@nx=\noexpand
\long\def\@ifempty#1{\@xifempty#1@@..\@nil}
\long\def\@xifempty#1#2@#3#4#5\@nil{%
  \ifx#3#4\@xp\@firstoftwo\else\@xp\@secondoftwo\fi}
\long\def\@ifnotempty#1{\@ifempty{#1}{}}
%    \end{macrocode}
%   
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\nxandlist}
%   This is from |amsart|:
%    \begin{macrocode}
\newtoks\@emptytoks
\def\@andlista#1#2\and#3\and{\@andlistc{#2}\@ifnotempty{#3}{%
  \@andlistb#1{#3}}}
\def\@andlistb#1#2#3#4#5\and{%
  \@ifempty{#5}{%
    \@andlistc{#2#4}%
  }{%
    \@andlistc{#1#4}\@andlistb{#1}{#3}{#3}{#5}%
  }}
\let\@andlistc\@iden
\newcommand{\nxandlist}[4]{%
  \def\@andlistc##1{\toks@\@xp{\the\toks@##1}}%
  \toks@{\toks@\@emptytoks \@andlista{{#1}{#2}{#3}}}%
  \the\@xp\toks@#4\and\and
  \edef#4{\the\toks@}%
  \let\@andlistc\@iden}
%    \end{macrocode}
%   
% \end{macro}
% \begin{macro}{\@@and}
%   The final `and' in the list
%    \begin{macrocode}
\def\@@and{and}
%    \end{macrocode}
%   
% \end{macro}
%
% \begin{macro}{\author@andify}
%   Again |amsart|
%    \begin{macrocode}
\def\author@andify{%
  \nxandlist {\unskip ,\penalty-1 \space\ignorespaces}%
    {\unskip {} \@@and~}%
    {\unskip ,\penalty-2 \space\@@and~}%
}
%    \end{macrocode}
%   
% \end{macro}
%
%
%\subsection{Options}
%\label{sec:options}
%
% We use |xkeyval|: right now our options do not have values, but we
% may change this.
%    \begin{macrocode}
\RequirePackage{xkeyval}
%    \end{macrocode}
% 
% \begin{macro}{AFP@OptionWarning}
%   We disable some options and issue a warning:
%    \begin{macrocode}
\def\AFP@OptionWarning#1{\ClassWarning{afparticle}{The option #1 is
    not used for afparticle.  I will silently ignore it}}
%    \end{macrocode}
% \end{macro}
%
%
% The suppressed options:
%    \begin{macrocode}
\DeclareOptionX{3p}{\AFP@OptionWarning{\CurrentOption}}%
\DeclareOptionX{5p}{\AFP@OptionWarning{\CurrentOption}}%
\DeclareOptionX{authoryear}{\AFP@OptionWarning{\CurrentOption}}%
\DeclareOptionX{number}{\AFP@OptionWarning{\CurrentOption}}%
\DeclareOptionX{sort&compress}{\AFP@OptionWarning{\CurrentOption}}%
%    \end{macrocode}
% 
% All non-suppressed options are passed to |elsarticle|:
%    \begin{macrocode}
\DeclareOptionX*{\PassOptionsToClass{\CurrentOption}{elsarticle}}
%    \end{macrocode}
%
%
% And executing options:
%    \begin{macrocode}
\ProcessOptionsX
%    \end{macrocode}
% 
%
%\subsection{Loading Classes and Packages}
%\label{sec:classes}
%
% We want to prevent loading of natbib
%    \begin{macrocode}
\@namedef{ver@natbib.sty}{}
\@namedef{opt@natbib.sty}{round,authoryear}
\newlength\bibsep
%    \end{macrocode}
%
% We use |elasrticle| since it has nice features for front matter:
%    \begin{macrocode}
\LoadClass[1p,authoryear,round]{elsarticle}
%    \end{macrocode}
%
% We need |lastpage| for last page calculations, |fancyhdr| for our
% headings, |hyperref| for references and |caption| for caption
% formatting. 
%    \begin{macrocode}
\RequirePackage{lastpage,fancyhdr}
\RequirePackage{caption}
\RequirePackage{booktabs}
\RequirePackage{graphicx}
\RequirePackage[hyperfootnotes=false,colorlinks,allcolors=blue]{hyperref}
%    \end{macrocode}
% 
% And now we do want natbib!
%    \begin{macrocode}
\expandafter\let\csname ver@natbib.sty\endcsname=\@undefined
\let\bibsep=\@undefined
\RequirePackage[natbibapa]{apacite}
%    \end{macrocode}
% 
%
%\subsection{Front Matter}
%\label{sec:frontmatter}
% 
% \begin{macro}{\abstract}
%   We do not use the word ``abstract'' for abstract
\renewenvironment{abstract}{\global\setbox\absbox=\vbox\bgroup
  \hsize=\textwidth\def\baselinestretch{1}%
  \noindent\unskip\ignorespaces}
 {\egroup}
% \end{macro}
%
% \begin{macro}{\tnoteref}
%   This macro is disabled.
%    \begin{macrocode}
\def\tnoteref#1{\AFP@DisableMacro{tnoteref}}
%    \end{macrocode}
%   
% \end{macro}
% \begin{macro}{\corref}
%   This macro is disabled.
%    \begin{macrocode}
\def\corref#1{\AFP@DisableMacro{corref}}
%    \end{macrocode}
%   
% \end{macro}
% \begin{macro}{\fnref}
%   This macro is disabled.
%    \begin{macrocode}
\def\fnref#1{\AFP@DisableMacro{fnref}}
%    \end{macrocode}
%   
% \end{macro}
%
% \begin{macro}{\title}
%   This is from |amsart|:
%    \begin{macrocode}
\renewcommand*{\title}[2][]{\gdef\shorttitle{#1}\gdef\@title{#2}}
\edef\title{\@nx\@dblarg
  \@xp\@nx\csname\string\title\endcsname}
%    \end{macrocode}
%   
% \end{macro}
%
% \begin{macro}{\ifAFP@corrauthor}
%   This checks whether this author is the coresponding author
%    \begin{macrocode}
\newif\ifAFP@corrauthor
%    \end{macrocode}
%   
% \end{macro}
%
% \begin{macro}{\authors}
%   We store in \cs{authors} the list of authors separated by
%   \cs{and}.
%    \begin{macrocode}
\def\authors{}
%    \end{macrocode}
%   
% \end{macro}
%
% \begin{macro}{\shortauthors}
%   Initially we define \cs{shortauthors} as \cs{authors}, but the
%   user can redefine it.
%    \begin{macrocode}
\def\shortauthors{\authors}
%    \end{macrocode}
%   
% \end{macro}
%
% \begin{macro}{\author}
%   First, check whether this author is the corresponding author.
%    \begin{macrocode}
\def\author{%
  \@ifstar{\AFP@corrauthortrue\AFP@author}{\AFP@corrauthorfalse\AFP@author}}
%    \end{macrocode}
%   
% \end{macro}
%
% \begin{macro}{\AFP@author}
%   The macro \cs{AFP@author} is our version of the standard
%   \cs{autor} macro
%    \begin{macrocode}
\def\AFP@author{\@ifnextchar[{\@@author}{\@author}}
%    \end{macrocode}
%   
% \end{macro}
%
% \begin{macro}{\@@author}
%   This typesets an author with some footnotes
%    \begin{macrocode}
\def\@@author[#1]#2{%
  \ifx\@empty\authors
      \gdef\authors{#2}%
  \else
    \g@addto@macro\authors{\and#2}%
  \fi
  \g@addto@macro\elsauthors{%
    \normalsize\upshape
    \def\baselinestretch{1}%
    \authorsep#2\unskip}%
  \ifAFP@corrauthor
  \g@addto@macro\elsauthors{\textsuperscript{$\ast$,}}\fi
  \g@addto@macro\elsauthors{%
    \textsuperscript{%#1%
      \@for\@@affmark:=#1\do{%
        \edef\affnum{\@ifundefined{X@\@@affmark}{1}{\elsRef{\@@affmark}}}%
        \unskip\sep\affnum\let\sep=,}%
      \ifx\@fnmark\@empty\else\unskip\sep\@fnmark\let\sep=,\fi
      \ifx\@corref\@empty\else\unskip\sep\@corref\let\sep=,\fi
    }%
    \def\authorsep{\unskip,\space}%
    \global\let\sep\@empty\global\let\@corref\@empty
    \global\let\@fnmark\@empty}%
  \@eadauthor={#2}
}
%    \end{macrocode}
%   
% \end{macro}
%
% \begin{macro}{\@author}
%   No footnote marks after the author:
%    \begin{macrocode}
\def\@author#1{%
  \ifx\@empty\authors
     \gdef\authors{#1}%
  \else
    \g@addto@macro\authors{\and#1}%
  \fi
 \g@addto@macro\elsauthors{\normalsize%
    \def\baselinestretch{1}%
    \upshape\authorsep#1}
  \ifAFP@corrauthor
  \g@addto@macro\elsauthors{\textsuperscript{$\ast$}}\fi
  \g@addto@macro\elsauthors{%
    \def\authorsep{\unskip,\space}%
    \global\let\@fnmark\@empty
    \global\let\sep\@empty}%
    \@eadauthor={#1}
}
%    \end{macrocode}
%   
% \end{macro}
%
% \begin{macro}{\@address}
% \changes{v1.0}{2014/08/18}{Added macro}
%   We redefine |elsarticle| macro to change the vertical spacing
%    \begin{macrocode}
\long\def\@address#1{\g@addto@macro\elsauthors{%
    \def\baselinestretch{1}\def\addsep{\par\vskip4pt}%
    \addsep\footnotesize\itshape#1%
    \def\authorsep{\par\vskip16pt}}}
%    \end{macrocode}
%   
% \end{macro}
%
%
% The next lines are from |resphilosophica| class
% \begin{macro}{\paperUrl}
%   The url to submit to crossref
%    \begin{macrocode}
\def\paperUrl#1{\gdef\@paperUrl{#1}}
\paperUrl{}
%    \end{macrocode}
%   
% \end{macro}
% \begin{macro}{\@mainrpi}
%   The stream for the rpi file:
%    \begin{macrocode}
\newwrite\@mainrpi
%    \end{macrocode}
%   
% \end{macro}
%
% \begin{macro}{\RESP@write@paper@info}
%   This writes the information about the paper into the file
%   |jobname.rpi|.  Note that hyperref makes our life a little bit
%   more complex
%    \begin{macrocode}
\def\RESP@write@paper@info{%
  \bgroup
  \if@filesw
     \openout\@mainrpi\jobname.rpi%
     \write\@mainrpi{\relax}%
    \ifx\r@LastPage\@undefined
       \edef\@tempa{\start@page}%
    \else
       \def\@tempb##1##2##3##4##5{##2}%
       \edef\@tempa{\expandafter\@tempb\r@LastPage}%
    \fi
    \def\and{\string\and\space}%
    \protected@write\@mainrpi{}%
    {\string\articleentry{\authors}{\@title}{\start@page}{\@tempa}}%
%    \end{macrocode}
%  The next lines are for crossref software
%    \begin{macrocode}
   \protected@write\@mainrpi{}%
    {\@percentchar authors=\authors}%
   \protected@write\@mainrpi{}%
    {\@percentchar title=\@title}%
   \protected@write\@mainrpi{}%
    {\@percentchar year=\currentyear}%
   \protected@write\@mainrpi{}%
    {\@percentchar volume=\currentvolume}%
   \protected@write\@mainrpi{}%
    {\@percentchar issue=\currentissue}%
   \protected@write\@mainrpi{}%
    {\@percentchar paper=\currentpaper}%
   \protected@write\@mainrpi{}%
    {\@percentchar startpage=\start@page}%
   \protected@write\@mainrpi{}%
    {\@percentchar endpage=\@tempa}%
   \protected@write\@mainrpi{}%
    {\@percentchar doi=\@doinumber}%
   \ifx\@paperUrl\@empty\else
   \protected@write\@mainrpi{}%
    {\@percentchar paperUrl=\@paperUrl}%
   \fi
    \closeout\@mainrpi
    \fi
\egroup}
%    \end{macrocode}
%   
% \end{macro}
%
%
% \begin{macro}{\maketitle}
% \changes{v1.0}{2014/08/18}{Moved the text down}
%   Our macro is simpler than that of |elsarticle|, since we have
%   fewer options.
%    \begin{macrocode}
\def\maketitle{%
  \null\bigskip\par
  \iflongmktitle\getSpaceLeft
     \global\setbox\els@boxa=\vsplit0 to \@tempdima
     \box\els@boxa\par\resetTitleCounters
     \printFirstPageNotes
     \box0%
   \else
       \finalMaketitle\printFirstPageNotes
   \fi
   \RESP@write@paper@info
   \author@andify\authors
   \xdef\authors{\authors}%
   \gdef\thefootnote{\arabic{footnote}}%
   \thispagestyle{firstpagestyle}%
}
%    \end{macrocode}
%   
% \end{macro}
%
% \begin{macro}{\volumenumber}
%   This sets the volume of the paper
%    \begin{macrocode}
\def\volumenumber#1{\gdef\currentvolume{#1}}
\volumenumber{}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\issuenumber}
%   This sets the issue of the paper:
%    \begin{macrocode}
\def\issuenumber#1{\gdef\currentissue{#1}}
\issuenumber{}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\publicationyear}
%   This sets the year of the paper
%    \begin{macrocode}
\def\publicationyear#1{\gdef\currentyear{#1}}
\publicationyear{}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\publicationmonth}
%   This sets the month of the paper
%    \begin{macrocode}
\newcommand\publicationmonth[2][]{\gdef\currentmonth{#2}%
  \gdef\abbrevcurrentmonth{#1}%
  \ifx\abbrevcurrentmonth\@empty\gdef\abbrevcurrentmonth{#2}\fi}
\publicationmonth{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\papernumber}
%   This is absent from the |\issueinfo|.  
%    \begin{macrocode}
\def\papernumber#1{\gdef\currentpaper{#1}}
\papernumber{0000}
%   
% \end{macro}
%
%
% \begin{macro}{\doinumber}
%    \begin{macrocode}
\def\doinumber#1{\gdef\@doinumber{#1}}
\doinumber{123.4567/archivesforensicpsychology.\currentyear.\currentvolume.\currentissue.\currentpaper}
%    \end{macrocode}
% \end{macro}
% 
%
% \begin{macro}{\startpage}
%   This defines the starting page of the paper.  We have some nice
%   features to set up roman page numbers for editorial
%   stuff---probably not needed for this journal at this time\dots
%    \begin{macrocode}
\def\startpage#1{\pagenumbering{arabic}\setcounter{page}{#1}%
  \gdef\start@page{#1}%
  \ifnum\c@page<\z@ \pagenumbering{roman}\setcounter{page}{-#1}%
    \gdef\start@page{\romannumeral#1}%
  \fi}
%    \end{macrocode}   
% \end{macro}
%
% \begin{macro}{\endpage}
%   This macro again has a twist in it: if the argument is not set, it
%   calculates the last page number itself.
%    \begin{macrocode}
\def\endpage#1{\def\@tempa{#1}%
  \ifx\@tempa\@empty\def\end@page{\pageref{LastPage}}%
  \else\def\end@page{#1}\fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\pagespan}
%   This macro is different from the one provided by |amsart|
%   because we want to have the option of automatic calculation of the
%   last page number.
%    \begin{macrocode}
\def\pagespan#1#2{\startpage{#1}\endpage{#2}}
\pagespan{1}{}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\articleentry}
%   This is necessary for |\prevpaper| command.  We read the TOC entry
%   from the previous paper and increment it by 1.  Note that we
%   always start with on an odd page, since the additional check
%    \begin{macrocode}
\def\articleentry#1#2#3#4{\@tempcnta=#4\relax
  \advance\@tempcnta by 1\relax
  \ifodd\the\@tempcnta\else\advance\@tempcnta by 1\relax\fi
  \startpage{\the\@tempcnta}}
%    \end{macrocode}
%   
% \end{macro}
%
% \begin{macro}{\prevpaper}
%   This sets the previous paper location and reads the information
%   from the previous paper
%    \begin{macrocode}
\def\prevpaper#1{\IfFileExists{#1.rpi}{%
    \ClassInfo{afparticle}{%
      Reading first page number from the file #1.rpi}%
    \input{#1.rpi}%
  }{\ClassWarning{afparticle}{Cannot find the file #1.rpi.  
      Did you run latex on the previous paper?}}}
%    \end{macrocode}
%   
% \end{macro}
%
%
%\subsection{Back Matter}
%\label{sec:back}
%
% \begin{macro}{\AFP@backmatter}
%   The technical information about the paper.
%    \begin{macrocode}
\def\AFP@backmatter{}
%    \end{macrocode}
%   
% \end{macro}
% \begin{macro}{\received}
%   Date of receiving
%    \begin{macrocode}
\def\received#1{\g@addto@macro\AFP@backmatter{Received: #1\\}}
%    \end{macrocode}
%   
% \end{macro}
% \begin{macro}{\revised}
%   Date of receiving a revision
%    \begin{macrocode}
\def\revised#1{\g@addto@macro\AFP@backmatter{Revision Received: #1\\}}
%    \end{macrocode}
%   
% \end{macro}
% \begin{macro}{\accepted}
%   Date of acceptance
%    \begin{macrocode}
\def\accepted#1{\g@addto@macro\AFP@backmatter{Accepted: #1\\}}
%    \end{macrocode}
%   
% \end{macro}
%
%    \begin{macrocode}
%    \end{macrocode}
% 
% \begin{macro}{\printbackmatter}
%   Print the back matter
%    \begin{macrocode}
\def\printbackmatter{\ifx\AFP@backmatter\@empty\else\medskip
  \begin{flushright}%
    \AFP@backmatter
  \end{flushright}%
\fi}
%    \end{macrocode}
%   
% \end{macro}
%
%\subsection{Page styles}
%\label{sec:styles}
%
% In |preprint| mode |elsarticle| uses one side style.  We want to
% override this:
%    \begin{macrocode}
\AtBeginDocument{\@twosidetrue}
%    \end{macrocode}
% 
% \begin{macro}{\footskip}
%   We want generous \cs{footskip}
%    \begin{macrocode}
\setlength\footskip{40\p@}
%    \end{macrocode}
%   
% \end{macro}
% 
% \begin{macro}{\headrulewidth}
% \begin{macro}{\footrulewidth}
%   We do not want decorative rules in the journal:
%    \begin{macrocode}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{standardpagestyle}
%   The page style for all pages but the first one
%    \begin{macrocode}
\fancypagestyle{standardpagestyle}{%
  \fancyhead{}%
  \fancyfoot{}%
  \fancyfoot[R]{\thepage}%
  \fancyhead[CE]{\scshape\MakeLowercase{\shortauthors}}%
  \fancyhead[CO]{\scshape\MakeLowercase{\shorttitle}}%
}
\pagestyle{standardpagestyle}
%    \end{macrocode}
%   
% \end{macro}
%
% \begin{macro}{firstpagestyle}
% \changes{v1.2}{2014/10/22}{Corrected masthead}
% \changes{v1.3}{2014/12/23}{Corrected another typo in masthead}
%   The page style for the first page
%    \begin{macrocode}
\fancypagestyle{firstpagestyle}{%
  \fancyhead{}%
  \fancyfoot{}%
  \fancyfoot[R]{\thepage}%
  \fancyhead[L]{\small Archives of Forensic Psychology\\
    \currentyear, Vol.~\currentvolume, No.~\currentissue,
    \thepage--\end@page}%
   \fancyhead[R]{\small\textcopyright~\currentyear\ Global Institute of
     Forensic Psychology\\ISSN~2334-2749}%
}
%    \end{macrocode}
% \end{macro}
%
%
%\subsection{Paragraphing}
%\label{sec:paras}
%
% \begin{macro}{\parindent}
%   We want generous indents
%    \begin{macrocode}
\setlength\parindent{2em}
%    \end{macrocode}
%   
% \end{macro}
%
%
%\subsection{Sectioning}
%\label{sec:sectioning}
%
% \begin{macro}{secnumdepth}
%   We do not number sections
%    \begin{macrocode}
\setcounter{secnumdepth}{-1}
%    \end{macrocode}
%   
% \end{macro}
%
% \begin{macro}{\section}
%   We center our sections:
%    \begin{macrocode}
\renewcommand\section{\@startsection {section}{1}{\z@}%
           {18\p@ \@plus 6\p@ \@minus 3\p@}%
           {9\p@ \@plus 6\p@ \@minus 3\p@}%
           {\centering\normalsize\bfseries\boldmath}}
%    \end{macrocode}
%   
% \end{macro}
%
% \begin{macro}{\subsection}
%   Our subsections look like sections, but flushed left
%    \begin{macrocode}
\renewcommand\subsection{\@startsection {subsection}{2}{\z@}%
           {18\p@ \@plus 6\p@ \@minus 3\p@}%
           {9\p@ \@plus 6\p@ \@minus 3\p@}%
           {\normalsize\bfseries\boldmath}}
%    \end{macrocode}
%   
% \end{macro}
%
% \begin{macro}{\subsubsection}
%   Our subsubsections are italicized and written on the same line as
%   the text.  Also, they end with dots.
%    \begin{macrocode}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{0\z@}%
           {0\z@}%
           {-6\p@}%
           {\normalfont\hspace*{\parindent}\itshape\@addfinaldot}}
%    \end{macrocode}
%   
% \end{macro}
%
% \begin{macro}{\@addfinaldot}
%   Add a dot after a text
%    \begin{macrocode}
\def\@addfinaldot#1{#1.}
%    \end{macrocode}
%   
% \end{macro}
%
%
%\subsection{Floats}
%\label{sec:floats}
% \changes{v1.0}{2014/08/18}{Centered captions}
% Setting up table captions
%    \begin{macrocode}
\DeclareCaptionLabelSeparator{periodNewline}{.\\}
\captionsetup[table]{position=top, format=plain,
  labelsep=periodNewline, justification=centering,
  singlelinecheck=off, font=normalsize, textfont=it}
%    \end{macrocode}
% 
% Setting up figure captions
%    \begin{macrocode}
\captionsetup[figure]{position=bottom, format=plain,
  labelsep=period, justification=centering,
  singlelinecheck=off, font=normalsize, labelfont=it}
%    \end{macrocode}
% 
%
%\subsection{Final Words}
%\label{sec:finis}
%
% \changes{v1.1}{2014/10/20}{Added changes requested by the editor and
%   implemented by David Latchman,
%   david.latchman@texnical-designs.com: no hyphenation throughout the
%   entire manuscript}
%
%    \begin{macrocode}
\tolerance=1
\emergencystretch=\maxdimen
\hyphenpenalty=10000
\hbadness=10000
\normalsize\normalfont
%</class>
%    \end{macrocode}
%
%\Finale
%\clearpage
%
%\PrintChanges
%\clearpage
%\PrintIndex
%
\endinput
