% MYSHADING.STY % a version of shading.sty (for LaTeX 2.09) % modified slightly by Jason Eisner, 10/4/1996, to allow user % to change \xgrayspace and \ygrayspace outside a call to % \textshade, and to introduce \xgrayparaspace, \ygrayparaspace. %% Save file as: SHADING.STY Source: FILESERV@SHSU.BITNET %From: IN%"LEO@vaxc.cc.monash.edu.au" 7-JAN-1992 01:27:46.65 %Modified to work as a LaTeX style: mroth@afit.af.mil 22 Jan 92 % -- added setting the grayscale as an optional argument. % -- allowed multiple paragraphs in the \parashade command % USAGE: \textshade[grayscale]{corneroption}{text to be shaded} % \parashade[grayscale]{corneroption}{paragraph(s) to be shaded} % where % grayscale is a number from 0 to 1, the higher the number the % lighter the shading, if missing it is set to 0.95 % corneroption is either sharpcorners or roundcorners % % LIMITATIONS: --can not break the shaded text across lines (\textshade) or % across pages (both) % --can not specify the line width of the surrounding box or % the amount of space between the surrounding % box and the text to be shaded as arguments % --modifying the xgrayspace and ygrayspace in the argument % will only affect the space added to the right and % bottom of the box, respectively % % EXAMPLES: % This is a test of a\ \textshade[1]{roundcorners}{shaded box} routine. % With a grayscale of 1, we essentially get no shading, and just a box. % % This is another test of a\ \textshade{sharpcorners}{shaded box} routine. % The default shading of .95 is used here. % % \parashade[.995]{roundcorners}{\gdef\linewidth{.5}% % 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. % } %This shows an example of changing the linewidth used, without % %changing the style % % 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}$$} % %---------------------------------------------------------------------------- \newbox\graybox \newdimen\xgrayspace \newdimen\ygrayspace \newdimen\xgrayparaspace \newdimen\ygrayparaspace \xgrayspace=4pt \ygrayspace=4pt \xgrayparaspace=10pt \ygrayparaspace=10pt %---------------------------------------------------------------------------- % % 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. % %MAR-added ability for optional argument for user to set grayscale \def\textshade{\@ifnextchar[{\@textshade}{\@textshade[0.95]}} \def\@textshade[#1]#2#3{% \def\grayshade{#1}% % \xgrayspace=4pt% (moved by JME) % \ygrayspace=4pt% (moved by JME) \def\linewidth{1}% \def\theradius{5}% \setbox\graybox=\hbox{\surroundboxa{#3}}% \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 #2 grestore}}% \box\graybox}}% % % Use the following for paragraphs. % %MAR-added ability for optional argument for user to set grayscale \def\parashade{\@ifnextchar[{\@parashade}{\@parashade[0.95]}} %MAR-added \long to allow multiple paragraphs in one shaded block \long\def\@parashade[#1]#2#3{% \xgrayspace=\xgrayparaspace% formerly =10pt (changed by JME) \ygrayspace=\ygrayparaspace% formerly =10pt (changed by JME) \def\grayshade{#1}% \def\linewidth{2}% \def\theradius{10}% \def\thevskip{15pt}% \setbox\graybox=\hbox{\surroundboxb{#3}}% \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 #2 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 ======================================================================