%%
%%  File: fmp.cls
%%
%%  Author: Mariusz \.Zynel
%%
%%  Description: LaTeX document class to typeset book of abstracts for FMP
%%
%%  Create date: Apr 6, 2025
%%
%%  Last modified: Apr 13, 2025
%%
%%
%%  Copyright (c) 2025 Mariusz Zynel <mariusz@math.uwb.edu.pl>.
%%
%%  This  software  is  FREE.  You can use  and/or  redistribute  it for any
%%  purpose in either,  modified, or unmodified form, under the terms of the
%%  GNU General Public License as published by the Free Software Foundation.
%%
%%  The above copyright notice and this permission  notice shall be included
%%  in all copies or substantial portions of this software.
%%
%%  THIS  SOFTWARE IS PROVIDED AS IS AND COME WITH NO WARRANTY  OF ANY KIND,
%%  EITHER  EXPRESSED OR IMPLIED.  IN NO EVENT WILL THE COPYRIGHT  HOLDER BE
%%  LIABLE FOR ANY DAMAGES RESULTING FROM THE USE OF THIS SOFTWARE.
%%
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{fmp}[2025/04/13 v1.1 LaTeX document class (MZ)]

\newdimen\binding
\newcommand\@ptsize{}

\DeclareOption{a4paper}
   {\setlength\paperheight {297mm}%
    \setlength\paperwidth  {210mm}}
\DeclareOption{a5paper}
   {\setlength\paperheight {210mm}%
    \setlength\paperwidth  {148mm}}
\DeclareOption{b5paper}
   {\setlength\paperheight {250mm}%
    \setlength\paperwidth  {176mm}}
\DeclareOption{landscape}
   {\setlength\@tempdima   {\paperheight}%
    \setlength\paperheight {\paperwidth}%
    \setlength\paperwidth  {\@tempdima}}
\DeclareOption{10pt}{\renewcommand\@ptsize{0}}
\DeclareOption{11pt}{\renewcommand\@ptsize{1}}
\DeclareOption{12pt}{\renewcommand\@ptsize{2}}
\DeclareOption{oneside}{\@twosidefalse \@mparswitchfalse}
\DeclareOption{twoside}{\@twosidetrue  \@mparswitchtrue}
\DeclareOption{draft}{%
    \setlength\overfullrule {5pt}%
    \setlength\binding      {0pt}%
    \@twosidefalse \@mparswitchfalse}
\DeclareOption{final}{%
    \setlength\overfullrule {0pt}%
    \setlength\binding      {16pt}}
\DeclareOption{book}{%
    \def\bookofabstracts{\relax}
    \def\@predocument{\frontmatter\makecover\mainmatter}
    \def\@postdocument{\tableofcontents}}
\DeclareOption{nobook}{%
    \def\@predocument{\mainmatter}
    \let\@postdocument\relax}

\ExecuteOptions{b5paper,11pt,twoside,final,nobook}
\ProcessOptions
\input{bk1\@ptsize.clo}
\AtBeginDocument{\@predocument}
\AtEndDocument{\@postdocument}
\bibliographystyle{plain}
\usepackage[utf8]{inputenc}
\usepackage{polski}
\usepackage{amssymb,amsmath,amsthm,amsfonts,enumerate}

\def\@setcoverlayout{%
    \setlength\headheight{0\p@}
    \setlength\headsep   {0\p@}
    \setlength\footskip  {0\p@}
    \@setpagelayout}
\def\@setmainlayout{%
    \setlength\headheight{12\p@}
    \setlength\headsep   {20\p@}
    \setlength\footskip  {30\p@}
    \@setpagelayout}
\def\@setpagelayout{%
    \setlength\@tempdima{\paperwidth}
    \ifdim \paperwidth >209mm\relax
        \setlength\@tempdimb{443\p@}
    \else
        \setlength\@tempdimb{372\p@}
    \fi
    \ifdim\@tempdima>\@tempdimb\relax
        \setlength\textwidth{\@tempdimb}
    \else
        \setlength\textwidth{\@tempdima}
    \fi
    \@settopoint\textwidth

    \setlength\@tempdima{\paperheight}
    \ifdim \paperwidth >296mm\relax
        \addtolength\@tempdima{-50mm}
    \else
        \addtolength\@tempdima{-52mm}
    \fi
    \addtolength\@tempdima{-\headheight}
    \addtolength\@tempdima{-\headsep}
    \addtolength\@tempdima{-\footskip}
    \divide\@tempdima\baselineskip
    \@tempcnta=\@tempdima
    \setlength\textheight{\@tempcnta\baselineskip}
    \addtolength\textheight{\topskip}
    \@settopoint\textheight

    \setlength\@tempdima        {\paperwidth}
    \addtolength\@tempdima      {-\binding}
    \addtolength\@tempdima      {-\textwidth}
    \setlength\oddsidemargin    {.5\@tempdima}
    \addtolength\oddsidemargin  {\binding}
    \addtolength\oddsidemargin  {-1in}
    \@settopoint\oddsidemargin

    \setlength\marginparwidth   {.5\@tempdima}
    \addtolength\marginparwidth {-\marginparsep}
    \addtolength\marginparwidth {-0.4in}
    \ifdim \marginparwidth >2in
        \setlength\marginparwidth{2in}
    \fi
    \@settopoint\marginparwidth

    \setlength\evensidemargin  {\paperwidth}
    \addtolength\evensidemargin{-2in}
    \addtolength\evensidemargin{-\textwidth}
    \addtolength\evensidemargin{-\oddsidemargin}
    \@settopoint\evensidemargin

    \setlength\topmargin{\paperheight}
    \addtolength\topmargin{-\headheight}
    \addtolength\topmargin{-\headsep}
    \addtolength\topmargin{-\textheight}
    \addtolength\topmargin{-\footskip}
    \addtolength\topmargin{-.5\topmargin}
    \addtolength\topmargin{-1in}
    \@settopoint\topmargin
    \@colht\textheight
    \@colroom\textheight
    \vsize\textheight
    \hsize\textwidth
    \linewidth\textwidth}

\setlength\lineskip{1\p@}
\setlength\normallineskip{1\p@}
\renewcommand\baselinestretch{}
\setlength\parskip{0\p@ \@plus \p@}
\@lowpenalty   51
\@medpenalty  151
\@highpenalty 301

\setlength\leftmargini  {2.5em}
\leftmargin  \leftmargini
\setlength\leftmarginii  {2.2em}
\setlength\leftmarginiii {1.87em}
\setlength\leftmarginiv  {1.7em}
\setlength\leftmarginv  {1em}
\setlength\leftmarginvi {1em}
\setlength  \labelsep  {.5em}
\setlength  \labelwidth{\leftmargini}
\addtolength\labelwidth{-\labelsep}
\@beginparpenalty -\@lowpenalty
\@endparpenalty   -\@lowpenalty
\@itempenalty     -\@lowpenalty
\renewcommand\theenumi{\@arabic\c@enumi}
\renewcommand\theenumii{\@alph\c@enumii}
\renewcommand\theenumiii{\@roman\c@enumiii}
\renewcommand\theenumiv{\@Alph\c@enumiv}
\newcommand\labelenumi{\theenumi.}
\newcommand\labelenumii{(\theenumii)}
\newcommand\labelenumiii{\theenumiii.}
\newcommand\labelenumiv{\theenumiv.}
\renewcommand\p@enumii{\theenumi}
\renewcommand\p@enumiii{\theenumi(\theenumii)}
\renewcommand\p@enumiv{\p@enumiii\theenumiii}
\newcommand\labelitemi{\textbullet}
\newcommand\labelitemii{\normalfont\bfseries \textendash}
\newcommand\labelitemiii{\textasteriskcentered}
\newcommand\labelitemiv{\textperiodcentered}

\let\@@itemize\itemize
\renewcommand{\itemize}{\@@itemize\setlength\itemsep{0.66\itemsep}}
\let\@@enumerate\enumerate
\renewcommand{\enumerate}{\@@enumerate\setlength\itemsep{0.66\itemsep}}

\newcommand\frontmatter{%
    \@setcoverlayout
    \cleardoublepage
%%  \@mainmatterfalse
    \pagenumbering{roman}}
\newcommand\mainmatter{%
    \@setmainlayout
    \cleardoublepage
%%  \@mainmattertrue
    \pagenumbering{arabic}}
\newcommand\backmatter{%
    \cleardoublepage
    \@mainmatterfalse}


\def\openoddpage{\clearpage%
    \if@twoside
        \ifodd\c@page
        \else
            \thispagestyle{empty}
            \hbox{}\newpage
            \if@twocolumn
                \hbox{}\newpage
            \fi
        \fi
    \fi}
\let\cleardoublepage\openoddpage
\def\openevenpage{\clearpage%
    \if@twoside
        \ifodd\c@page
            \thispagestyle{empty}
            \hbox{}\newpage
            \if@twocolumn
                \hbox{}\newpage
            \fi
        \else
        \fi
    \fi}

\def\stroke#1#2{%
    \setbox\@tempboxa=\hbox{#2}%
    \rule[#1]{\wd\@tempboxa}{0.4pt}\llap{\usebox\@tempboxa}}
\def\@underrule#1{%
     \stroke{-1.3ex}{\hbox to\hsize{#1}}}

\def\ps@abstract{%
    \def\@head{\scshape 10. Forum Matematyków Polskich\hfill\scriptsize Białystok, 8-12/09/2025}
    \def\@oddhead{\@underrule{\@head}}
    \def\@oddfoot{\reset@font\hfil\thepage}
    \def\@evenhead{\@underrule{\@head}}
    \def\@evenfoot{\reset@font\thepage\hfill}
}

\newenvironment{cover}{%
    \cleardoublepage
    \thispagestyle{empty}%
    \setcounter{page}\@ne
}{%
    \if@twoside\else
        \setcounter{page}\@ne
     \fi
}

\newcommand\makecover{%
    \begin{cover}
        \hoffset-0.5\binding
        \frontcover\newpage
        \hoffset0\p@
%%    \coverinfo\newpage
%%    \frontcover
    \end{cover}}

\newcommand\HUGE{\@setfontsize\HUGE{36}{42}}
\newcommand\exhuge{\@setfontsize\exhuge{40}{46}}
\newcommand\exHuge{\@setfontsize\exHuge{44}{50}}
\newcommand\ExHuge{\@setfontsize\ExHuge{50}{56}}
\newcommand\EXHUGE{\@setfontsize\EXHUGE{96}{106}}

\newcommand\frontcover{%
    \thispagestyle{empty}
    {\EXHUGE 10.}\hskip10pt%
    \vbox{\huge\scshape%
        \hbox{Forum}%
        \hbox{Matematyków}%
        \hbox{Polskich}}
    \vfil\vfil\vfil\vfil\vfil\vfil
    \begin{center}
        {\Large\scshape Uniwersytet w Bia{\l}ymstoku\par Wydział Matematyki}\par
        \bigskip
        {\large\scshape 8-12 września 2025}
    \end{center}
    \vfil}

\newcommand{\section}{\@startsection{section}{1}{\z@}%
                                   {-3.5ex \@plus -1ex \@minus -.2ex}%
                                   {2.3ex \@plus.2ex}%
                                   {\normalfont\bfseries}}

\newcounter{abstract}
\renewcommand{\theabstract}{\@arabic\c@abstract}

\renewcommand{\title}[1]{%
    \medskip{%
        \parindent\z@
        \normalfont
        \interlinepenalty\@M
        \lineskip 0.5em%
        {\Large\bfseries #1}\par}%
    \bigskip%
    \def\@title{#1}
}
\renewcommand{\author}[3]{%
    \medskip{%
        \parindent\z@
        \normalfont
        \interlinepenalty\@M
        \lineskip 0.3em%
        {\large\bfseries #1}\par
        #2\par
        e-mail: {\ttfamily #3}\par}%
    \medskip%
    \ifx\@authors\@empty
        \def\@authors{#1}
    \else
        \g@addto@macro\@authors{, #1}
    \fi
}
\newenvironment{abstract}{%
    \bigskip\par\noindent\ignorespaces%
}{%
    \par\bigskip%
    \gdef\@abstract{\relax}
}
\newcommand{\keywords}[1]{
    \smallskip\par\noindent{\bfseries\keywordsname}: #1%
    \def\@keywords{#1}
}
\newcommand{\MSC}[1]{
    \smallskip\par\noindent{\bfseries\mscname}: #1%
    \def\@MSC{#1}
}

\def\@bibprefix{\number\value{abstract}-}

\def\bibitem{\@ifnextchar[\@@lbibitem\@@bibitem}
\def\@@lbibitem[#1]#2{\@bibitem{\@bibprefix#2}}
\def\@@bibitem#1{\@bibitem{\@bibprefix#1}}

\DeclareRobustCommand\cite{%
  \@ifnextchar [{\@tempswatrue\@@citex}{\@tempswafalse\@@citex[]}}
\def\@@citex[#1]#2{\@citex[#1]{\@bibprefix#2}}

\newenvironment{references}{%
    \section*{\bibname}%
    \list{\@biblabel{\@arabic\c@enumiv}}{%
        \settowidth\labelwidth{\@biblabel{9}}%
        \setlength\parskip{.1\baselineskip}
	\setlength\itemsep{0pt plus 0.2ex}
        \leftmargin\labelwidth
        \advance\leftmargin\labelsep
        \small
        \usecounter{enumiv}%
        \let\p@enumiv\@empty
        \renewcommand\theenumiv{\@arabic\c@enumiv}}%
    \sloppy
    \clubpenalty4000
    \@clubpenalty \clubpenalty
    \widowpenalty4000%
    \sfcode`\.\@m%
}{%
    \@endparpenalty\@M\endlist%
}

\newcommand{\@pnumwidth}{1.55em}
\newcommand{\@dotsep}{4.5}
\setcounter{tocdepth}{2}
\newcommand{\tableofcontents}{%
    \cleardoublepage
    \parindent\z@
    {\LARGE\bfseries\contentsname}\par
    \bigskip
    \@starttoc{toc}}
\newcommand*{\l@abstract}[2]{%
  \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}%
    \vskip 1.0em \@plus\p@
    \setlength\@tempdima{1.5em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode\bfseries
      \advance\leftskip\@tempdima
      \hskip -\leftskip
      #1\nobreak\mdseries
      \leaders\hbox{$\m@th
         \mkern \@dotsep mu\hbox{.}\mkern \@dotsep
         mu$}\hfill
      \nobreak\bfseries
      \hb@xt@\@pnumwidth{\hss #2}\par
      \penalty\@highpenalty
    \endgroup
  \fi}

\newcommand{\fmp@err}{\ClassError{FMP}}
\newcommand{\fmp@warn}{\ClassWarning{FMP}}

\newcommand{\initabstract}{%
    \pagestyle{abstract}
    \let\@title\@empty
    \let\@authors\@empty
    \let\@MSC\@empty
}

\newcommand{\finalizeabstract}{%
    \ifx\@title\@empty
        \fmp@err{Missing title}
    \fi
    \ifx\@authors\@empty
        \fmp@err{Missing author}
    \fi
    \ifdefined\@abstract\relax\else
        \fmp@err{Missing abstract environment}
    \fi
    \ifx\@MSC\@empty
        \fmp@err{Missing MSC}
    \fi
    \ifnum\value{page}>2
        \fmp@err{More than two pages}
    \fi
}

\newcommand{\openabstract}{%
    \pagestyle{abstract}
    \ifdim\pagegoal=\maxdimen\relax\else
        \bigskip
        \hrule
        \smallskip
    \fi
    \let\@title\@empty
    \let\@authors\@empty
    \refstepcounter{abstract}%
    \typeout{Abstract:\space\number\value{abstract}}%
}

\newcommand{\closeabstract}{%
    \addcontentsline{toc}{abstract}{\@title\protect\\
        \protect{\protect\mdseries\protect\scshape\@authors\protect}}%
}

\renewcommand\bibname{Literatura}
\newcommand\keywordsname{Słowa kluczowe}
\newcommand\mscname{MSC (2020)}

\endinput
%%
%% End of file `fmp.cls'.
