% tsayusen.sty by Shinsaku Fujita
% Copyright (C) S. Fujita (1998). All rights reserved. 
% 無保証
\typeout{tbousen.sty(v1.00) by S. Fujita 1998/08/26}
\typeout{藤田眞作著「LaTeX本づくりの八衢」第4章参照}
\typeout{藤田眞作著「続LaTeX2e階梯(縦組み編)」参照}
% 
% From warichu.sty by Shinsaku Fujita 
% Copyright (C) S. Fujita (1995). All rights reserved. 
% Version 1.00 1995/09/09
% ****************************************************
% * For separating an augument list to each argument *
% ****************************************************
% delimiter == as A==B== ... ==Z
%
\long\def\@fordbleq#1:=#2\do#3{%
%  \edef\@fortmp{#2} % 1996/04/07 by Shinsaku Fujita
  \expandafter\def\expandafter\@fortmp\expandafter{#2}%
  \ifx\@fortmp\@empty \else%
    \expandafter\@dbleql@@p#2==\@nil==\@nil\@@#1{#3}\fi}
\long\def\@dbleql@@p#1==#2==#3\@@#4#5{\def#4{#1}\ifx #4\@nnil \else%
       #5\def#4{#2}\ifx #4\@nnil \else#5\@idbleql@@p #3\@@#4{#5}\fi\fi}
\long\def\@idbleql@@p#1==#2\@@#3#4{\def#3{#1}\ifx #3\@nnil%
%       \let\@nextwhile=\@fornoop \else%
       \expandafter\@fornoop \else%
%      #4\relax\let\@nextwhile=\@idbleql@@p\fi\@nextwhile#2\@@#3{#4}}
      #4\relax\expandafter\@idbleql@@p\fi#2\@@#3{#4}}
%
%
% 本文字と傍線との間隔を可変にするために設定
%  標準値
%    \newdimen\bousensep \bousensep=0.5zw
%    \def\bousensepstretch{1.4}
%
\newdimen\bousensep \bousensep=0.5zw
\def\bousensepstretch{1.4}
%
% pLaTeX2e \kasen命令を借用
% 左右の傍線を引けるように変更
%
\def\@sayubosen#1#2{%
 \ifydir\underline{#1}%
 \else
  \if@rotsw\underline{#1}%
  \else
   \def\aaa{#2}\def\bbb{l}%
   \ifx\aaa\bbb\relax \let\lowerorraise=\lower
   \else \let\lowerorraise=\raise\fi
   \setbox\z@\hbox{#1}%
    \leavevmode\lowerorraise%
    \bousensepstretch\bousensep%標準0.5zw x 1.4 = 0.7zw
    \hbox to\z@{\vrule\@width\wd\z@ \@depth\z@ \@height.4\p@\hss}%
    \box\z@
  \fi
\fi}
%
% 傍線命令 1998/08/26 by Shinsaku Fujita
%
% \sayubosen[出力位置]{前部==中部== ... ==後部} 
%
\def\sayubosen{\@ifnextchar[%]
{\migihidarisen}{\migihidarisen[r]}}
%
\def\migihidarisen[#1]#2{%
\@tempcnta=0\relax
\@fordbleq\member:=#2\do{\global\advance\@tempcnta\@ne}%
\ifnum\@tempcnta=1\relax
\@sayubosen{#2}{#1}%
\else
 \@tempcntb=0
 \@fordbleq\member:=#2\do{%
 \advance\@tempcntb\@ne
 \ifnum\@tempcntb=1\relax
   \expandafter\@sayubosen{\member}{#1}\break%
  \else
   \ifnum\@tempcntb=\@tempcnta
    \expandafter\@sayubosen{\member}{#1}%
   \else
    \@sayubosen{\hbox to\expandafter\hsize{\member}}{#1}\break%
   \fi\fi}%
 \fi}%
\endinput
