%%% ==================================================================== %%% @LaTeX-style-file{ %%% filename = "shading.sty", %%% version = "1.3", %%% date = "29 September 1992", %%% time = "08:23:05 MDT", %%% author = "Art Mulder", %%% address = "Department of Computing Science %%% 615 General Services Building %%% University of Alberta %%% Edmonton, Alberta %%% T6G 2H1, Canada.", %%% telephone = "n/a", %%% FAX = "(403) 492-1071", %%% checksum = "06606 232 1004 9082", %%% email = "art@cs.ualberta.ca", %%% codetable = "ISO/ASCII", %%% keywords = "LaTeX style option, shaded background", %%% supported = "yes", %%% docstring = "A LaTeX Style file for putting text on a %%% shaded background. Requires a PostScript %%% printer and dvi-file converter. %%% %%% NOTE: Art Mulder is not the author %%% of this file, just the most recent %%% modifier. %%% %%% The style file is based upon ideas by %%% Je'ro^me Maillot, maillot@bora.inria.fr %%% which where turned into TeX code by %%% Leo, LEO@vaxc.cc.monash.edu.au. %%% That TeX code was converted into a LaTeX %%% style file by M.A.R. ( mroth@afit.af.mil )", %%% } %%% ==================================================================== %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % 'Shading.sty' % % Art Mulder ( art@cs.ualberta.ca ) 28-Sept-1992 % - Changed name of "linewidth" variable to "outlineboxwidth". % That variable name conflicted with another variable of the same % name in "latex.tex" when doing miniparagraphs. % - Wrote accompanying document ``shading.tex'', brief instructions % in the use of this style file, together with several examples. % % M.A.R. ( mroth@afit.af.mil ) 22 Jan 92 % - Modified to work as a LaTeX style: % - added setting the grayscale as an optional argument. % - allowed multiple paragraphs in the \parashade command % % Leo ?? ( LEO@vaxc.cc.monash.edu.au ) % - Wrote the original TeX code, based upon some ideas % from Je'ro^me Maillot ( maillot@bora.inria.fr ). % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % 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 % (Actually you can, see the use of "\gdef" in the example) % --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\outlineboxwidth{.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 outlineboxwidth 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 %---------------------------------------------------------------------------- % % 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{% \xgrayspace=4pt% \ygrayspace=4pt% \def\grayshade{#1}% \def\outlineboxwidth{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 \outlineboxwidth\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=10pt% \ygrayspace=10pt% \def\grayshade{#1}% \def\outlineboxwidth{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 \outlineboxwidth\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 \endinput