% reajmac.sty --- 日本信頼性学会・論文スタイル出力のためのマクロ
%
% $Id: reajmac.sty,v 2.1 2008/11/26 09:28:28 tunenori Exp $
%
% 




%\makeatletter
% 
% page layout
%
\textwidth=173mm	%% 209mm(A4) - 17mm - 10mm -17mm
\textheight=245mm	%% 296mm(A4) - 21.2mm - 29.3mm
\columnsep=10mm		%% column separation
\oddsidemargin=-4mm	%% side-margin to be 17mm
\topmargin=-8mm		%% no top-margin
\headsep=0mm		%% no head-separation 
\parindent=1em		%% one kanji-character for paragraph indentation
\renewcommand{\@afterindentfalse}{}	%% indentation for first paragraph 

%
% latex.tex
%

\def\class#1{\gdef\@class{#1}}
\def\jtitle#1{\gdef\@jtitle{#1}}
\def\title#1{\gdef\@title{#1}}

\def\jauthor#1{\gdef\@jauthor{#1}}
\def\author#1{\gdef\@author{#1}}



%
% redefine of fnsymbol
%
%\def\@fnsymbol#1{\ifcase#1\or *\or \dagger\or \ddagger\or
%   \mathchar "278\or \mathchar "27B\or \|\or **\or \dagger\dagger
%   \or \ddagger\ddagger \else\@ctrerr\fi\relax}
\def\@fnsymbol#1{\ifcase#1\or *\or **\or *3\or
   *4\or *5\or *6\or *7\or *8
   \or *9 \else\@ctrerr\fi\relax}


%
% \doublebox
% The width of the inner frame is .75"\fboxrule", and the
% width of the outer frame is 1.5"\fboxrule". The distance between the two
% frames is 1.5"\fboxrule" plus .5pt.
%
\newbox\@tempfbox
\long\def\doublebox#1{%
  \begingroup
    \setbox\@tempfbox\hbox{{#1}}%
    \fboxrule=.75\fboxrule
    \setbox\@tempfbox\hbox{\fbox{\box\@tempfbox}}%
    \fboxrule=2\fboxrule
    \fboxsep=\fboxrule
    \advance\fboxsep .5pt
    \fbox{\box\@tempfbox}%
  \endgroup}



%
% TeX for Windows shows ``Refernces'' instead of 参考文献
%
\def\thebibliography#1{\section*{参考文献\markboth
 {参 考 文 献}{参 考 文 献}}\list
 {[\arabic{enumi}]}{\settowidth\labelwidth{[#1]}\leftmargin\labelwidth
 \advance\leftmargin\labelsep
 \usecounter{enumi}}
 \def\newblock{\hskip .11em plus .33em minus .07em}
 \sloppy
 \sfcode`\.=1000\relax}
\let\endthebibliography=\endlist
 

%
% 見出しのフォントサイズを小さくする
% sectionにsubsectionのフォントを、subsectionにsubsubsectionのフォントを使う
%
\def\@spart#1{{\parindent 0pt \raggedright 
 \huge \bf 
 #1\par} \nobreak \vskip 3ex \@afterheading } 
%\def\section{\@startsection {section}{1}{\z@}{3.5ex plus 1ex minus 
% .2ex}{2.3ex plus .2ex}{\Large\bf}}
\def\section{\@startsection{section}{2}{\z@}{3.25ex plus 1ex minus 
 .2ex}{1.5ex plus .2ex}{\large\bf}}
%\def\subsection{\@startsection{subsection}{2}{\z@}{3.25ex plus 1ex minus 
% .2ex}{1.5ex plus .2ex}{\large\bf}}
\def\subsection{\@startsection{subsection}{3}{\z@}{1.625ex plus 
.5ex minus .1ex}{.75ex plus .1ex}{\normalsize\bf}}
%\def\subsubsection{\@startsection{subsubsection}{3}{\z@}{3.25ex plus 
%1ex minus .2ex}{1.5ex plus .2ex}{\normalsize\bf}}
\def\subsubsection{\@startsection{subsubsection}{3}{\z@}{1.625ex plus 
.5ex minus .1ex}{.75ex plus .1ex}{\normalsize\bf}}
\def\paragraph{\@startsection
 {paragraph}{4}{\z@}{3.25ex plus 1ex minus .2ex}{-1em}{\normalsize\bf}}
\def\subparagraph{\@startsection
 {subparagraph}{4}{\parindent}{3.25ex plus 1ex minus 
 .2ex}{-1em}{\normalsize\bf}}


%
% 行間を広くする
\def\baselinestretch{1.06}

%
% タイトルページ回りを修正する
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 1[column output ]-in-2[column document].sty                       %
%                      by bear@hashi1.civil.tohoku.ac.jp (2/9/1993) %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% FUNCTIONS added in "twocolumn"-"article" documents :
%
%    (1) footnotes by \thanks' are set in one-column
%    (2) abstract and keywords are set below title in one-column
%    (3) align bottom line of columns at the last page and put
%        abstract below them in one-column
%    (4) footnote of the \textwidth can be put at the left-column
%        of arbitrary page
%
% without using "multicol.sty" (Current version of the "multicol.sty"
%                                 does not support one-column float).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% A SAMPLE document is given below.
%                      Cut out a portion after the line of \endinput.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% SELECTION of these functions: (current status = all active)
%
\newif\if@thanksinonecolumn \@thanksinonecolumntrue
% \@thanksinonecolumnfalse      % if you do NOT need the function No.1
%
\newif\if@abstractinonecolumn \@abstractinonecolumntrue
% \@abstractinonecolumnfalse    % if you do NOT need the function No.2
%
\newif\if@lastpagecolumnalign \@lastpagecolumnaligntrue
% \@lastpagecolumnalignfalse    % if you do NOT need the function No.3
%
\newif\if@widefootnote \@widefootnotetrue
% \@widefootnotefalse           % if you do NOT need the function No.4
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% in order to check opened file
\newif\if@fileforfootnote \@fileforfootnotefalse   % for function No.1
%
% defs, dimension and box used in functions No.1 and 4
\let\@origin@lfootnoterule\footnoterule % original def of \footnoterule
\let\@origin@lpar\par                   % original definition of \par
\newdimen\@fullwidthfootnote \newsavebox{\@fullwdp@gebox}
\newdimen\@fullwidthfootnotepage
%
% definition change of \par used in functions No.1 and 4
\def\@pardefch@nge{\@setpar{%
  \if@firstcolumn\@origin@lpar % original in the leftcolumn
  \else \rightfootnotepage\@origin@lpar\fi}}
%       ^^^^^ make a blank footnote and restore the original
%               definition in the rightcolumn of the math-foot page
%
% change definition of \footnoterule used in functions No.1 and 4
\def\footnoterule{\ifdim\c@page pt=\@fullwidthfootnotepage
  \if@firstcolumn\kern-3\p@ \hrule width \textwidth \kern 2.6\p@
   \else\null\fi            % ^^^^^ leftcolumn of the specified page
%                                           rightcolumn of that page
   \else\@origin@lfootnoterule\fi                        % otherwise
 }
%
% force a blank footnote at the right-column used in functions No.1 and 4
\def\rightfootnotepage{\@setpar{\@origin@lpar}% restore original
 \ifdim\@fullwidthfootnote>\z@
  \insert\footins{\footnotesize
  \interlinepenalty\interfootnotelinepenalty
  \splittopskip\footnotesep
  \splitmaxdepth \dp\strutbox \floatingpenalty \@MM
  \hsize\columnwidth \@parboxrestore
  \vspace*{\@fullwidthfootnote}}\fi}
%
% insert a box in the footnote used in functions No.1 and 4
\def\@makebigfootnote{\insert\footins{% \footnotesize
  \interlinepenalty\interfootnotelinepenalty
  \splittopskip\footnotesep
  \splitmaxdepth \dp\strutbox \floatingpenalty \@MM
  \hsize\textwidth \@parboxrestore
  \usebox{\@fullwdp@gebox}}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\if@thanksinonecolumn % ============ FUNCTION No.1 ============
%
% change definition of \thanks to make a box
%
\def\thanks#1{\if@fileforfootnote\else
 \global\newwrite\@titlefile \gdef\@titlename{\jobname.1@2 }%
%    temporary file "\jobname.1@2" is used to store all the \thanks'
 \immediate\openout\@titlefile\@titlename
 \global\@fileforfootnotetrue\fi
 \footnotemark{\let\protect\string\immediate\write\@titlefile{%
 \string\item\string[\string\footnotemark\string]\space #1}}}
%
% making a footnote of the box of items by \thanks above
% \@setthefirstpagefootnote is used in \def\maketitle below
%                                        ^^^^^^^^^^^^^^^^
\def\@setthefirstpagefootnote{\if@fileforfootnote
 \immediate\closeout\@titlefile
 \global\@fileforfootnotefalse
 \@pardefch@nge % change definition of \par
 \global\sbox{\@fullwdp@gebox}{% save them into a box
 \begin{minipage}{\textwidth}%
  \setcounter{footnote}{0} 
	\def\thefootnote{\fnsymbol{footnote}}%
      \def\@makefnmark{\hbox to 0.65em{$\m@th^{\@thefnmark}$\hss}}% REAJ
  %%% \def\@{\hbox to\z@{$\m@th^{\@thefnmark}$\hss}}%
  \begin{list}{}{\leftmargin=1.2em \rightmargin\leftmargin
  %%% \begin{list}{}{\leftmargin=0.05\textwidth \rightmargin\leftmargin
   \parsep=0pt \topsep=0pt \partopsep=0pt
   \itemindent=0pt \itemsep=0pt \labelwidth=2ex \footnotesize}%
    \input{\jobname.1@2}%
  \end{list}%
 \end{minipage}}\global\@fullwidthfootnotepage=\c@page pt%
 \global\@fullwidthfootnote\ht\@fullwdp@gebox % set dimension
 \global\advance\@fullwidthfootnote\dp\@fullwdp@gebox
 \@makebigfootnote\fi} % and output it into one-column footnote
%
% \maketitle modified in case function No.2 is inactive
%
\if@abstractinonecolumn\else % \maketitle copied from article.sty
 \def\maketitle{\par
  \begingroup
    \def\thefootnote{\fnsymbol{footnote}}% \c added for REAJ
     \def\@makefnmark{\hbox
      to 0.65em{$\m@th^{\@thefnmark}$\hss}}% REAJ
  %%% to\z@{$\m@th^{\@thefnmark}$\hss}}%
    \if@twocolumn
      \twocolumn[\@maketitle]%
      \else \newpage
      \global\@topnum\z@
      \@maketitle \fi\thispagestyle{plain}\@thanks
  \endgroup
%
  \@setthefirstpagefootnote % only for the footnote of the first page
%
  \setcounter{footnote}{0}%
  \let\maketitle\relax
  \let\@maketitle\relax
  \gdef\@thanks{}\gdef\@author{}\gdef\@title{}\let\thanks\relax
  \gdef\@jauthor{}\gdef\@jtitle{}\relax} %%% REAJ
\fi
%
\fi % ===========================================================
%
\if@abstractinonecolumn % ============ FUNCTION No.2 ============
%
%                \@setthefirstpagefootnote defined above is used
%
% define \abstract and \keywords
%
\def\abstract#1{\gdef\@abstract{#1}} % does NOT allow paragraphs
\def\jabstract#1{\gdef\@jabstract{#1}} 
\def\keywords#1{\gdef\@keywords{#1}}
\def\jkeywords#1{\gdef\@jkeywords{#1}}
%
% \def\institution#1{\gdef\@institution{#1}}    % if you need it
%  if \institution is defined,
%    uncomment corresponding lines of \maketitle and \@maketitle
%
% modify \maketitle
%
\def\maketitle{\par
 \begingroup
   \def\thefootnote{\fnsymbol{footnote}}%
   \def\@makefnmark{\hbox
       to 0.65em{$\m@th^{\@thefnmark}$\hss}}% REAJ
	%%% to\z@{$\m@th^{\@thefnmark}$\hss}}%
   \if@twocolumn
     \twocolumn[\@maketitle]%
     \else \newpage
     \global\@topnum\z@
     \@maketitle \fi\thispagestyle{plain}\@thanks
 \endgroup
%
% only when the function no.1 is active
%
 \if@thanksinonecolumn \@setthefirstpagefootnote \fi
%
 \setcounter{footnote}{0}%
 \let\maketitle\relax
 \let\@maketitle\relax
% added
 \gdef\@abstract{}\gdef\@keywords{} % \gdef\@institution{} % if defined
%
 \gdef\@thanks{}\gdef\@author{}\gdef\@title{}\let\thanks\relax
 \gdef\@jauthor{}\gdef\@jtitle{}\relax} %%% REAJ
%
% set layout of the actual \@maketitle suitable for one's need
%
\def\@maketitle{\newpage
\null \vskip 0.5em   
 {\doublebox{\@class}}	% 投稿区分を左上に印字するならここを生かす
 \null \vskip 1.5em   
%%% for Japanese title and author
 \begin{center}%
\vspace*{-2em}{\LARGE \@jtitle \par}%
  \vskip  .5em
  {\large
   \lineskip .5em
   \begin{tabular}[t]{c}\@jauthor
   \end{tabular}\par}%
%  \vskip 1.5em    %
%   \@institution  % if you need it
 \end{center}%
%%% for English title and author
\begin{center}%
  {\Large \@title \par}%
  \vskip  .5em
  {\large
   \lineskip .5em
   \begin{tabular}[t]{c}\@author
   \end{tabular}\par}%
%  \vskip 1.5em    %
%   \@institution  % if you need it
 \end{center}%
%%% for Japanese abstract
 \@ifundefined{@jabstract}{}{%
  \vskip 1.em %%% 1.5em
  \begin{list}{}{\setlength{\leftmargin}{0.05\textwidth}%
   \listparindent=10pt \topsep=0pt \partopsep=0pt \parsep=0pt \itemsep=0pt
  \setlength{\rightmargin}{\leftmargin}}%
    \item {\bf 要旨: \rm\@jabstract}%
    \@ifundefined{@jkeywords}{}{%
    \item {\bf キーワード: \rm\@keywords}}%
  \end{list}}%
 \par
%%% \vskip 2.5em
%%% for English abstract
 \@ifundefined{@abstract}{}{%
  \vskip 1.em
  \begin{list}{}{\setlength{\leftmargin}{0.05\textwidth}%
   \listparindent=10pt \topsep=0pt \partopsep=0pt \parsep=0pt \itemsep=0pt
  \setlength{\rightmargin}{\leftmargin}}%
    \item {\bf Abstract: \rm\@abstract}%
    \@ifundefined{@keywords}{}{%
    \item {\bf Keywords: \rm\@keywords}}%
  \end{list}}%
 \par
 \vskip 2.5em}
%
\fi % ===========================================================
%
\if@lastpagecolumnalign % ============ FUNCTION No.3 ============
%
\newdimen\lastp@geheight \lastp@geheight=10mm
\newsavebox{\lastp@gebox}
%
% define \endabstract
%
\long\def\endabstract#1{\gdef\@endabstract{#1}} % permit paragraphs
%
% to create enough space of footnote to align columns of the last page
%
\def\lastpagecontrol{\@ifnextchar [{\l@stpagecontrol}%
 {\l@stpagecontrol[\z@]}}
%
\def\l@stpagecontrol[#1]#2{\global\lastp@geheight=#2%
%
 \@ifundefined{maxsize}{}{\global\advance\maxsize-#2}% for supertab.sty
%
 \@ifundefined{@endabstract}{}{% save \endabstract in a box
 \global\sbox{\lastp@gebox}{%
  \begin{minipage}{\textwidth}\vspace*{#1}%
   \hrule width \textwidth \vspace{1ex}%
   \begin{list}{}{\setlength{\leftmargin}{0.15\textwidth}%
    \listparindent=10pt \parsep=0pt
    \topsep=0pt \partopsep=0pt
   \setlength{\rightmargin}{\leftmargin}\small}%
     \item \ignorespaces\hspace*{\listparindent}\ignorespaces
                 \@endabstract
   \end{list}%
   \vspace{1ex} \hrule width \textwidth
  \end{minipage}}}%
%
% insert footnote with abstract if enough room left
%                 without abstract otherwise
%
  \@tempdima\ht\lastp@gebox \advance\@tempdima\dp\lastp@gebox
 \ifdim\@tempdima>\lastp@geheight
  \@tempdima\lastp@geheight \global\lastp@geheight=0pt
 \else
  \global\advance\lastp@geheight -\@tempdima
  \@tempdima\lastp@geheight \global\lastp@geheight\textheight
 \fi
  \def\footnoterule{\null}% force it to \null at the last page
  \insert\footins{\footnotesize
  \interlinepenalty\interfootnotelinepenalty
  \splittopskip\footnotesep
  \splitmaxdepth \dp\strutbox \floatingpenalty \@MM
  \hsize\textwidth \@parboxrestore
   \ifdim\lastp@geheight=\z@\else\usebox{\lastp@gebox}\fi%
  \vspace*{\@tempdima}}}
%
% set the layout of the last line of the document
%
\def\lastpagesettings{\@ifnextchar [{\l@stpagesettings}%
 {\l@stpagesettings[\z@]}}
%
\def\l@stpagesettings[#1]{%
 \begin{flushright}%
  {\footnotesize(`{\tt\jobname.tex}'~~@~\today)}%
 \end{flushright}%
%
% put \endabstract in the next page when no room left for it
%
 \ifdim\lastp@geheight=\z@
  \onecolumn\null\vspace*{#1}\noindent\usebox{\lastp@gebox}%
 \fi}
%
\fi % ===========================================================
%
\if@widefootnote % ================ FUNCTION No.4 ===============
%
\def\mathfootnote#1{%
% left-column OK
\if@firstcolumn \@pardefch@nge % change \par and save argument in a box
 \sbox{\@fullwdp@gebox}{\begin{minipage}{\textwidth} #1 \end{minipage}}%
 \global\@fullwidthfootnotepage=\c@page pt%
 \global\@fullwidthfootnote\ht\@fullwdp@gebox % set its width
 \global\advance\@fullwidthfootnote\dp\@fullwdp@gebox
 \@makebigfootnote % and output it into one-column footnote
% right-column No good
\else
 #1\ignorespaces
 \@warning{No `Wide-Footnote' in the right-column }\ignorespaces
\fi}
%
\fi % ===========================================================










%\makeatother
