%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  $B!V(BTAINS$B%K%e!<%9!W%/%i%9%U%!%$%k(B for LaTeX2e
%					  Version 1.08
%
%               originally developed by Yuichi Ohkawa, 
%                                       Akinori Ito, 
%                                       Masatoshi Watanabe
%                  slightly modified by Takaaki Mizuki
%
%  (c) Cyberscience Center, Tohoku University
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\NeedsTeXFormat{pLaTeX2e}[2000/11/03]
\ProvidesClass{tainsnews}[2019/07/17 v1.08 TAINS News class]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% $B!|;HMQK!(B
%
% $BJ8=qA4BN$H$7$F$O<!$N$h$&$J9=B$$H$J$k!%(B
%
% \documentclass{tainsnews}
% \begin{document}
% \issueNo{$BHV9f(B}
% \issueDate{$BH/9TG/(B.$B7n(B.$BF|(B}
% \newstitle
%   $BE,Ev$J3($rF~$l$?$j$9$k(B
% \tableofcontents
% \newarticle
%   $B5-;v(B1
% \newarticle
%   $B5-;v(B2
%	:
%	:
% \end{document}
%
% $B3F5-;v$G$N%?%$%H%k!$Cx<TEy$O<!$N$h$&$K;XDj$9$k!%(B
%
% \title{$BI=Bj(B}
% \author{$BCx<T(B}
% \organization[$B"((B1]{$B=jB05!4X(B}
%                 ($B"((B1: $BK\J8%Z!<%8$N$_Cx<T$N1&B&$KA^F~$5$l$kJ8;z(B $BNc(B:${}^1$)
% \email{E-mail$B%"%I%l%9(B}  <-- $B$3$N9`L\$O>JN,2D(B
% \author{$BCx<T(B2}          <-- 2$B?ML\0J9_$NCx<T$O>JN,2D(B
% \organization{$B=jB05!4X(B2}<-- 2$B?ML\$N=jB0$r>JN,$9$k>l9g$G$b(B\organization{}$B$O(B
%                             $B;XDj$9$k$3$H(B
% \email{E-mail$B%"%I%l%9(B2} <-- $B$3$N9`L\$O>JN,2D(B
%	:
% \maketitle
%   $B5-;vK\BN(B
%
% $B!&5-;v<+BN$K%?%$%H%k$,$J$/(B($B2q9p$J$I(B)$B!$L\<!$KFH<+$N%?%$%H%k$r:\$;$?$$(B
%   $B>l9g$K$O!$(B
%     \hiddentitle{$BL\<!$K:\$;$k%?%$%H%k(B}
%   $B$r;H$&!%(B\title{},\maketitle $BEy$O;H$o$J$$!%(B
% $B!&5-;v$N%?%$%H%k$K!$L\<!$K$O:\$;$J$$I{Bj$r$D$1$?$$>l9g$K$O!$(B
%     \title{$B%?%$%H%k(B\subtitle{$BL\<!$K$O:\$;$J$$I{Bj(B}}
%   $B$r;H$&!%(B
% $B!&%4%7%C%/BN$K$O(B \gothic$B!$L@D+BN$K$O(B \mincho $B$r;H$&!%(B
% $B!&(B``StarTAINS'' $B$NJ8;z$K$O(B \StarTAINS$B!$(B
%   ``TAINS/G'' $B$NJ8;z$K$O(B \TAINSG$B!$(B``SuperTAINS'' $B$NJ8;z$K$O(B \SuperTAINS$B!$(B
%   ``TAINS88'' $B$NJ8;z$K$O(B \oldTAINS$B!$(B``TAINS95'' $B$NJ8;z$K$O(B \oldTAINSii$B!$(B
%   ``TAINS98'' $B$NJ8;z$K$O(B \oldTAINSiii$B!$(B``TAINS'' $B$NJ8;z$K$O(B \TAINS $B$r;H$&!%(B
% $B!&%?%$%H%kFb$K2~9T$rF~$l$?$$>l9g$O!$(B\newlineintitle $B$r;H$&!%(B
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\LoadClass{jarticle}
\RequirePackage{graphicx}

%%% Fonts
% ASCII$BMQ(B
\let\gothic\gtfamily\let\mincho\mcfamily
\DeclareRobustCommand\tnf{\romanfamily{\sfdefault}\romanseries{sbc}\selectfont}
\kanjiskip=0pt plus 5pt minus 0pt

%%% Dimension
\topmargin -.3in
\oddsidemargin -3mm
\evensidemargin -3mm
\textheight 238mm
\textwidth 165mm
\advance\textheight by \topskip
\advance\headheight by 10pt
\def\baselinestretch{1.15}
\settowidth{\parindent}{$B$"(B}
\footskip2mm
%%

%%% Title
\newif\iftn@intitle
\tn@intitlefalse
\newif\iftn@inheader
\tn@inheaderfalse

\def\tn@null{.}
\def\newlineintitle{\iftn@intitle\\ \hfill\else\relax\fi}
\def\newlineintitlex#1{\iftn@intitle\\ \hspace*{#1zw}\else\relax\fi}
\def\footnoteintitle#1{\iftn@intitle\expandafter\footnote{#1}\else\relax\fi}
\def\seriestitle#1{\iftn@intitle{\large\gothic#1\\}\else %koko
  \iftn@inheader\relax\else#1: \fi\fi}
\def\subtitle#1{\iftn@intitle\\ {\Large\gothic#1}\else\relax\fi}
\def\subsubtitle#1{\iftn@intitle\\ {\normalsize\gothic#1}\else\relax\fi}
\def\title#1{\gdef\tn@title{#1}}
\def\author#1{
\gdef\tn@author{#1}
  \ifx\tn@authors\tn@null
    \gdef\tn@authors{#1}
  \else\xdef\tn@authors{\tn@authors, #1}\fi
}
\def\@rganization[#1]#2{
 \ifx\tn@afauthor\tn@null
    \xdef\tn@afauthor{#2[\tn@author#1]}
  \else
    \xdef\tn@afauthor{\tn@afauthor,#2[\tn@author]}\fi
}
\def\@@rganization#1{
  \ifx\tn@afauthor\tn@null
    \xdef\tn@afauthor{#1[\tn@author]}
  \else
    \xdef\tn@afauthor{\tn@afauthor,#1[\tn@author]}\fi
}
\def\organization{\@ifnextchar[{\@rganization}{\@@rganization}}
\def\email#1{\xdef\tn@afauthor{\tn@afauthor[#1]}}
\def\tn@showaf#1[#2]{
\@ifnextchar[{\tn@showafe[#1][#2]}
{\gothic\romanfamily\sfdefault\selectfont #1 & \gothic\romanfamily%
\sfdefault\selectfont #2 \\
}
}
\def\tn@showafe[#1][#2][#3]{
\gothic\romanfamily\sfdefault\selectfont #1 & \gothic\romanfamily%
\sfdefault\selectfont #2 \\
\multicolumn{2}{r}{\tt #3} \\
}

\def\maketitle{
\begin{quote}\tn@intitletrue
 \LARGE\gothic\romanfamily\sfdefault\selectfont \tn@title
\end{quote}
\begin{flushright}
\begin{tabular}{rr}
\@for\tn@aa:=\tn@afauthor\do{
 \expandafter\tn@showaf\tn@aa
}
\end{tabular} %\\
\addcontentsline{toc}{article}{\tn@title\dotfill\tn@authors}
\end{flushright}
}
\def\hiddentitle#1{
\addcontentsline{toc}{article}{#1\dotfill}
}

%

%%% Initialization

\def\newarticle{
  \clearpage
  \def\tn@title{}
  \def\tn@author{}
  \def\tn@afauthor{.}
  \def\tn@authors{.}
  \setcounter{section}{0}
  \setcounter{figure}{0}
  \setcounter{table}{0}
  \setcounter{footnote}{0}
  \normalsize
}

%%% Misc.
\newcommand\StarTAINS{{\tnf \mbox{Star\hspace{-1pt}TAINS}}}
\newcommand\TAINSG{{\tnf \mbox{TAINS/G}}}
\newcommand\SuperTAINS{{\tnf \mbox{Super\hspace{-1pt}TAINS}}}
\newcommand\oldTAINS{{\tnf \mbox{TAINS88}}}
\newcommand\oldTAINSii{{\tnf \mbox{TAINS95}}}
\newcommand\oldTAINSiii{{\tnf \mbox{TAINS98}}}
\newcommand\TAINS{{\tnf \mbox{TAINS}}}
\newcommand{\issueNo}[1]{\gdef\theissuenumber{#1}}
\def\setissuedate#1.#2.#3,{\newcount\wareki
%\wareki#1 \advance\wareki-1988%
\wareki#1 \advance\wareki-2018%
\gdef\theissuetdate{\huge#1{\LARGE.}#2{\LARGE.}#3}%
%\gdef\theissuedate{#1$BG/!JJ?@.(B\number\wareki{}$BG/!K(B#2$B7n(B#3$BF|(B}}
\gdef\theissuedate{#1$BG/!JNaOB(B\number\wareki{}$BG/!K(B#2$B7n(B#3$BF|(B}}
\newcommand{\issueDate}[1]{\setissuedate#1,}
\newcommand{\makespace}[1]{\settowidth{\labelwidth}{#1}\makebox[\labelwidth]{}}
\newarticle
\def\theissuenumber{xx}
\issueDate{\the\year.x.x}

%%% Page style
\def\ps@tainsnews{
 \@twosidetrue
 \def\rightmark{\TAINS $B%K%e!<%9(B No.\theissuenumber\quad\theissuedate}
 \def\leftmark{\tn@inheadertrue\tn@title}
 \def\@oddfoot{}
 \def\@evenfoot{}
 \def\@evenhead{\small\rm\thepage\hfil\gothic\romanfamily\sfdefault\selectfont\leftmark \gdef\headrulewidth{0.25pt}}
\def\@oddhead{\hbox{}\gothic\romanfamily\sfdefault\selectfont   %% 02 Dec 04
 \rightmark \hfil\rm\thepage \gdef\headrulewidth{0.25pt}}
}
\pagestyle{tainsnews}

\newif\iftn@newstitlepage
\tn@newstitlepagefalse

\def\@specialheader{
\iftn@newstitlepage
  \global\tn@newstitlepagefalse
  {\small ISSN 1883-9045}
\else
  \phantom{\small I}
\fi
}

% \@outputpage$B$O(BpLaTeX 2000/11/03$BHG$r4p$K$7$F$$$^$9!#(B
\def\@outputpage{%
\begingroup % the \endgroup is put in by \aftergroup
  \iftdir
    \dimen\z@\textwidth \textwidth\textheight \textheight\dimen\z@
  \fi
  \let \protect \noexpand
  \@resetactivechars
  \@parboxrestore
  \shipout\vbox{\yoko
    \set@typeset@protect
    \aftergroup\endgroup
    \aftergroup\set@typeset@protect
     \if@specialpage
       \global\@specialpagefalse\@nameuse{ps@\@specialstyle}%
     \fi
     \if@twoside
       \ifodd\count\z@ \let\@thehead\@oddhead \let\@thefoot\@oddfoot
          \iftdir\let\@themargin\evensidemargin
          \else\let\@themargin\oddsidemargin\fi
       \else \let\@thehead\@evenhead
          \let\@thefoot\@evenfoot
           \iftdir\let\@themargin\oddsidemargin
           \else\let\@themargin\evensidemargin\fi
     \fi\fi
     \@@topmargin\topmargin
     \iftombow
       \@@paperwidth\paperwidth \advance\@@paperwidth 6mm\relax
       \@@paperheight\paperheight \advance\@@paperheight 16mm\relax
       \advance\@@topmargin 1in\relax \advance\@themargin 1in\relax
     \fi
     \reset@font
     \normalsize
     \normalsfcodes
     \let\label\@gobble
     \let\index\@gobble
     \let\glossary\@gobble
     \baselineskip\z@skip \lineskip\z@skip \lineskiplimit\z@
    \@begindvi
    \@outputtombow
    \vskip \@@topmargin
    \moveright\@themargin\vbox{%
      \setbox\@tempboxa \vbox to\headheight{%
	\hb@xt@\textwidth{\hfil\@specialheader}
        \vfil
        \color@hbox
          \normalcolor
          \hb@xt@\textwidth{\@thehead}%
        \color@endbox
	\ifx\headrulewidth\@undefined\relax\else%     %% 02 Dec 04
	  \hb@xt@\textwidth{\rule[0pt]{\textwidth}{\headrulewidth}}
	\fi                                           %% 02 Dec 04
      }%                        %% 22 Feb 87
      \dp\@tempboxa \z@
      \box\@tempboxa
      \vskip \headsep
      \box\@outputbox
      \baselineskip \footskip
      \color@hbox
        \normalcolor
        \hb@xt@\textwidth{\@thefoot}%
      \color@endbox
    }%
  }%
  \global \@colht \textheight
  \stepcounter{page}%
  \let\firstmark\botmark
}

%%% Table of contents, etc.
\def\l@article#1#2{#1\hbox to10mm{\hfill\large#2}\\}
\def\l@section#1#2{}
\def\l@subsection#1#2{}
\def\l@subsubsection#1#2{}

%
\def\tableofcontents{
\newdimen\contentswidth\contentswidth\textwidth%
\advance\contentswidth-30pt%
\newbox\contentsbox\setbox\contentsbox=\vbox{%
\hsize\contentswidth\vskip2zh\noindent\@starttoc{toc}}%
\vbox{\offinterlineskip\hbox to\textwidth{%
\leaders\hrule\hskip10mm\smash{\raisebox{-.5zh}{%
\LARGE\gothic $BL\(B\hskip.5zw $B<!(B}}\leaders\hrule\hfil}%
\hbox to\textwidth{\vrule\hfill\box\contentsbox\hfill\vrule}\hrule}
}


%%% Title of this newsletter
\long\def\newstitle{
\thispagestyle{empty}
%\enlargethispage{-10pt}
\noindent
\mbox{}\vskip-36pt
\noindent
\includegraphics[bb=0 0 483 113,width=\linewidth]{eps/tnews-logo.eps}\\%
\vbox{%
\hbox to \linewidth{\hfill\gothic $BElKLBg3X>pJs%7%J%8!<5!9=(B %
$B>pJs%7%J%8!<9-Js<<(B{\TAINS}$B%K%e!<%9JT=8%0%k!<%W(B}\medskip%  
\hbox to \linewidth{\hfill\gothic\romanfamily{phv}\selectfont\theissuetdate%
\hskip5mm{\LARGE No.}\Huge\selectfont\theissuenumber}%
}
\def\headrulewidth{0pt}
\tn@newstitlepagetrue
\bigskip
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  $B%k%SMQ%^%/%m!J(B1:2 $BHfN(%P!<%8%g%s!K(B
%
%  Modified '92/03/14. by yoshit-s[at]ascii.co.jp
%  $B$3$NItJ,$O(B ASCII EWB $B$r4p$K$7$F$$$^$9!#(B
\newcount\rby@cnt
\newdimen\rby@off
\newdimen\rby@size

\def\length#1{{\rby@cnt=0\getlength#1\end}}
\def\getlength#1{\ifx#1\end\let\next=\relax
  \else\global\advance\rby@cnt by1\let\next=\getlength\fi\next}

\def\ruby#1#2{%
\rby@size=\f@size pt\divide\rby@size by2%
\def\rubyfont{\fontsize{\rby@size}{\rby@size}\selectfont}%
\ifvmode\leavevmode\fi%
 {\setbox0\hbox{\kanjiskip=0pt\rubyfont#1}\dimen0\wd0%
  \setbox0\hbox{#2}%
  \rby@off=0truept%
%
  \ifdim\dimen0<\wd0%  shorter ruby
    \length{#1}%
    % \ifnum\rby@cnt=1\rby@cnt=2\else\advance\rby@cnt by2\fi%
        \multiply\rby@cnt by 2%
      \rby@off\wd0 \advance\rby@off by-\dimen0
      \divide\rby@off by\rby@cnt
      \dimen0\wd0
    \vbox to0pt{\vss\vbox to1zw{\hsize\dimen0
      \baselineskip0truept\lineskip0truept
      \lineskiplimit0truept\parfillskip0truept
      \vss
      \ifnum\rby@cnt=2\hbox to\dimen0{\kanjiskip=0pt\rubyfont\hss#1\hss}\else
        \hbox to\dimen0{\rubyfont\hskip\rby@off
          \kanjiskip0pt plus1fill minus1fil#1\inhibitglue\hskip\rby@off}%
      \fi
      \hbox{#2}}}%
%
  \else\length{#2}%    longer ruby
    % \ifnum\rby@cnt=1\rby@cnt=2\else\advance\rby@cnt by1\fi
        \multiply\rby@cnt by 2%
    \rby@off\dimen0 \advance\rby@off by-\wd0%
    \divide\rby@off by\rby@cnt%
    \vbox to0pt{\vss\vbox to1zw{\hsize\dimen0%
      \baselineskip0truept\lineskip0truept%
      \lineskiplimit0truept\parfillskip0truept%
      \vss%
      \hbox to\dimen0{\kanjiskip=0pt\rubyfont#1}%
      \ifnum\rby@cnt=2\hbox to\dimen0{\hss#2\hss}\else%
        \hbox to\dimen0{\hskip\rby@off\kanjiskip0pt plus1fill minus1fil#2%
           \inhibitglue\hskip\rby@off}\fi}}%
    \fi}}
