% foldbox.sty --- Fold Down of the Coner of a Box Style File
%                                   by Masaki Sudoh <18 May 1995>
%
%   Usage : \foldbox[WIDTH]{WORD}            箱の描画
%                    WIDTH : 箱の幅          <省略時:ページの幅>
%                    WORD  : 文字列
%
%           \setfold{SIZE}                   角の折り返し指定
%                    SIZE  : 折り返しの大きさ
%
%           \foldboxset{xSIZE}{ySIZE}{WORD}  角の部分の指定
%                    xSIZE : WORD の横の大きさ
%                    ySIZE : WORD の縦の大きさ
%                    WORD  : 角の部分にくる文字列など
%
%          \foldboxsidemargin{SIZE}          左右の余白指定
%                    SIZE  : 余白の大きさ
%
%          \foldboxtopmargin{SIZE}           上下の余白指定
%                    SIZE  : 余白の大きさ
%
\typeout{Option foldbox Version 2.0, 18 May 1995, Masaki Sudoh}

\newbox\FOLDbox \newdimen\@FBht
\newdimen\@FBtop \@FBtop10\p@
\newdimen\@FBside \@FBside20\p@
\newdimen\@FBaD		\newdimen\@FBxsize
\newdimen\@FBbD		\newdimen\@FBstep\@FBstep1.5\p@
\newdimen\@FBcD		\newdimen\@FBtmpa
\newcount\@FBtmpb	\newcount\DIVx
\newcount\DIVy		\newcount\DIVr
\newcount\DIVs

\def\foldbox{\@ifnextchar[{\@foldbox}{\@foldbox[\textwidth]}}
\def\@foldbox[#1]#2{\noindent\leavevmode
 \@tempdima#1\advance\@tempdima by-\@FBxsize
 \@tempdimb#1\advance\@tempdimb by-2\@FBside
 \setbox\@tempboxa\hbox{\parbox{\@tempdimb}{#2}}%
 \@FBht\ht\@tempboxa\advance\@FBht\dp\@tempboxa\advance\@FBht 2\@FBtop
 \advance\@FBht 2\p@\advance\@FBht-\@FBtmpa
 {\baselineskip\z@
 \vbox{\hbox{\vrule width.4\p@ depth \z@\kern-.4\p@\hbox{\vbox{%
 \hbox{\vbox{\hrule height.4\p@ width \@tempdima}\usebox{\FOLDbox}}%
 \vskip\@FBtop\hbox{\kern\@FBside\box\@tempboxa}\vskip\@FBtop
 \hbox{\vbox{\hrule height.4\p@ width #1}}}%
 \vrule width.4\p@ depth \z@ height \@FBht\kern-.4\p@}}}}}

\def\foldboxsidemargin#1{\global\@FBside#1}
\def\foldboxtopmargin#1{\global\@FBtop#1}

\def\foldboxset#1#2#3{\global\@FBxsize#1\global\@FBtmpa#2
 \newdiv\@FBxsize{65535}\@FBa\newdiv\@FBtmpa{65535}\@FBb
 \global\setbox\FOLDbox\hbox{\begin{picture}(\@FBa,0)%
 \put(0,-\@FBb){#3}\end{picture}}}

\def\setfold#1{\global\@FBxsize#1\@FBaD#1\divide\@FBaD 7
 \multiply\@FBaD 4\relax\@FBtmpb\@FBaD\divide\@FBtmpb 65536
 \@FBbD\@FBstep\multiply\@FBbD\@FBtmpb\@FBcD#1\advance\@FBcD-\@FBaD
 \newdiv\@FBaD{65535}\@FBa\newdiv\@FBbD{65535}\@FBb\newdiv\@FBcD{65535}\@FBc
 \@FBaD#1\newdiv\@FBaD{65535}\@FBd
 \global\setbox\FOLDbox\hbox{\begin{picture}(\@FBd,0)%
 \put(0,0){\line(2,-1){\@FBd}}\put(0,0){\line(2,-3){\@FBa}}%
 \put(\@FBa,-\@FBb){\line(6,5){\@FBc}}\end{picture}}%
 \@FBtmpa\@FBxsize\divide\@FBtmpa 2}

\def\newdiv#1#2#3{\DIVx#1\divide\DIVx by#2\edef\DIVr{\the\DIVx.}
 \DIVy\DIVx\multiply\DIVy by#2\DIVx#1\advance\DIVx by-\DIVy
 \multiply\DIVx by10\edef\DIVs{\the\DIVx}%
 \divide\DIVx by#2\edef\DIVr{\DIVr\the\DIVx}%
 \DIVy\DIVx\multiply\DIVy by#2\DIVx\DIVs\advance\DIVx by-\DIVy
 \multiply\DIVx by10\edef\DIVs{\the\DIVx}%
 \divide\DIVx by#2\edef\DIVr{\DIVr\the\DIVx}%
 \DIVy\DIVx\multiply\DIVy by#2\DIVx\DIVs\advance\DIVx by-\DIVy
 \multiply\DIVx by10\edef\DIVs{\the\DIVx}%
 \divide\DIVx by#2\edef\DIVr{\DIVr\the\DIVx}%
 \DIVy\DIVx\multiply\DIVy by#2\DIVx\DIVs\advance\DIVx by-\DIVy
 \multiply\DIVx by10\edef\DIVs{\the\DIVx}%
 \divide\DIVx by#2\edef\DIVr{\DIVr\the\DIVx}%
 \xdef#3{\DIVr}}

\setfold{24\p@}

\endinput


