%% Save file as: SHADEBOX.TEX Source: FILESERV@SHSU.BITNET %% Author: Leo@vaxc.cc.monash.edu.au %% Original Source: Posted by Jim Hefferon to %% INFO-TeX on Thu, 16 Jan 1992 11:21 EST %---------------------------------------------------------------------------- \newbox\graybox \newdimen\xgrayspace \newdimen\ygrayspace %---------------------------------------------------------------------------- % % The following \TeX code was based on previous work by % % Je'ro^me Maillot, maillot@bora.inria.fr % %---------------------------------------------------------------------------- % % Use the following for one or more words within a line. % \def\textshade#1#2{% \xgrayspace=4pt% \ygrayspace=4pt% \def\grayshade{0.95}% \def\linewidth{1}% \def\theradius{5}% \setbox\graybox=\hbox{\surroundboxa{#2}}% \hbox{% \hbox to 0pt{% \special{"gsave newpath 0 0 moveto % 0 1 copy /xmin exch store % \number\dp\graybox \space -65536 div 1 copy /ymin exch store % \number\wd\graybox \space 65536 div 1 copy /xmax exch store % \number\ht\graybox \space 65536 div 1 copy /ymax exch store % \theradius\space /radius exch store \linewidth\space /linewidth exch store \grayshade\space /grayshade exch store #1 grestore}}% \box\graybox}}% % % Use the following for paragraphs. % \def\parashade#1#2{% \xgrayspace=10pt% \ygrayspace=10pt% \def\grayshade{0.95}% \def\linewidth{2}% \def\theradius{10}% \def\thevskip{15pt}% \setbox\graybox=\hbox{\surroundboxb{#2}}% \vskip\thevskip \hbox{% \hbox to 0pt{% \special{"gsave newpath 0 0 moveto % 0 1 copy /xmin exch store % \number\dp\graybox \space -65536 div 1 copy /ymin exch store % \number\wd\graybox \space 65536 div 1 copy /xmax exch store % \number\ht\graybox \space 65536 div 1 copy /ymax exch store % \theradius\space /radius exch store \linewidth\space /linewidth exch store \grayshade\space /grayshade exch store #1 grestore}}% \box\graybox}% \vskip\thevskip% }% %---------------------------------------------------------------------------- % % A pair of box macros. Each builds a slightly oversized box % containing the text. The text is centred both in the vertical % horizontal directions. % % Use the following for one or more words within a line. % \long\def\surroundboxa#1{\leavevmode\hbox{\vtop{% \vbox{\kern\ygrayspace% \hbox{\kern\xgrayspace#1% \kern\xgrayspace}}\kern\ygrayspace}}} % % Use the following for a paragraphs. % \long\def\surroundboxb#1{\leavevmode\hbox{\vtop{% \vbox{\kern\ygrayspace% \hbox{\kern\xgrayspace\vbox{\advance\hsize-2\xgrayspace#1}% \kern\xgrayspace}}\kern\ygrayspace}}} %---------------------------------------------------------------------------- % % Here are some simple PostScript routines. % % The TeX command \PScommands must be called before any of the % shading routines can be used. % \long\def\PScommands{\special{! TeXDict begin % /sharpbox{% newpath xmin ymin moveto xmin ymax lineto xmax ymax lineto xmax ymin lineto xmin ymin lineto closepath }bind def % /roundbox{% newpath xmin radius add ymin moveto xmax ymin xmax ymax radius arcto xmax ymax xmin ymax radius arcto xmin ymax xmin ymin radius arcto xmin ymin xmax ymin radius arcto 16 {pop} repeat closepath }bind def % /sharpcorners{% sharpbox gsave grayshade setgray fill grestore linewidth setlinewidth stroke }bind def % /plainbox{% sharpbox grayshade setgray fill }bind def % /roundcorners{% roundbox gsave grayshade setgray fill grestore linewidth setlinewidth stroke }bind def % end}% Closes dictionnary }% \PScommands This is a test of a\ \textshade{roundcorners}{shaded box} routine. % This is another test of a\ \textshade{sharpcorners}{shaded box} routine \parashade{roundcorners}{% This is one very long line which I expect will be broken over one or more lines. The idea is to have this paragraph enclosed in a shaded box. I'll just keep on typing until I can be sure that there are more than two lines in this paragraph. I expect that this should be well and truely sufficient to test this macro. } \parashade{sharpcorners}{% This is one very long line which I expect will be broken over one or more lines. The idea is to have this paragraph enclosed in a shaded box. I'll just keep on typing until I can be sure that there are more than two lines in this paragraph. I expect that this should be well and truely sufficient to test this macro. } The field equations of General Relativity are\ % % \textshade{roundcorners}{\hbox{$G_{\mu\nu} = kT_{\mu\nu}$}} They can also be written as \parashade{sharpcorners}{$$R_{\mu\nu}-{1\over2}g_{\mu\nu}R = kT_{\mu\nu}$$} \bye