%% res/publ/reed/reed.def ---------------------------------------- 1999.2/24
%%
% 「統計数理研究所 研究教育活動報告」.登録申請・表紙作成用reed.texのmacro集


% 1. Abstracted out of comtex/defs.tex
\def\empty{}\def\blank{ }\def\Xend{\End}
\def\hstrut#1{\rule{#1}{0pt}}
\def\Vstrut#1{\rule{0pt}{#1}}\def\vstrut#1{\rule[#1]{0pt}{0pt}}

\font\headfontr=cmr8
\font\headfontm=min8
\def\headfont{\headfontr\headfontm}       % INSERTED ON May 15, 1992 
\font\headfontit=cmti8                    % INSERTED ON Mar  2, 1993 
\newdimen\headsignWd \newdimen\headsignHt 

\long\def\headsign#1{% ------------------------------------------ 1993.3/3
    % IN Letter.style, PUT JUST BENEATH \begin{letter}
    %           \vsapce*{-69.2mm}\headsign{...}\vskip...mm
    % THIS LEAVES UPPER-MARGIN OF 7.0mm IRRESPECTIVE OF \topmargin.
    % SEE /LETTRE/REMARKS/General.tex
    \headsignHt=31.5mm
    \advance\headsignHt\topmargin \advance\headsignHt\baselineskip 
    \headsignWd =178mm \advance\headsignWd-\oddsidemargin
    \hbox to0pt{\vbox to0pt{\vss
    \vbox to\headsignHt{\hsize=\headsignWd \baselineskip3.8mm\parskip=0pt%
          \hfill\headfont#1\par
          \hfill\headfont\today\vss}}\hss}%
    \vskip-1\baselineskip}

\long\def\headsignS#1#2{% ------------------------------------------ 1993.3/3
    % IN Letter.style, PUT JUST BENEATH \begin{letter}
    %           \vsapce*{-69.2mm}\headsignS{...}{...}\vskip...mm
    % THIS LEAVES UPPER-MARGIN OF 7.0mm IRRESPECTIVE OF \topmargin.
    % SEE /LETTRE/REMARKS/General.tex
    \headsignHt=31.5mm
    \advance\headsignHt\topmargin \advance\headsignHt\baselineskip 
    \headsignWd =178mm \advance\headsignWd-\oddsidemargin
    \hbox to0pt{\vbox to0pt{\vss
    \vbox to\headsignHt{\hsize=\headsignWd \baselineskip3.8mm\parskip=0pt%
          \hfill\headfont#1\par
          \hfill\headfont#2\vss}}\hss}%
    \vskip-1\baselineskip}

\def\doubletoks#1=#2+#3{%
    % newtoks #1 = syntehesis of newtoks #2 and #3 
    \edef\wddbltks{\the#2\the#3}\global#1=\expandafter{\wddbltks}}

\long\def\remark#1#2{%  New version made on 1994.10/25
     \setbox0 = \hbox{$\left(\mkern3mu % 1 mu = 1/18 em
                      \vcenter{\hsize=#1 \footnotesize \baselineskip=4.5mm
                      \parindent=5mm #2}\mkern5mu\right)$}%
     \leavevmode\hbox{$\vcenter{\kern2mm\copy0\kern2mm}$}}

\def\cdotfill{% --- COPIED FROM /MAP/Mapdefs.tex -----
    \cleaders\hbox{$\mathsurround=0pt\mkern1.5mu\cdot\mkern1.5mu$}\hfill}


% 2. Abstracted out of comtex/algebra.tex
\def\assignD#1=#2+#3{%
    #1=#2\relax\global\advance#1#3\relax
    \ignorespaces}
\def\assignT#1=#2+#3+#4{%
    #1=#2\relax\advance#1#3\relax\global\advance#1#4\relax
    \ignorespaces}

% 3. Abstracted out of comtex/text.tex
\newdimen\VTextBaselineskip
\def\VTextStyle=#1(#2,#3){%
    \gdef\VTextfont{#2}\global\VTextBaselineskip=#3\ignorespaces}
\long\def\vText#1{%
    % Write vertically, ie., from up to down, a text #1 of one-line.
    % The reference point (x,y) is the center of upper side of text.
    % Text is contained in a hbox of width = 0pt, height = natural height.
    % \hsize in \vbox is assigned to that of the entire document.
    \hbox to0pt{%
    \hss\vbox to0pt{\VTextfont \baselineskip=\VTextBaselineskip \parindent=0pt
              \rightskip=0pt plus1fill\leftskip=0pt plus1fill \parskip=0pt
              \expandafter\vtextA#1\End\par\vss}\hss}}
\long\def\vtextA#1{%
    \def\XEND{#1}\ifx\XEND\Xend \let\nextvwr=\relax
    \else{#1}\par\let\nextvwr=\vtextA\fi\nextvwr}

% 4. Abstracted from gobbles.tex
\newif\ifempty
\newtoks\gobbledtoken
\long\def\emptycheck#1{%
    % IF #1=empty, OR IF #1=blank, THEN \ifempty=true
    % For #1=empty or blank, the definition \long\def\dummy{#1} transfers
    % improper arguments to \spacetrick.
    \def\csdummy{#1}\ifx\csdummy\empty\emptytrue
    \else\ifx\csdummy\blank\emptytrue\else\emptyfalse\fi\fi\ignorespaces}
\long\def\gobblespace#1{%
    % IT GOBBLES ANY SPACE INCLUDED IN THE HEAD OF #1,
    % AND RETURNS THE REST AS "\def\gobbled", or "\gobbledtoken=".
    \emptycheck{#1}\ifempty\let\gobbled=\empty \gobbledtoken={}%
    \else\spacetrick#1>\fi\ignorespaces}
\long\def\spacetrick#1#2>{%
    % THE DOUBLE "#1#2" IS CRUCIAL TO REMOVE SPACES. THE MACRO
    %   \def\trick#1>{\def\gobbled{#1}}
    % DOES NOTHING MIRACLE.
    \def\gobbled{#1#2}\gobbledtoken={#1#2}}

\def\*{\let\sptoken= }\* %  Now \sptoken is a <space> token.
\def\GobbleSpaces#1{% 1995.5/23
    % Remove spaces at top and/or end of #1
    \gobbledtoken={}%
    \GobbleSpacesA#1\End\ignorespaces}
\def\GobbleSpacesA#1{%
    \def\XEND{#1}\ifx\XEND\Xend \let\next=\relax
    \else
    \ifx#1\sptoken \else
    \gobbledtoken=\expandafter{\the\gobbledtoken#1}\fi
    \let\next=\GobbleSpacesA\fi \next}

% 5. Abstracted from plandefs.tex and dimdefs.tex
\newcount\dummy \newcount\nommy \newcount\tommy \newcount\sommy
\newcount\PLdummy \newcount\PLnommy
\newcount\PLtommy \newcount\PLsommy
\newcount\wwxput  \newcount\wwyput  \newcount\PLwwww

\def\xput(#1+#2,#3+#4){%
   \assignD\wwxput=#1+{#2}\assignD\wwyput=#3+{#4}\put(\wwxput,\wwyput)}
\def\horline(#1,#2,#3){%
    % Draw a horizontal line from (#1,#2) to (#3,#2).
   {\assignD\PLwwww={#3}+{-#1}
    \ifnum\PLwwww>0 \put(#1,#2){\line( 1,0)\PLwwww}%
    \else           \put(#1,#2){\line(-1,0){-\PLwwww}}\fi}\ignorespaces}
\def\verline(#1,#2,#3){%
    % Draw a vertical line from (#1,#2) to (#1,#3).
   {\assignD\PLwwww={#3}+{-#2}
    \ifnum\PLwwww>0 \put(#1,#2){\line(0, 1)\PLwwww}%
    \else           \put(#1,#2){\line(0,-1){-\PLwwww}}\fi}\ignorespaces}

\def\Vdimen(#1,#2,#3,#4,#5,#6){%  
    % Simplified version of \vdimen in dimdefs.tex
    % PUT A LINE INDICATING THE VERTICAL DISTANCE FROM (#1,#2) TO (#3,#4),
    % AND WRITE A TEXTin the mid of the line.  It needs #2 < #4
    % #5 -- Specifies the position of the line.
    \thinlines
    \assignT\PLdummy=#1+#5+{20}% we suppose unitlength=0.1mm
    \horline(#1,#2,\PLdummy)\horline(#3,#4,\PLdummy) 
    \assignD\PLdummy=#1+{#5}
    \assignT\PLnommy=#4+{-#2}+{-40}% 40 = gap to insert text
    \divide\PLnommy by2\relax
    \xput(\PLdummy+0,#2+\PLnommy){\vector(0,-1)\PLnommy}%
    \xput(\PLdummy+0,#4+{-\PLnommy}){\vector(0, 1)\PLnommy}%
    \assignD\PLnommy=\PLnommy+{20}
    \xput(\PLdummy+0,#2+\PLnommy){%
          \vbox to0pt{\vss\hbox to0pt{\footnotesize\hss#6\hss}\vss}}}

% 5. Macros specific to reed.tex

\def\Number=#1>{\GobbleSpaces{#1}\edef\xNumber{\the\gobbledtoken}}
\def\Date=#1.#2/#3>{\def\year{#1}\def\month{#2}\def\day{#3}}
\long\def\Title=#1>{\gobblespace{#1}\edef\xTitle{\the\gobbledtoken}}
\long\def\SubTitle=#1>{\gobblespace{#1}\edef\xSubTitle{\the\gobbledtoken}}
\long\def\ETitle=#1>{\gobblespace{#1}\edef\xETitle{\the\gobbledtoken}}
\long\def\ESubTitle=#1>{\gobblespace{#1}\edef\xESubTitle{\the\gobbledtoken}}
%\long\def\PreTitle=#1>{\gobblespace{#1}\edef\xPreTitle{\the\gobbledtoken}}
%\long\def\EPreTitle=#1>{\gobblespace{#1}\edef\xEPreTitle{\the\gobbledtoken}}

\def\Applicant=#1>{\def\xApplicant{#1}}
\long\def\Author(s)#1=#2>{\def\xAuthor{#2}}
\def\Affil=#1>{\def\xAffil{#1}}
\def\Address=#1>{\def\xAddress{#1}}
\def\Phone=#1>{\def\xPhone{#1}}
\def\Email=#1>{\def\xEmail{#1}}

\def\symp{研究集会の記録}         % "symposia"と正しく入力されるとは限らない．
\def\thes{特定主題に関する論文集} %  初めの4文字を使う．
\def\lect{講義資料}               %  これら以外の綴りに対しては、\CatB=\relax
\def\tran{翻訳文}
\def\othe{その他}
\def\Category=#1>{\GobbleSpaces{#1}%
    \expandafter\CatA\the\gobbledtoken\End
    \def\xCategory{\csname\CatB\endcsname}}
\def\CatA#1#2#3#4#5\End{\def\CatB{#1#2#3#4}}

\newtoks\tTitl \tTitl={}% 扉表記用
\newtoks\tAuth \tAuth={}% 申請書記入用
\long\def\AuthA#1+#2+{%
    \def\XEND{#2}%
    \ifx\XEND\Xend
          \gobblespace{#1}%
          \doubletoks\tTitl=\tTitl+\gobbledtoken
          \doubletoks\tAuth=\tAuth+\gobbledtoken
          \let\nextA=\relaxA
    \else \AuthB#1+\let\nextA=\AuthA \fi \nextA#2+}
\def\AuthB#1+{%
    \gobblespace{#1\par}%
    \doubletoks\tTitl=\tTitl+\gobbledtoken
    \gobblespace{#1/\hskip3mm}%
    \doubletoks\tAuth=\tAuth+\gobbledtoken}
\def\relaxA\End+{\relax}

% 申請時と申請後（登録番号取得後）で処理を分ける
\long\def\Apply#1\ApplyEnd{#1}
\long\def\Skip#1\ApplyEnd{\relax}
\def\IfApply{%
    \expandafter\emptycheck\expandafter{\xNumber}%
    \ifempty \Apply \else \Skip \fi}

\def\LineText#1{%
    \setbox0=\hbox{#1}%
    \vbox{\hrule width\wd0 \kern1mm \copy0 \kern1mm \hrule width\wd0}}

