%-------------------- File FANCYBOX.TEX ---------------------
% Fancy frames
%
% Usage:
% \fancyframebox {rule thickness} {separation from inner guy} {inner guy}
%
% \makeemptybox {width} {height} {depth}
 
\newbox\fancyboxA
\newbox\fancyboxB
\newdimen\fancyboxD
 
\def\makeemptybox#1#2#3{\setbox\fancyboxA=\hbox{}\wd\fancyboxA=#1\relax
    \ht\fancyboxA=#2\relax \dp\fancyboxA=#3\relax \box\fancyboxA }
 
\def\fancyframebox#1#2#3{%
    \leavevmode
    \setbox\fancyboxB=\hbox{#3}%
    \dimen\fancyboxD=#1\relax
    \advance\dimen\fancyboxD by #2\relax
    \advance\dimen\fancyboxD by \dp\fancyboxB
    \hbox{%
 \lower\dimen\fancyboxD\hbox{%
     \vbox{%
  \hrule height #1\relax
  \hbox{%
      \vrule width #1\relax
      \kern #2\relax
      \vbox{\vskip #2\relax\box\fancyboxB\vskip #2\relax}%
      \kern #2\relax
      \vrule width #1\relax}%
  \hrule height #1\relax}}}}
%-------------------- End of FANCYBOX.TEX -------------------
\endinput
%*********** Test file and documentation for above *****************************
%\input fancybox
% Usage:
% \fancyframebox {rule thickness} {separation from inner guy} {inner guy}
 
\setbox0=\hbox{\it the center}
\count11=1
\loop\ifnum\count11<11
    \setbox0=\hbox{\fancyframebox{.1pt}{5pt}{\unhbox0}}
    \advance\count11 by1
\repeat
 
\vbox{\centerline{\box0}\vss}
 
This paragraph is probably rather hard to read.  I have used \TeX's
rule-drawing and macro capability to set 10 boxes on top of the
text.  This was rather easy to do in \TeX.  I challenge anyone
to come up with as simple a method for {\it troff}.
 
\def\\{\char`\\}\def\{{\char`\{}\def\}{\char`\}}
The command I used was:
 
$$\hbox{\tt \\fancyframebox\{.1pt\}\{5pt\}\{{\it text to be boxed}\}}$$
 
{\tt \\fancyframebox} makes a framed {\tt \\hbox} containing its
third argument, surrounded by extra space (its second argument),
and rules on all four sides whose width is its first argument.
To get 10 boxes, you just re-frame 10 times.  I used a {\tt \\loop}
construct, but one could just write out 10 nested {\tt \\fancyframebox}
calls.
 
In order to center the fancy boxes, I put them into {\tt \\box0} and
used {\tt \\centerline\{\\box0\}} to write it out.  To make the
text come out on top, I put it in a {\tt \\vbox to 0pt} construct,
making \TeX\ try to squeeze everything vertically to zero.  A
{\tt \\vss} allowed the {\tt \\vbox} to shrink (without it \TeX
\ would still have done the job, but would have complained about
an ``overfull {\tt \\vbox}'').[Ed.-Example was changed...]
 
Thus, the final set of commands, including the \TeX\ loop instructions,
to typeset the boxes was
 
\bigskip
 
{\tt\parindent=2\parindent\obeylines
\\setbox0=\\hbox\{\\it the center\}
\\count11=1
\\loop\\ifnum\\count11<11
\quad\\setbox0=\\hbox\{\\fancyframebox\{.1pt\}\{5pt\}\{\\unhbox0\}\}
\quad\\advance\\count11 by1
\\repeat
 
\\vbox\{\\centerline\{\\box0\}\\vss\}
}
 
\bigskip
 
Simple---at least when you consider the task\dots.
 
\bye
