\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{experimentTitle}

\usepackage{tex/coms}
\usepackage{multirow}
\usepackage{array}
\usepackage{etoolbox}
\usepackage{ifthen}

\setmainfont{TeX Gyre Pagella}

\makeatletter
\newcounter{researchercount}
\setcounter{researchercount}{1}
\newcommand{\addResearcher}[1]{\listadd{\researchers}{#1}}
\newcommand{\researchercs}[1]{
    \ifthenelse{\isodd{\theresearchercount}}
    {
        & {\underline{(\theresearchercount)\quad #1}}
    }
    {
        & {\underline{(\theresearchercount)\quad #1}} \@arraycr
    }
    \stepcounter{researchercount}
}

\newcounter{expdatecount}
\setcounter{expdatecount}{0}
\newcommand{\expdates}{}
\newcommand{\addExperimentDate}[1]{\listadd{\expdates}{#1}}
\newcommand{\expdatecs}[1]{\stepcounter{expdatecount} & {\underline{\theexpdatecount.\qquad #1}} \@arraycr}

\newcommand{\expgroup}[1]{\def\@expgroup{#1}}
\newcommand{\reportid}[1]{\def\@reportid{#1}}

\newcommand{\experimentTitle}{
    \begin{titlepage}
        \thispagestyle{empty}
        \sffamily
        \begin{flushright}
            {提出日\qquad\hspace{1.6em}{\@turninyear \@turninmonth \@turninday}}
        \end{flushright}

        \vspace{2em}

        \begin{center}
            {\Large \textrm{\@schoolyear}年度\quad {\@department} \textrm{\@grade}年}

            \vspace{2em}

            {\Huge {\@subject}レポート}
        \end{center}

        \begin{flushleft}
            \vspace{1em}

            {\large 課題記号\qquad {\@reportid}}

            \vspace{1em}

            {\large 実験テーマ名\qquad {\@title}}

            \vspace{1em}

            { 提出者：\quad \underline{実験班\quad \@expgroup}\quad \underline{名列番号\quad \@seatingnum}\quad \underline{氏名\quad \@author}}

            \vspace{1em}

            \hspace{-8.525pt}\begin{tabular}{ lp{8em}p{8em} }
                \ifthenelse{\isundefined{\researchers}}{
                    \multirow[t]{3}{8em}{共同実験者：} & {なし} & \\
                }{
                    \multirow[t]{3}{8em}{共同実験者：} \forlistloop{\researchercs}{\researchers}
                }
            \end{tabular}

            \vspace{5em}

            \hspace{-6pt}\begin{tabular}{ lp{8em} }
                \multirow[t]{3}{8em}{実験実施日：} \forlistloop{\expdatecs}{\expdates}
            \end{tabular}
        \end{flushleft}
    \end{titlepage}
}
\makeatother
