% Copyright 2022 Cyril Banderier, Michael Wallner
% Inspired and partly adapted from FPSAC2021.cls by Nicholas Beaton 2018

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{SLC-preface}[2023]
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions\relax
\LoadClass[12pt,reqno]{amsart}

\def\headertitle#1{\def\@headertitle{#1}}
\newcommand{\printheadertitle}{\@headertitle}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def \@articlenumber{XX}
\def \articlenumber#1{\gdef \@articlenumber{#1}}
\def \@doinumber{addedlater}
\def \doinumber#1{\gdef \@doinumber{#1}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\RequirePackage{graphicx} 
\graphicspath{{./}{../}}

\RequirePackage{amsmath,amssymb,amsthm}
\RequirePackage{lmodern}    
\RequirePackage[T1]{fontenc}    
\RequirePackage[nopatch=eqnum]{microtype}
%%%%%%%%%%%%%%%%%%%%%%%%%%%            From: https://tex.stackexchange.com/questions/682319/t1-font-encoding-newtxtext-and-microtype-result-in-package-microtype-info-ch
\let\originalMT@info@missing@char\MT@info@missing@char
\def\MT@info@missing@char{%
  \def\privateMTc{029}%
  \edef\privateMTv{\the\MT@toks}%
  \ifx\privateMTc\privateMTv%
    \def\privateMTc{sc}%
    \ifx\privateMTc\f@shape%
    \else%
      \originalMT@info@missing@char%
    \fi%
  \else%
    \originalMT@info@missing@char%
  \fi%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%

\RequirePackage{zref-totpages}
\RequirePackage{mathtools}
\mathtoolsset{showonlyrefs}

\RequirePackage{ifthen}
\RequirePackage{cite} %ordering the citations
\RequirePackage{url} 
\RequirePackage{fancyhdr} 
\RequirePackage[text={16cm,23cm},centering]{geometry} %recommanded by Christian/SLC

\linespread{1.05}           
\setlength \baselineskip{22pt plus 2pt}
% \setlength \textheight{56pc}
% \setlength \textwidth{35pc}
\setlength \headsep{20\p@}
% \setlength \footskip{10\p@}
% \setlength \oddsidemargin{10\p@}
% \setlength \evensidemargin{21\p@}
% \setlength \textfloatsep{13\p@ \@plus 2\p@ \@minus 4\p@}
% \setlength \dbltextfloatsep{13\p@ \@plus 2\p@ \@minus 4\p@}
% \setlength \parskip{\z@ \@plus 1\p@}
% \setlength \parindent{10\p@}
% \setlength \topsep{4\p@ \@plus 2\p@ \@minus 1\p@}

\numberwithin{equation}{section}

\newcommand{\oeis}[1]{\text{\href{https://oeis.org/#1}{{\small \tt #1}}}} 
\newcommand{\arxiv}[1]{\text{\href{https://doi.org/10.48550/arXiv.#1}{{arXiv:#1}}}} 

\newif \if@keywordsgiven
\@keywordsgivenfalse
\def\@keywords{\relax}
% pulling keywords information from source
\def \keywords{\@getkeywords}
\def \@getkeywords#1{{
  \global \@keywordsgiventrue
  \gdef \@keywords{#1.}
}}

\newif \if@creditsgiven
\@creditsgivenfalse
\def\@credits{\relax}
% pulling credits information from source
\def \credits{\@getcredits}
\def \@getcredits#1{{
  \global \@creditsgiventrue
  \gdef \@credits{\\#1}
}} %We invite the authors to put credits/fundings in the acknowledgments section, at the end of the article. If really needed, the authors can use \credits{blah} to have blah on bottom of page 1.

\newif \if@abstractgiven
\@abstractgivenfalse
\def \@abstract{\relax}
\long\def \abstract#1{
  \global \@abstractgiventrue
  \long\gdef \@abstract{#1}
}

\let\authors\@empty

%%% Renew author to distinguish in copyright between "The author" and "The authors" %%%
%%% copy-paste of \author from amsart 01/06/2022: https://www.ctan.org/pkg/amsart
\newcommand{\copyrightauthors}{the author}
\renewcommand{\author}[2][]{%
  \ifx\@empty\authors
    \gdef\authors{#2}%
  \else
    \g@addto@macro\authors{\and#2}%
    \g@addto@macro\addresses{\author{}}%
	\renewcommand{\copyrightauthors}{the authors}
  \fi
  \@ifnotempty{#1}{%
    \ifx\@empty\shortauthors
      \gdef\shortauthors{#1}%
    \else
      \g@addto@macro\shortauthors{\and#1}%
    \fi
  }%
}

\renewcommand{\datename}{}
\date{{\vspace{-4mm}\flushleft  {\tiny %\copyright\ 
\href{https://en.wikipedia.org/wiki/Creative_Commons_license}{\includegraphics[width=11mm]{CCBYSA.png}} : 
Released by \copyrightauthors\  under the \href{https://creativecommons.org/licenses/by-sa/4.0/}{CC-BY-SA} license (International 4.0). 
Article published online August 2023.
}}%end flushleft
\@credits}
\def\@setdate{\datename\ \@date} %to remove the extra "." after credits.  

\let \pagenumber=\@gobble

\AtBeginDocument{\gdef \@thefirstpage{\thepage}}

\fancypagestyle{firststyle}
{
   \fancyhf{}
   \fancyhead[L]{\footnotesize 
       \href{https://www.mat.univie.ac.at/~slc/}{\textit{S\'eminaire Lotharingien de Combinatoire {\bf 87B}} (2023)} \\ 
       Preface, \ztotpages pp.\\
%We'll possibly add this later, using the arXiv DOI:
%\url{https://doi.org/\@doinumber}
}
   \fancyhead[R]{\footnotesize \textit{Special issue for the $9^{th}$\! International Conference} \\ \textit{on Lattice Path Combinatorics and Applications}\\ }
   \renewcommand{\headrulewidth}{0pt} % removes horizontal header line
   
%\fancyhead[C]{\rule{.5\textwidth}{4\baselineskip}}% Add something BIG in the header
\setlength{\headheight}{36.1pt}
%\setlength{\headheight}{1.1pt}
}

\global \@twosidetrue

\def\@titlehead{\shorttitle}
\def\@authorhead{\shortauthors}

\def \ps@journal{
  \let \@mkboth \@gobbletwo
  \def \@evenhead{%
    \def \thanks####1{\relax}%
    \small \thepage \hfill \textit{\@authorhead}%
  }
  \def \@oddfoot{}
  \def \@oddhead{%
    \small \textit{\@titlehead} \hfill \thepage%
  }
  \def \@evenfoot{}
}
%%% Renew setaddresses to reduce the space between addresses:  
%%% \smallskipamount instead of \bigskipamount
%%% copy-paste from amsart 01/06/2022: https://www.ctan.org/pkg/amsart
\def\@setaddresses{\par
  \nobreak \begingroup
\footnotesize
  \def\author##1{\nobreak\addvspace\bigskipamount}%
  \def\\{\unskip, \ignorespaces}%
  \interlinepenalty\@M
  \def\address##1##2{\begingroup
    \par\addvspace\smallskipamount\indent
    \@ifnotempty{##1}{(\ignorespaces##1\unskip) }%
    {\scshape\ignorespaces##2}\par\endgroup}%
  \def\curraddr##1##2{\begingroup
    \@ifnotempty{##2}{\nobreak\indent\curraddrname
      \@ifnotempty{##1}{, \ignorespaces##1\unskip}\/:\space
      ##2\par}\endgroup}%
  \def\email##1##2{\begingroup
    \@ifnotempty{##2}{\nobreak\indent\emailaddrname
      \@ifnotempty{##1}{, \ignorespaces##1\unskip}\/:\space
      \ttfamily##2\par}\endgroup}%
  \def\urladdr##1##2{\begingroup
    \def~{\char`\~}%
    \@ifnotempty{##2}{\nobreak\indent\urladdrname
      \@ifnotempty{##1}{, \ignorespaces##1\unskip}\/:\space
      \ttfamily##2\par}\endgroup}%
  \addresses
  \endgroup
}

\renewcommand \maketitle{%
  \@topnum\z@ % this prevents figures from falling at the top of page 1
  \thispagestyle{firststyle}
	\begingroup
  \@maketitle
  \endgroup
	  
  \vspace{-15\p@}
  \ifx\@empty\addresses \else\@setaddresses\fi
  \vspace{20\p@}

  \@makeabstract
		
  %
  \renewcommand{\addresses}{}
}

\newcommand \printkeywords{
  \small \noindent \textbf{Keywords:} \@keywords \par
}

\newenvironment{titlesp}{
  \list{}{
    \leftmargin 0pt
  }\item[]
}{\endlist}

\newenvironment{abstractsp}{
  \list{}{
    \leftmargin 25pt
    \rightmargin 25pt
  }\item[]
}{\endlist}

\def \@makeabstract{
  \begin{abstractsp}
    \vspace{-5\p@}
    \bgroup
    \small
    \if@abstractgiven{\noindent{\textbf{Abstract.} \@abstract \par}}\fi
    \if@keywordsgiven{\vspace{4\p@} \printkeywords}\fi
    \egroup
  \end{abstractsp}
  % \vspace{8\p@}
  % \hrule \@height 1\p@
}


\newcommand \acknowledgments{\section*{Acknowledgments}}
\newcommand \acknowledgements{\section*{Acknowledgements}}

\newtheorem{theorem}{Theorem}[section]
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{conjecture}[theorem]{Conjecture}  
\newtheorem{problem}[theorem]{Problem}

\theoremstyle{definition}
\newtheorem{example}[theorem]{Example}  
\newtheorem{definition}[theorem]{Definition}   

\theoremstyle{remark}
\newtheorem{remark}[theorem]{Remark}  

\def\@setkeywords{} %overwrite fct from amsart; prevent keywords in footnote on first page

\newcommand \website[1]{\tt \url{#1}}
\newcommand{\orcid}[1]{{\raisebox{-1mm}{\scalebox{0.04}{\href{https://orcid.org/#1}{\protect\includegraphics{orcid}}}}}}

%%%%%%%% Put hyperref at the end %%%%%%%%%%%%   possible issue: authors add some packages, leading to the error 
%%%  pdfTeX warning (ext4): destination with the same identifier (name{table.1}) has been already used, duplicate ignored
%%%  <argument> ...shipout:D \box_use:N \l_shipout_box         \__shipout_drop_firstpage_...

%%% add here, if any, the author package which should be BEFORE hyperref %%%
%\RequirePackage{algorithm}  

%%% now the rest of our style: %%%
\RequirePackage{xcolor}
\definecolor{darkgreen}{rgb}{0,0.4,0}
\definecolor{green}{rgb}{0,0.4,0}
\definecolor{BrickRed}{rgb}{0.65,0.08,0}
\RequirePackage{hyperref}\hypersetup{colorlinks=true,linkcolor=blue,citecolor=darkgreen,filecolor=BrickRed,urlcolor=darkgreen}

\pagestyle{journal}
\endinput
% end of file