%% Simple style-file for Combinatorial Theory
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage[a4paper,twoside]{geometry}
\usepackage{amsthm,amssymb,amsmath}
\usepackage{tgtermes}
\usepackage[noblocks]{authblk}
\usepackage{xparse}	 	% see comment (*) below
\usepackage{color}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage[colorlinks=true,citecolor=blue,linkcolor=blue,urlcolor=black]{hyperref}
 
 % fonts
 \renewcommand{\familydefault}{qtm}
 \renewcommand\Authfont{\fontsize{12}{14.4}\selectfont}
 \newcommand\smAuthfont{\fontsize{9}{14.4}\selectfont}

% change numbering of some things to within section
\numberwithin{equation}{section}
\numberwithin{figure}{section}
\numberwithin{table}{section}

% Section formatting
\def\@seccntformat#1{\@ifundefined{#1@cntformat}%
   {\csname the#1\endcsname\space}%    default
   {\csname #1@cntformat\endcsname}}%  enable individual control
\newcommand\section@cntformat{\thesection.\space}       % section-level
\newcommand\subsection@cntformat{\thesubsection.\space} % subsection-level


% dimensions
\setlength{\textwidth}{6.3in}
\setlength{\textheight}{8.7in}
\setlength{\topmargin}{0pt}
\setlength{\headsep}{16pt}
\setlength{\headheight}{4pt}
\setlength{\oddsidemargin}{0pt}
\setlength{\evensidemargin}{0pt}

\renewcommand{\geq}{\geqslant}
\renewcommand{\leq}{\leqslant}
\renewcommand{\ge}{\geqslant}
\renewcommand{\le}{\leqslant}
\renewcommand{\emptyset}{\varnothing}

\newenvironment{corrigendum}[1]%
{\clearpage\newpage\section*{Corrigendum -- submitted #1}}{}

\newcommand{\reusenumber}[2]{\setcounter{#1}{#2}\addtocounter{#1}{-1}}

\newcommand{\specs}[4]{\def\papno{#1}\def\volno{#2}\def\volyear{#3}\def\papid{#4}}
\ifx\volno\undefined\def\volno{27}\fi
\ifx\volyear\undefined\def\volyear{2020}\fi
\ifx\papno\undefined\def\papno{P00}\fi
\ifx\papid\undefined\def\papid{abcd}\fi

\newcommand{\Copyright}[1]{\def\copy@right{\copyright\thinspace\ignorespaces#1}}
\newcommand{\dateline}[3]{\footnotesize \def\the@dateline{Submitted: \ignorespaces#1;
    Accepted: \ignorespaces#2; Published: \ignorespaces#3\\[0.5ex]\copy@right}}
\newcommand{\MSC}[1]{\def\the@MSC{\ignorespaces#1}}
\providecommand{\keywords}[1]
{
  \linebreak\small	
  \textbf{\textbf{Keywords:\,}} #1
}

\let\old@maketitle\maketitle
\renewcommand{\maketitle}{\date{\small\the@dateline}\old@maketitle}

%% abstracts presentation
\def\abstractheadfont{\scshape}
\def\@setabstracthead{{\abstractheadfont\abstractname}}


\renewenvironment{abstract}{%
  \small
  \quotation
   \noindent\abstractheadfont{\abstractname}.\normalfont}
  {\par\smallskip\noindent
   \textbf{Mathematics Subject Classifications: }\the@MSC\endquotation}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% The next group of commands makes the font smaller for the title and
%% for section and subsection headings, and adjusts the space just below
%% each such heading.

\renewcommand\title[1]{\gdef\@title{\reset@font\scshape #1}}
\renewcommand\section{\@startsection {section}{1}{\z@}%
                                   {-3.5ex \@plus -1ex \@minus -.2ex}%
                                   {2.3ex \@plus.2ex}%
                                   {\normalfont\large\bfseries}}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
                                     {-3ex\@plus -1ex \@minus -.2ex}%
                                     {1.5ex \@plus .2ex}%
                                     {\normalfont\normalsize\bfseries}}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
                                     {-2.5ex\@plus -1ex \@minus -.2ex}%
                                     {1.5ex \@plus .2ex}%
                                     {\normalfont\normalsize\bfseries}}

\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
                                     {2ex \@plus.5ex \@minus.2ex}%
                                     {-1em}%
                                     {\normalfont\normalsize\bfseries}}

\renewcommand\subparagraph{\@startsection{subparagraph}{5}{\parindent}%
                                     {2ex \@plus.5ex \@minus .2ex}%
                                     {-1em}%
                                     {\normalfont\normalsize\bfseries}}

% These font declarations are for the footer appearing on all pages.
\newfont{\footsc}{cmcsc10 at 8truept}
\newfont{\footbf}{cmbx10 at 8truept}
\newfont{\footrm}{cmr10 at 10truept}
\newfont{\foottt}{cmtt10 at 10truept}

  % Authors in header
  % ----------------------------
  % Comment (*)
  % The following solution would ideally have
  % \NewCommandCopy{\authblkauthor}{\author}
  % 		instead of
  % \let\authblkauthor\author
  % but this requires everyone to have the newest LaTeX.
  % Likewise, we load xparse so that we can use \ReNewCommand. This
  % is also in the newest LaTeX kernel.
  % ----------------------------

 \let\authblkauthor\author

\ExplSyntaxOn

\seq_new:N \g_ct_authors_seq
\RenewDocumentCommand{\author}{om}
 {
  \seq_gput_right:Nn \g_ct_authors_seq { #2 }
  \IfNoValueTF { #1 } { \authblkauthor{#2} } { \authblkauthor[#1]{#2} }
 }
 % The following command returns the m-th author
\NewDocumentCommand{\ABgetauthor}{m}
 {
  \seq_item:Nn \g_ct_authors_seq { #1 }
 }

\ExplSyntaxOff


\newcommand*{\authors}{%
  \begingroup
    \let\footnote\@gobble% ignore \footnote
    \let\thanks\@gobble% ignore \thanks
    \let\textsuperscript\@gobble% ignore protected \textsuperscript
    \expandafter\let\csname textsuperscript \endcsname\@gobble
    \let\Authfont\relax% do not use a special font
    \def\Authand{, }% separate list of authors by ,
    \ifnum\value{authors}<3 % one ore two authors
      \AB@authlist% show them all
    \else% 3 or more authors
  	\ABgetauthor{1}\,et~al.
    \fi
  \endgroup
}


% headers and footers
\renewcommand{\ps@plain}{%
\ps@headings
\renewcommand{\@evenhead}{\hfil \smAuthfont \authors}
\renewcommand{\@oddhead}{\footsc combinatorial theory {\footbf\volno} (\volyear), \#\papno \hfil \ifnum\value{page}>1{\thepage}\else
 \href{https://www.combinatorial-theory.org}{\foottt combinatorial-theory.org}\fi}}
 
 
\pagestyle{plain}

\g@addto@macro\bfseries{\boldmath}

%%%  Squashing the bibliography together a bit
  \newlength{\BiblioSpacing}
  \setlength{\BiblioSpacing}{0.4ex plus 0.1ex minus 0.1ex}
  \newcommand{\SquashBibFurther}{%
     \setlength{\BiblioSpacing}{0.2ex plus 0.1ex}}

  \let\oldthebibliography\thebibliography
  \let\endoldthebibliography\endthebibliography
  \renewenvironment{thebibliography}[1]{%
    \begin{oldthebibliography}{#1}%
      \setlength{\parskip}{\BiblioSpacing}
      \setlength{\itemsep}{\BiblioSpacing}
  }%
  {%
    \end{oldthebibliography}%
  }

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

\theoremstyle{plain}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{fact}[theorem]{Fact}
\newtheorem{observation}[theorem]{Observation}
\newtheorem{claim}[theorem]{Claim}

\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{example}[theorem]{Example}
\newtheorem{conjecture}[theorem]{Conjecture}
\newtheorem{open}[theorem]{Open Problem}
\newtheorem{problem}[theorem]{Problem}
\newtheorem{question}[theorem]{Question}

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

% addresses and emails
\renewcommand\Affilfont{\fontsize{9}{10.8}\itshape}
 \newcommand\emailfont{\sffamily}
 \newcommand*{\email}[1]{\href{mailto:#1}{\emailfont#1} } 

% For linking to an arXiv article:
\newcommand{\arxiv}[1]{\href{https://arxiv.org/abs/#1}{\texttt{arXiv:#1}}}

% Typeset a doi. Some magic to make underscores work:
\def\doi{\begingroup\catcode`\_=12\relax\doi@arg}
\def\doi@arg#1{\href{https://doi.org/#1}{\texttt{https://doi.org/#1}}\endgroup}


