% Class file for report collection of Wakate seminar
%
% Written by 松元 久明 / Tokyo University of Science
% Date:   September 9, 2008
% Version: 1.0
%
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{wakate}%[ Class file for report collection of Wakate, Ver.1.0]
\newif\ifeqnwithinsection\eqnwithinsectiontrue
\DeclareOption{eqnwithoutsection}{\eqnwithinsectionfalse}
\def\theoremnumwith{.}
\DeclareOption{theoremwithoutdot}{\def\theoremnumwith{}}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{jarticle}}
\newif\if@english
\@englishfalse
\DeclareOption{english}{\@englishtrue}
\PassOptionsToPackage{leqno}{amsmath}
\ProcessOptions\relax
\if@english
\LoadClass[11pt, twoside, leqno]{article}
\else
\LoadClass[11pt, twoside, leqno]{jarticle}
\fi
%
%
\DeclareFontShape{JY1}{mc}{m}{it}{<->ssub*mc/m/n}{}
\DeclareFontShape{JT1}{mc}{m}{it}{<->ssub*mc/m/n}{}
%
%
% Page size
%
\setlength\paperheight{297mm}%
\setlength\paperwidth{210mm}%
\setlength{\topmargin}{0cm}%
\setlength{\oddsidemargin}{0cm}%
\setlength{\evensidemargin}{0cm}%
\setlength{\textwidth}{452.96789pt}%
\setlength{\textheight}{23cm}%
\setlength{\parindent}{0.5cm}%
\setlength{\footskip}{1cm}%
%
%
% Commands for title and etc.
\renewcommand{\title}[2][]{\gdef\@title{#2}%
  {\def\temp{#1}\ifx\temp\@empty\else\shorttitle{#1}\fi}}
\newcommand{\shortauthor}[1]{\gdef\@shortauthor{\uppercase{#1}}}
\newcommand{\shorttitle}[1]{\gdef\@shorttitle{\uppercase{#1}}}
%
\newcommand{\vol}[1]{\gdef\@vol{#1}}
\newcommand{\annum}[1]{\gdef\@annum{#1}}
\newcommand{\fpage}[1]{\gdef\@fpage{#1}}
\newcommand{\lpage}[1]{\gdef\@lpage{#1}}
\newcommand{\pages}[2]{\fpage{#1}\lpage{#2}}
%
\newcommand{\keywords}[1]{\gdef\@keywords{#1}}
%
\shortauthor{NAME}
\shorttitle{SHORTTITLE}
\annum{????}
\newcommand{\@fpage@default}{??}
\let\@fpage\@fpage@default
\let\@lpage\@fpage@default
%
\def\author@affiliation{\@empty}
\renewcommand{\author}[2][]{\g@addto@macro\author@affiliation{{\Large\author{#1}{#2}}\\}}
\newcommand{\affiliation}[2][]{\g@addto@macro\author@affiliation{（\affiliation{#1}{#2}）\\[8pt]}}
%
% title
%
\let\maketitle@orig\maketitle
\renewcommand{\maketitle}{%
  \ifx\@fpage\@fpage@default\else\setcounter{page}{\@fpage}\fi
  \maketitle@orig
  \thispagestyle{toppage}}
\renewcommand{\@maketitle}{%
  \newpage
  \null
  \vskip 5mm%
  \begin{center}%
  \let\footnote\thanks
  {\bfseries\LARGE\@title\par}%
  \vskip 13mm%
  {\bfseries\begin{tabular}[t]{c}%
\author@affiliation
  \end{tabular}\par}%
  \end{center}
  \par \vskip 14mm}
%
% address
%
\let\addresses\@empty
\newcommand{\address}[2][]{\g@addto@macro\addresses{\address{#1}{#2}}}
\newcommand{\email}[2][]{\g@addto@macro\addresses{\email{#1}{#2}}}
\newcommand{\urladdr}[2][]{\g@addto@macro\addresses{\urladdr{#1}{#2}}}
%
\def\makeaddress{\ifx\@empty\addresses \else
  \@makeaddress\let\addresses\@empty\fi}
\def\@makeaddress{\par
  \nobreak \begingroup
  \footnotesize\parindent0pt%
  \def\address##1##2{\begingroup\def\tempa{##1}%
    \par\addvspace\bigskipamount\indent
    \ifx\@empty\tempa\else(\ignorespaces##1\unskip) \fi%
    {\ignorespaces##2}\par\endgroup}%
  \def\email##1##2{\begingroup
    \def\tempa{##1}\def\tempb{##2}%
    \ifx\tempb\@empty\else\nobreak\indent{\itshape E-mail}%
      \ifx\tempa\@empty\else, \ignorespaces##1\unskip\fi\/:\space
      \ttfamily##2\par\fi\endgroup}%
  \def\urladdr##1##2{\begingroup
    \def\tempa{##1}\def\tempb{##2}%
    \ifx\tempb\@empty\else\nobreak\indent{\itshape URL}%
      \ifx\tempa\@empty\else, \ignorespaces##1\unskip\fi\/:\space
      \ttfamily##2\par\fi\endgroup}%
  \addresses
  \endgroup
}
%
\AtEndDocument{\makeaddress}
%
% abstract, classification and keyword
%
\def\abstractname{Abstract.}
\renewenvironment{abstract}{%
  \begin{center}%
  \begin{minipage}[t]{0.86\linewidth}\footnotesize
  \noindent{\bfseries \abstractname}\ %
 }{%
  \end{minipage}\end{center}%
}
%
% headings
%
\newcommand{\firstheadline}{\vbox to 0pt{\vss\hbox{%
  {\footnotesize\begin{tabular}{l}%
  第\@vol 回 発展方程式 若手セミナー 報告集\hfill \\
  (\@annum), pp.\@fpage--\@lpage
  \end{tabular}}}\vss}}
%
\newcommand{\ps@toppage}{%
  \renewcommand{\@oddhead}{\firstheadline\hfil}%
  \renewcommand{\@evenhead}{}%
  \renewcommand{\@oddfoot}{\hfil{\footnotesize\textrm{\thepage}}\hfil}%
  \renewcommand{\@evenfoot}{}}%
\newcommand{\ps@sutheadings}{%
  \renewcommand{\@oddhead}{{%
    \footnotesize\textrm{\thepage}\hfil\textrm{\@shorttitle}\hfil}}%
  \renewcommand{\@evenhead}{{%
    \footnotesize\hfil\textrm{\@shortauthor}\hfil\textrm{\thepage}}}%
  \renewcommand{\@oddfoot}{}%
  \renewcommand{\@evenfoot}{}}
%
\AtBeginDocument{\pagestyle{sutheadings}}
%
% section and counter
\renewcommand{\section}{%
  \@startsection{section}{1}{\z@}{-1truecm plus -1ex minus -.2ex}%
  {1.5ex plus .2ex}{\centering\Large\bfseries}}
\renewcommand{\subsection}{%
  \@startsection{subsection}{1}{\z@}{-1truecm plus -1ex minus -.2ex}%
  {1.5ex plus .2ex}{\large\bfseries}}
\newcommand{\thesectionB}{\S\thesection.\hspace{-3mm}}
\newcommand{\thesubsectionB}{\thesubsection.\hspace{-3mm}}
\def\thesubsubsectionB{\thesubsubsection.}
\let\theparagraphB\theparagraph
\let\thesubparagraphB\thesubparagraph
\let\@seccntformat@orig\@seccntformat
\renewcommand{\@seccntformat}[1]{\csname the#1B\endcsname\quad}
%
\ifeqnwithinsection
\@addtoreset{equation}{section}
\renewcommand{\theequation}{\thesection.\arabic{equation}}
\fi
%
% thebibliography
\let\thebibliography@orig\thebibliography
\renewcommand{\thebibliography}[1]{\thebibliography@orig{{\small #1}}\small}
%
% 
\def\@begintheorem#1#2{\trivlist 
   \item[\hskip \labelsep{\bfseries #1\ #2\theoremnumwith}]\itshape}
\def\@opargbegintheorem#1#2#3{\trivlist
      \item[\hskip \labelsep{\bfseries #1\ #2\ (#3)\theoremnumwith}]\itshape}
\def\theoremwithoutdot{\def\theoremnumwith{}}


