%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% style file for a guide for usage of
%                             style files and macro examples
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% PAGE FORMAT for A4-size
\setlength{\textheight}{24cm}
\setlength{\textwidth}{16cm}
\setlength{\headsep}{20pt}
\setlength{\topmargin}{-11mm}
\setlength{\evensidemargin}{1.5mm}
\setlength{\oddsidemargin}{1.5mm}
%
% special page style
\def\ps@totalpagestyle{%
\let\@mkboth=\@gobbletwo
\def\@oddhead{}\def\@evenhead{}
\def\@oddfoot{\hfill \thepage/\pageref{lastpagenumber} \hfill}
\def\@evenfoot{\hfill \thepage/\pageref{lastpagenumber} \hfill}}
%
% symbols
\def\bs{{\tt\symbol{'134}}}
\def\hathat{{\tt\symbol{'136}}}
\def\yen{{\leavevmode\tt\rlap=Y}}
\def\file#1{`{\tt #1}'}
%
% logos
% from : This is PiCTeX, Version 1.1   9/21/87
\def\PiC{P\kern-.12em\lower.5ex\hbox{I}\kern-.075emC}
\def\PiCTeX{\PiC\kern-.11em\TeX}
% from texsym.sty
\def\SLiTeX{{\rm S\kern-.06em{\sc l\kern-.035emi}\kern-.06em T\kern
   -.1667em\lower.7ex\hbox{E}\kern-.125emX}}
%
% from ttn2n1.sty
\def\PS{{\sc Post\-Script}}
\newcount\TestCount
\def\La{\TestCount=\the\fam \leavevmode L\raise.42ex
         \hbox{$\fam\TestCount\scriptstyle\kern-.3em \if@bold a\else A\fi$}}
\def\LaTeX{\La\kern-.15em\TeX}
\def\AmSTeX{{\the\textfont2 A}\kern-.1667em\lower.5ex\hbox
        {\the\textfont2 M}\kern-.125em{\the\textfont2 S}-\TeX}
\def\AmSLaTeX{{\the\textfont2 A}\kern-.1667em\lower.5ex\hbox
        {\the\textfont2 M}\kern-.125em{\the\textfont2 S}-\LaTeX}
\def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025emb}\kern-.08em\TeX}}
%
% strings
\def\JTeX{\leavevmode\lower.5ex\hbox{J}\kern-.18em\TeX}
\def\NTT{\leavevmode\hbox{NTT} \JTeX}
\def\ASCII{{\tt ASCII} Nihongo \TeX}
%
\def\refname{REFERENCES}
%
% using Mr.Watanabe's overwrite command
\def\MARU#1{\leavevmode\setbox0\hbox{$\bigcirc$}%
 \copy0\kern-\wd0 \hbox to\wd0{\hfil{\scriptsize#1}\hfil}}
%
% \Section from ttn2n1.sty
\def\Section#1{\refstepcounter{section}%
 \section*{\centering%
  \addcontentsline{toc}{section}{\protect\numberline{\thesection}#1}%
   \hrule\@height 1pt\nopagebreak[4] \vskip.5pc
  #1\nopagebreak[4] \vskip.5pc \hrule\@height 1pt\nopagebreak[4] \vskip1pc}}
%
% x-ref
\def\seesec#1{Section \ref{sec:#1} {\small (p. \pageref{sec:#1})} }
%
% time
\def\mod#1#2{
  \count255=#1 \divide\count255 by #2   % <register> = <counter> / <value>
  \multiply\count255 by #2              % <register> *= <value>
  \advance\count255 by -#1              % <register> -= <counter>
  #1=-\count255}                        % <counter> = -<register>
\newcount\hour
\hour=\time \divide\hour by 60          % <time> = <\time> / 60
\newcount\minute
\minute=\time \mod{\minute}{60}         % <minute> = <\time> % 60
%
% keyword
\def\keyword#1#2{\def\@thefnmark{}\@footnotetext{{\bf #1}: #2}}
%
% style file existence check
\newread\@istheresuchafile
\newif\if@yeswehave
\newif\ifdoublefiles \doublefilesfalse
\newif\iftriplefiles \triplefilesfalse
\def\ftpdirectory{{\tt akiu:ftp/pub/tex/latex-styles/}}
%
\def\additionalstyles#1{\gdef\n@meofstylefile{#1.sty}%
\openin\@istheresuchafile #1.sty\relax
\ifeof\@istheresuchafile\relax\global\@yeswehavefalse%
 \excludeversion{usage}\includeversion{nousage}%
\else \closein\@istheresuchafile\global\@yeswehavetrue%
 \excludeversion{nousage}\includeversion{usage}%
%
% temporary counter etc. No \global
 \def\alloc@##1##2##3##4##5{\advance\count1##1by\@ne
   \ch@ck##1##4##2% make sure there's still room
   \allocationnumber=\count1##1%
   ##3##5=\allocationnumber
   \wlog{\string##5=\string##2\the\allocationnumber}}
%
 \makeatletter\ignorespaces\@killglue\input #1.sty%
 \makeatother\@killglue\fi}
%
\def\endadditionalstyles{\global\@yeswehavefalse}
%
\def\stylefilename{`{\tt\n@meofstylefile}'\if@yeswehave\else%
 \footnote{`{\tt\n@meofstylefile}' is not installed here.}\fi}
%
\def\checkfile#1{\gdef\n@meofstylefile{#1}%
\openin\@istheresuchafile #1\relax
\ifeof\@istheresuchafile\relax\global\@yeswehavefalse%
 \else \closein\@istheresuchafile\global\@yeswehavetrue\fi}
%
\def\endcheckfile{\global\@yeswehavefalse}
%
\def\checkedfilename{`{\tt\n@meofstylefile}'\if@yeswehave%
 \ (Yes, we have it.)\ \else%
 \footnote{`{\tt\n@meofstylefile}' is not installed here.}\fi}
%
% font existence check
\def\foy{A quick brown fox jumps over the lazy dog}
\edef\fox{{\foy}.}
\def\foz{ABCDEFGHIJKLMNOPQRSTUVWXYZ}
\def\fontcheckexist#1#2#3{%
 \handsfontcheck{#1}%
 \typeout{\space\space ..... searching for a font `#1' .....}%
 {\tt #1} & \iffontexistence {\font\fonts@mple=#1\relax%
  \fonts@mple #2} \else \rm (Not Available) \fi
 & \rm #3 \\}
%
% hands font
\newif\iffontexistence \fontexistencefalse
\def\handsfontcheck#1{%
 \batchmode \font\fonts@mple=#1\relax \errorstopmode%
 \ifx\fonts@mple\nullfont \global\fontexistencefalse%
 \else \global\fontexistencetrue\fi\rm}
%
\def\handsfont#1{%
  \font\font@hands=hands scaled #1
  \font\font@bhands=handsbig
  \def\handsright{\ \raisebox{.5ex}[0pt]{\font@hands\symbol{"41}}\ }%
  \def\bighandsright{\ {\font@bhands\symbol{"41}}\ }%
  \def\handsleft{\ \raisebox{.5ex}[0pt]{\font@hands\symbol{"42}}\ }%
  \def\bighandsleft{\ {\font@bhands\symbol{"42}}\ }%
  \def\handsrightr{\ \raisebox{.5ex}[0pt]{\font@hands\symbol{"43}}\ }%
  \def\bighandsrightr{\ {\font@bhands\symbol{"43}}\ }%
  \def\handsleftr{\ \raisebox{.5ex}[0pt]{\font@hands\symbol{"44}}\ }%
  \def\bighandsleftr{\ {\font@bhands\symbol{"44}}\ }}
%
% toc control
\def\l@section#1#2{\addpenalty{\@secpenalty} \addvspace{1.0em plus 1pt}
\@tempdima 1.8em \begingroup
 \parindent \z@ \rightskip \@pnumwidth
 \parfillskip -\@pnumwidth
 \bf \leavevmode \advance\leftskip\@tempdima
 \hskip -\leftskip #1\nobreak\hfil
\nobreak\hbox to\@pnumwidth{\hss #2}\par
 \endgroup}
\def\l@subsection{\@dottedtocline{2}{1.8em}{2.6em}}
\def\l@subsubsection{\@dottedtocline{3}{4.1em}{3.5em}}
%
% english environment: small pitch
\def\english{\par\baselineskip=.7\normalbaselineskip
\vskip .4286\baselineskip\noindent\ignorespaces}
\def\endenglish{\par}
%
% NAMELIST : "namelist" environment          from "Raku Raku LaTeX"
\def\namelistlabel#1{\mbox{#1}\hfill}   % itemize
\newenvironment{namelist}[1]{%
\begin{list}{}
  {\let\makelabel\namelistlabel
   \settowidth{\labelwidth}{#1}
   \setlength{\leftmargin}{1.1\labelwidth}}
}{%
\end{list}}
%
% Q and A
\def\QandA{\setbox\@tempboxa\hbox{{\bf ~Q.99~:~}}%
  \labelwidth\wd\@tempboxa \leftmargini\labelwidth
  \advance\leftmargini\labelsep \def\labelenumi{\theenumi~:~} \enumerate}
\let\endQandA\endenumerate
\def\Qitem{\@ifnextchar [{\@item}{\@noitemargtrue \@item[\@qitemlabel]}}
 \def\@qitemlabel{{\bf Q.\@itemlabel}}
\def\Aitem{\@ifnextchar [{\@aitem}{\@noitemargtrue \@aitem[\@aitemlabel]}}
 \def\@aitemlabel{{\bf A.\@itemlabel}}
\def\@aitem[#1]{\addtocounter{\@listctr}{-1}\@item[#1]}
%
% announce env. from "ttn2n4.tex"
\newbox\REYbox
%
\def\announce{\@ifnextchar [{\@nnounce}{\@nnounce[2cm]}}
%
\def\@nnounce[#1]#2{%
  \gdef\REYrule{\hbox to #1{\leaders\hrule height 3pt\hfill}}%
  \setbox\REYbox=\hbox{\REYrule\quad{\Large\bf #2}\quad\raise3pt\REYrule}%
  \gdef\REYbigrule{\hbox to \wd\REYbox{\leaders\hrule height 3pt\hfill}}%
  \vspace{1em}%
  \centerline{\raise3pt\REYrule\quad{\Large\bf #2}\quad\raise3pt\REYrule}%
}
\def\endannounce{\par\centerline{\REYbigrule}%
}
%
% KINTOU-WARITSUKE from "LaTeX bibunsho sakusei nyumon"
\def\kintou#1#2{%
 \setbox\@tempboxa\hbox{#1}\makebox[\wd\@tempboxa]{%
 \@ifundefined{jintercharskip}{%
  \kanjiskip=0pt plus 1fill minus 1fill
  \xkanjiskip=\kanjiskip #2}{%
  \jintercharskip=0pt plus 1fill minus 1fill
  \jasciikanjiskip=\jintercharskip #2}}}
%
% Math Symbols by m.watanabe
\def\therefore{\setbox0 \hbox{$\cdot$}
 \raise-0.2em \copy0 \raise0.2em \copy0 \raise-0.2em \box0 ~}
\def\because{\setbox0\hbox{$\cdot$}
 \raise0.2em \copy0 \raise-0.2em \copy0 \raise0.2em \box0 ~}
%
% float control
\def\textfraction{.08}
\def\topfraction{.9}
\def\floatpagefraction{.99}
\def\dbltopfraction{.9}
\def\dblfloatpagefraction{.99}
%
% change caption style
\long\def\@makecaption#1#2{%
   \vskip 10\p@
   \setbox\@tempboxa\hbox{{\bf#1}\ \ #2}%
   \ifdim \wd\@tempboxa >\hsize
       {\bf#1}\ \ #2\par
     \else
       \hbox to\hsize{\hfil\box\@tempboxa\hfil}%
   \fi}
\def\figurename{Fig.}
\def\tablename{Table}
%
% subfloat captions
\@definecounter{subfloatnumber}
\def\@T@bLe{table}
\def\subfloatcap{-\alph{subfloatnumber}}
%
\def\subcaption{\@addtoreset{subfloatnumber}{\@captype}%
\ifx\@captype\@T@bLe\relax\else\addtocounter{\@captype}{1}\fi%
\def\the@subfloatnumber{\csname the\@captype\endcsname\subfloatcap}%
\stepcounter{subfloatnumber}%
\edef\@currentlabel{\csname the@subfloatnumber\endcsname}%
\@dblarg{\@subcaption\@captype}}
%
\long\def\@subcaption#1[#2]#3{\par\addcontentsline{\csname
  ext@#1\endcsname}{#1}{\protect\numberline{\csname
  the#1\endcsname\subfloatcap}{\ignorespaces #2}}\begingroup
    \@parboxrestore
    \normalsize
    \@makecaption{\csname fnum@#1\endcsname\subfloatcap}%
         {\ignorespaces #3}\par
    \endgroup%
     \ifx\@captype\@T@bLe\relax\else\addtocounter{\@captype}{-1}\fi}
%
% photo environment
\newcounter{photo}
\def\thephoto{\@arabic\c@photo}
\def\fps@photo{tp}
\def\ftype@photo{4}
\def\ext@photo{lop}
\def\fnum@photo{\photoname \thephoto}
\def\photo{\@float{photo}}
\let\endphoto\end@float
\@namedef{photo*}{\@dblfloat{photo}}
\@namedef{endphoto*}{\end@dblfloat}
\def\photoname{Photo}
%
% dialog environment
\newenvironment{dialog}{%
  \begin{list}{}{%
    \setlength{\labelwidth}{3cm}
    \setlength{\labelsep}{1cm}
    \setlength{\itemsep}{0pt}
    \setlength{\leftmargin}{3.5cm}
  }%
}{%
  \end{list}}
\def\character#1#2{\def#1{\item[{\bf #2:}]}}
\def\naration#1{\item \par
        \medskip\hspace{-\leftmargin}
        \parbox{0.98\textwidth}{\it #1}
        \smallskip}
%
% sample of maketitle
\newdimen\vspace@title  \newdimen\vspace@abstract
\vspace@title=0.15\textheight              % space for title
\vspace@abstract=0.15\textheight           % space for abstract
\def\etitle#1{\gdef\@etitle{#1}}           % english title
\def\affiliation#1{\gdef\@affiliation{#1}} % affiliation
\def\abstract#1{\gdef\@abstract{#1}}       % does NOT allow paragraphs
\def\keywords#1{\gdef\@keywords{#1}}       % keywords
%
\def\maketitle{\par
 \begingroup
   \def\thefootnote{\fnsymbol{footnote}}%
   \def\@makefnmark{\hbox
       to\z@{$\m@th^{\@thefnmark}$\hss}}%
   \if@twocolumn
     \twocolumn[\@maketitle]%
     \else \newpage
     \global\@topnum\z@
     \@maketitle \fi\thispagestyle{plain}\@thanks
 \endgroup
%  \setcounter{footnote}{0}%
 \let\maketitle\relax
 \let\@maketitle\relax
 \gdef\@abstract{}\gdef\@keywords{}%
 \let\abstract\relax\let\keywords\relax%
 \let\etitle\relax\gdef\@etitle{}%
 \let\affiliation\relax\gdef\@affiliation{}%
 \gdef\@thanks{}\gdef\@author{}\gdef\@title{}\let\thanks\relax}
\def\@maketitle{\newpage\null
\vbox to \vspace@title{\vskip 1.5em%
 \begin{center} {\large \@title} \end{center} \vfill
 \begin{center} {\normalsize \@etitle} \end{center} \vfill
 \begin{center} {\normalsize \lineskip .5em \@author} \\
    {\small \@affiliation} \end{center} \par} \vskip .5ex
\vbox to \vspace@abstract{\vfill%
 \@ifundefined{@abstract}{}{%
 \begin{list}{}{\setlength{\leftmargin}{0.15\textwidth}
  \topsep=0pt \partopsep=0pt \listparindent=1em \parsep=0pt
  \setlength{\rightmargin}{\leftmargin}
  \setlength{\baselineskip}{0.8\normalbaselineskip}}
 \item {\small \@abstract}
%
% minor-font definition for {'KEY WORDS:'}
 \handsfontcheck{cmbxti10}%
 \iffontexistence\font\fontkeywords=cmbxti10                  % bold italic
  \else\font\fontkeywords=cmbx10\fi%
 \def\keywordsname{\fontkeywords Key Words :}
%
 \@ifundefined{@keywords}{}{%
  \begin{list}{\keywordsname}{
   \topsep=-0.8\parskip \partopsep=0pt
   \settowidth{\labelwidth}{\keywordsname}
   \settowidth{\leftmargin}{1.1\keywordsname}
   \setlength{\baselineskip}{0.8\normalbaselineskip}}
  \item {\small\it\@keywords}
  \end{list}}
 \end{list}}
 \par \vfill}}
%
% indentation of footnote text
\long\def\@makefntext#1{\parindent 1em\noindent
  \hbox to 2em{\hss$^{\@thefnmark}$~}%
  \@tempdima\columnwidth\advance\@tempdima-2em\parbox[t]{\@tempdima}{#1}}
%
% CARRIAGE RETURN : cheating using "overwrite" by Mr. m.watanabe
\def\ovw#1{\leavevmode\setbox0\hbox{#1}\copy0\kern-\wd0}
\def\CR{\ovw{\raisebox{-2pt}[0pt][0pt]{\hbox{\xviipt$\Box$}}}%
 \kern 2pt\raisebox{1.5pt}[0pt][0pt]{\hbox{\vpt$\hookleftarrow$}}}
%
% index : \InDex*[a]{foo.sty}{2.14}
%                    :  in comment
%                [a] :  in separate files
%     sample is  [b] :  using "docstrip.tex"
%                [c] :  after \endinput
\def\InDex{\@ifstar{\global\def\@samplesymbol{\protect\P}\entrya}%
 {\global\def\@samplesymbol{\protect\null}\entrya}}
%
% Sakuin hojo
\def\entrya{\@ifnextchar[{\entryb}{\entryb[d]}}
\def\entryb[#1]#2#3{\@ifnextchar[{\entryc[#1]{#2}{#3}}%
 {\entryc[#1]{#2}{#3}[\empty]}}
\def\entryc[#1]#2#3[#4]{%
 \index{\ifx#4\empty\else#4\fi#2@\protect\makebox\string[6cm\string]%
 \string[l\string]{\protect\hspace*{1cm}{\tt #2}\ \@samplesymbol%
 \if#1a\ \protect\dag\else\if#1b\ \protect\ddag\else%
  \if#1c\ \protect\S\else\if#1?\ ?\fi\fi\fi\fi%
 \protect\dotfill {\tt (#3)}}}\ }
%
% modify "theindex" env.
\def\theindex{\@restonecoltrue\if@twocolumn\@restonecolfalse\fi
  \columnseprule \z@
  \columnsep 35pt\twocolumn[\section*{\indexname}%
  \begin{enumerate}%
  \item \P indicates existence of a sample in this article.
  \item \dag : Samples are in the original package.
  \item \ddag : Need {\tt docstrip.tex} to get manual and/or sample.
  \item \S : Samples are below the line of {\tt {\bs}endinput}.
  \item Usage is found in the comment lines of the file.
  \end{enumerate}\vskip 2em]%
   \@mkboth{\indexname}{\indexname}\thispagestyle{plain}\parindent\z@
   \parskip\z@ plus .3pt\relax\let\item\@idxitem}
%
\def\endtheindex{\label{lastpagenumber}% <===========================
  \if@restonecol\onecolumn\else\clearpage\fi}
%
%
\endinput
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
