%% 24 November 2025  2:05pm
%%
%%  This is file `BICA.cls', [2025/6/26 BICA document class]
%%
%%  built from the standard `article' document class by
%%  BICA Copy Editor R.C. Bunge, 31 October 2024.
%%  Much of the initial work was completed by
%%  BICA Production Manager and Editor-in-Chief D.L. Kreher.
%%
%%  Structure of this file is borrowed extensively from
%%  ``The LaTeX Companion'' 2nd edition.
%%  All page number references are for TLC2e.
%%


%% ------------------------------------------------------------
%%  Identification
%% ------------------------------------------------------------
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{BICA}


%% ------------------------------------------------------------
%%  Initial Code
%% ------------------------------------------------------------
\newif\if@print

%%  Set flag for production
\RequirePackage{etoolbox}
\newtoggle{ProdFlag}
\togglefalse{ProdFlag}


%% ------------------------------------------------------------
%%  Declaration of Options
%% ------------------------------------------------------------
\DeclareOption{11pt}{\OptionNotUsed}
\DeclareOption{12pt}{\OptionNotUsed}
\DeclareOption{twocolumn}{\OptionNotUsed}
\DeclareOption{titlepage}{\OptionNotUsed}
\DeclareOption{fleqn}{\OptionNotUsed}
\DeclareOption{leqno}{\OptionNotUsed}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\DeclareOption{onlinecopy}{\@printfalse \PassOptionsToClass{oneside}{article}}
\DeclareOption{printcopy}{\@printtrue \PassOptionsToClass{twoside}{article}}
\DeclareOption{Prod}{\toggletrue{ProdFlag}}


%% ------------------------------------------------------------
%%  Execution of Options
%% ------------------------------------------------------------
\ExecuteOptions{printcopy}
\ProcessOptions \relax


%% ------------------------------------------------------------
%%  Package Loading
%% ------------------------------------------------------------
\LoadClass{article}
\RequirePackage[centering, text={4.5in,7.125in}, paperwidth=6in, paperheight=9in]{geometry}

%%  Use \noparfill command at end of paragraphs that cause overfill boxes
\newlength\BICAparfill
\setlength\BICAparfill{30pt}
\RequirePackage[parfill=\BICAparfill, skip=1\baselineskip plus 1ex minus 2pt]{parskip}
\newcommand\noparfill{\hspace*{-\BICAparfill}}

\RequirePackage{amsmath,amsthm,amssymb,thmtools,mathtools}
\RequirePackage[defaultlines=2,all]{nowidow}
\RequirePackage{embrac,xcolor,xurl}
\RequirePackage{float,enumitem}
\RequirePackage[hidelinks,hypertexnames=false]{hyperref}
\RequirePackage{colonequals}
\RequirePackage{xspace}
\RequirePackage[noabbrev,capitalise,nameinlink]{cleveref}
\newcommand{\BICAPROBLEM}{}

%% ------------------------------------------------------------
%%  Main Code
%% ------------------------------------------------------------
\RequirePackage{titling}
  \setlength{\droptitle}{-2\baselineskip} 
  \pretitle{\BICAPROBLEM\begin{flushleft}\LARGE\bfseries}
  \posttitle{\end{flushleft}\vskip2em}
  \preauthor{\begin{flushleft}\scshape}
  \postauthor{\vskip-2.5\baselineskip\end{flushleft}}

\iftoggle{ProdFlag}%
{%
 \pagestyle{empty}
 \g@addto@macro\maketitle{\thispagestyle{empty}}
%%
% force italics to be slanted
%
% To revert to the old  versions
%
% {\oldit .... } for {\it ... }
% \oldtext{ ...} for \textit{ ... }
% {\oldem ...} for {\em ... }
%
%%
 \let\oldit\it
 \let\oldem\em
 \DeclareEmphSequence{\slshape}
 \DeclareTextFontCommand{\oldtextit}{\itshape}
 \renewcommand{\textit}[1]{\textsl{#1}} % Redefine \textit to use \textsl
 \DeclareTextFontCommand{\textit}{\slshape}
 \renewcommand{\it}{\slshape}
}

%%  Suppress the date
\date{}
\renewcommand{\date}[1]{\relax}

%%
\newcommand{\email}[1]{{\rm\href{mailto:#1}{#1}}}
\newcommand{\emailx}[1]{\textnormal{#1}}

%% Some newcomands
% \newcommand*{\deceased}{\ensuremath{\square}}
% \newcommand*{\rip}[1]{#1$^\deceased$}
\newcommand*{\coloneq}{\colonequals}
\newcommand*{\BICA}{\textsl{BICA}\xspace}
\newcommand*\fixmultline{\vadjust{\penalty\predisplaypenalty\vskip-\jot\relax}}

%%  Keywords and classification commands
\RequirePackage[hang]{footmisc}
\setlength{\footnotemargin}{0em}
\setlength{\skip\footins}{2em}
%
\newcommand\keywords[1]{%
  \begin{NoHyper}%
  \let\svthefootnote\thefootnote%
  \let\thefootnote\relax\footnotetext{\raggedright\hspace*{-\footnotemargin}\textbf{Key words and phrases:} #1}%
  \let\thefootnote\svthefootnote%
  \end{NoHyper}%
}
%
\newcommand\classification[1]{%
  \begin{NoHyper}%
  \let\svthefootnote\thefootnote%
  \let\thefootnote\relax\footnotetext{\raggedright\hspace*{-\footnotemargin}\textbf{Mathematics Subject Classifications:} #1}%
  \let\thefootnote\svthefootnote%
  \end{NoHyper}%
}
%
\newcommand\corresponding[2]{%
  \begin{NoHyper}%
  \let\svthefootnote\thefootnote%
  \let\thefootnote\relax\footnotetext{\raggedright\hspace*{-\footnotemargin}\textbf{Corresponding author:} #1 \url{<#2>}}%
  \let\thefootnote\svthefootnote%
  \end{NoHyper}%
}

%%  Define abstract environment
\renewenvironment{abstract}
 {\par\vspace{-2.5\baselineskip}\textbf{\abstractname.}}
 {\par\medskip}

%%  Some small adjustments
\settowidth{\thanksmarkwidth}{*}
\setlength{\thanksmargin}{-\thanksmarkwidth}
\renewcommand\bfdefault{b}
\g@addto@macro\bfseries{\boldmath}
\protected\def\verythinspace{%
  \ifmmode
    \mskip0.5\thinmuskip
  \else
    \ifhmode
      \kern0.08334em
    \fi
  \fi
}

%%  Set how lists appear
\SetEnumitemKey{smallsep}{topsep=-0.5\parskip, itemsep=0pt, parsep=0.25\parskip}
\SetEnumitemKey{medsep}{topsep=-0.5\parskip, itemsep=0pt, parsep=0.5\parskip}
\SetEnumitemKey{bigsep}{topsep=3pt plus 1pt minus 0.5pt, itemsep=3pt plus 1pt minus 0.5pt, parsep=\parskip}
\setlist[enumerate,itemize]{medsep}
\setlist[description]{bigsep}

%%  To distinguish between Latin v and Greek nu
\DeclareSymbolFont{CMletters}{OML}{cmm}{m}{it}
\DeclareMathSymbol{v}{\mathord}{CMletters}{`v}

%%  Define \pmod*{}, a nicer \pmod{}.
\let\old@pmod\pmod
\renewcommand{\pmod}{\@ifstar\@pmods\old@pmod}
\def\@pmods#1{\mkern4mu({\operator@font mod}\mkern 6mu#1)}

%% BICA definitions
%%
\declaretheoremstyle[
  headfont=\normalfont\bfseries,
  notefont=\mdseries, notebraces={\textup{(}}{\textup{)}},
  bodyfont=\normalfont,
  postheadspace=0.4em,
qed=\qedsymbol
]{BICAdefinition}
%%
\theoremstyle{BICAdefinition}
 \newtheorem{construction}{Construction}[section]
 \newtheorem{definition}[construction]{Definition}
 \newtheorem{remark}[construction]{Remark}
 \newtheorem{remarks}[construction]{Remarks}
 \newtheorem{example}[construction]{Example}
 \newtheorem{exercise}[construction]{Exercise}
 \newtheorem{observation}[construction]{Observation}
 \newtheorem{problem}[construction]{Problem}
 \newtheorem{conjecture}[construction]{Conjecture}
%%
 \newtheorem*{construction*}{Construction}
 \newtheorem*{definition*}{Definition}
 \newtheorem*{remark*}{Remark}
 \newtheorem*{remarks*}{Remarks}
 \newtheorem*{example*}{Example}
 \newtheorem*{exercise*}{Exercise}
 \newtheorem*{observation*}{Observation}
 \newtheorem*{problem*}{Problem}
 \newtheorem{conjecture*}{Conjecture}
%%
%% BICA theorems
%%
\declaretheoremstyle[
  headfont=\normalfont\bfseries,
  notefont=\mdseries, notebraces={\textup{(}}{\textup{)}},
  bodyfont=\slshape,
  postheadspace=0.4em,
qed=\qedsymbol
]{BICAtheorem}
%%
\theoremstyle{BICAtheorem}
 \newtheorem{theorem}[construction]{Theorem}
 \newtheorem{fact}[construction]{Fact}
 \newtheorem{lemma}[construction]{Lemma}
 \newtheorem{claim}[construction]{Claim}
 \newtheorem{proposition}[construction]{Proposition}
 \newtheorem{corollary}[construction]{Corollary}
 \newtheorem{question}[construction]{Question}
%%
 \newtheorem*{fact*}{Fact}
 \newtheorem*{theorem*}{Theorem}
 \newtheorem*{lemma*}{Lemma}
 \newtheorem*{claim*}{Claim}
 \newtheorem*{proposition*}{Proposition}
 \newtheorem*{corollary*}{Corollary}
 \newtheorem*{question*}{Question}
%%
 \numberwithin{figure}{section}
 \numberwithin{table}{section}
%%
%%  Command to make aliases for theorem-like environments.
\newcommand{\envalias}[2]{\newenvironment{#1}{\begin{#2}}{\end{#2}}}
%%  Example
%%  \envalias{thm}{theorem}
%%  \begin{thm}
%%    E=mc^2
%%  \end{thm}

%%  Reduced inter-word spacing as a last resort
%%    (EDITOR USE ONLY!)
\newcommand*{\SetSpaces}[2]{%
  \begingroup
  \spaceskip=#1
  \xspaceskip=#1
  #2%
  \endgroup}

%%  Margin notes from Editor to Author
\newcommand*{\EditorNote}[1]{%
  \marginpar[
    \raggedleft\fcolorbox{red}{red!25}{\parbox[t]{15mm}{\tiny\raggedright #1}}\hspace*{-3mm}
  ]{
    \hspace*{-3mm}\fcolorbox{red}{red!25}{\parbox[t]{15mm}{\tiny\raggedright #1}}}%
  }
\newcommand*{\InlineEditorNote}[1]{\smash{\fcolorbox{red}{red!25}{#1}}}

%% Author contacts
  \newcommand*{\BICA@Name}{}%
  \newcommand*{\BICA@Affil}{}%
  \newcommand*{\BICA@email}{}%
%%
  \NewHook{BICAContacts}
  \newcommand{\ContactsHere}{\UseOneTimeHook{BICAContacts}}
  \AtEndDocument{\UseOneTimeHook{BICAContacts}}
  \newcommand*{\AuthorAddress}[3]%
  {\AddToHook{BICAContacts}{\par{\small
      \raggedright
      \textsc{#1}\\ %%%  #1 = Author's Name
      \textsc{#2}\\ %%%  #2 = Author's Affiliation
      \email{#3}\noparfill %%%  #3 = Author's Email Address
    \par
  }}}
  \newenvironment{Contacts}%
  {\AddToHook{BICAContacts}{\par\vfill}}
  {\AddToHook{BICAContacts}{\clearpage}}

%%  Preserving the past
 \newcommand*{\OldAuthorAddress}[3]%
 {\par{\small%\noindent
     \textsc{#1}\\ %%%  #1 = Author's Name
     \textsc{#2}\\ %%%  #2 = Author's Affiliation
     \email{#3} %%%  #3 = Author's Email Address
   \par
 }}
 \newenvironment{OldContacts}%
   {\par\vfill}
   {\clearpage}


%% ------------------------------------------------------------
%%  Bibliography Styling
%% ------------------------------------------------------------
\RequirePackage[abbrev]{amsrefs}
%%
\renewcommand{\biblistfont}{%
    \normalfont
    \normalsize
}

%%  Reduce space between bibitems
%
\newlength\biblistsep
\setlength\biblistsep{1ex plus 0.3ex minus 0.2ex}
%
\BeforeBeginEnvironment{thebibliography}{%
 \vspace*{0.8\baselineskip plus 0.4\baselineskip}
 \setlength{\parskip}{\biblistsep}
}
%
\BeforeBeginEnvironment{biblist}{%
 \vspace*{0.8\baselineskip plus 0.4\baselineskip}
 \setlength{\parskip}{\biblistsep}
}



%%  Set bibitem appearance (by type)

\BibSpec{article}{%
  +{}  {\PrintAuthors}		{author}
  +{,} { }				{title}
  +{,} { \textsl}			{journal}
  +{}  { \textbf}			{volume}
  +{}  {\parenthesize}	{number}
  +{}  { \PrintDatePV}	{date}
  +{,} { \eprintpages}		{pages}
  +{,} { \url}			{url}
  +{,} { }				{note}
  +{.} {}				{transition}
}

\BibSpec{book}{%
  +{}  {\PrintPrimary}	{transition}
  +{,} { \textsl}		{title}
  +{,} { \PrintEdition}	{edition}
  +{,} { \textsc}		{series}
  +{,} { }			{publisher}
  +{,} { \PrintDateB}	{date}
  +{,} { \url}		{url}
  +{,} { }			{note}
  +{.} {}			{transition}
}

\BibSpec{collection.article}{%
  +{}  {\PrintAuthors}		{author}
  +{,} { }				{title}
  +{,} { in \textsl}		{booktitle}
  +{,} { \PrintEditorsA}	{editor}
  +{,} { }				{publisher}
  +{,} { \PrintDatePV}		{date}
  +{,} { }				{pages}
  +{,} { \url}			{url}
  +{,} { }				{note}
  +{.} {}				{transition}
}

\BibSpec{thesis}{%
  +{}  {\PrintAuthors}		{author}
  +{,} { \textsl}			{title}
  +{,} { \PrintThesisType}	{type}
  +{,} { }				{organization}
  +{,} { \PrintDateB}		{date}
  +{,} { \url}			{url}
  +{,} { }				{note}
  +{.} {}				{transition}
  }

\BibSpec{report}{%
  +{}  {\PrintPrimary}	{transition}
  +{,} { }			{title}
  +{,} { \textsl}		{organization}
  +{,} { Tech. Rep.~}	{number}
  +{,} { \PrintDatePV}	{date}
  +{,} { \url}		{url}
  +{,} { }			{note}
  +{.} {}			{transition}
}

\BibSpec{miscellaneous}{%
  +{}  {\PrintPrimary}	{transition}
  +{,} { }			{title}
  +{,} { \PrintDatePV}	{date}
  +{,} { \url}		{url}
  +{,} { \textsl}			{note}
  +{.} {}			{transition}
}

\BibSpec{misc}{%
  +{}  {\PrintPrimary}	{transition}
  +{,} { }			{title}
  +{,} { \PrintDatePV}	{date}
  +{,} { \url}		{url}
  +{,} { \textsl}			{note}
  +{.} {}			{transition}
}

