%% Date: Mon, 30 Nov 1992 15:41:42 GMT %% This a minor update of the style file I posted last week. Changes are: %% 1. Bug in documentation (table of contents) fixed. %% 2. \shadowsize is now a length, rather than an ordinary command. %% 3. \fancypage has been split into \fancypage and \fancyput. %% Tim %% BEGIN fancybox.sty %% \def\fileversion{0.91} \def\filedate{92/11/25} %% %% COPYRIGHT 1992, by Timothy Van Zandt, tvz@Princeton.EDU %% %% DESCRIPTION: %% fancybox.sty is a LaTeX style option, consisting of: %% * Variants of \fbox: \shadowbox, \doublebox, \ovalbox, \Ovalbox. %% * Helpful tools for using box macros. %% * Extensive documentation about how to use box macros. %% * Flexible verbatim macros. %% %% INSTALLATION: %% Put this file where your TeX looks for inputs. %% %% DOCUMENTATION: %% See fancybox.doc, which might be appended to this file. %% %% COPYING: %% Copying of part or all of this file is allowed under the following %% conditions only: %% (1) You may freely distribute unchanged copies of the file. Please %% include the documentation when you do so. %% (2) You may modify a renamed copy of the file, but only for personal %% use or use within an organization. %% (3) You may copy fragments from the file, for personal use or for %% distribution, as long as credit is given where credit is due. %% %% You are NOT ALLOWED to take money for the distribution or use of %% this file or modified versions or fragments thereof, except for %% a nominal charge for copying etc. %% %% CODE: \expandafter\ifx\csname fb@framepage\endcsname\relax \else\expandafter\endinput\fi \typeout{Style option: `fancybox' v\fileversion \space <\filedate> (tvz)} \newbox\@tempfbox \@ifundefined{@tempdimc}{\newdimen\@tempdimc}{} \@ifundefined{@tempdimd}{\newdimen\@tempdimd}{} %% \shadowbox \newdimen\shadowsize \shadowsize 4pt \long\def\shadowbox#1{% \setbox\@tempfbox\hbox{\fbox{{#1}}}% \leavevmode\vbox{% \offinterlineskip \dimen@=\shadowsize \advance\dimen@ .5\fboxrule \hbox{\copy\@tempfbox\kern-.5\fboxrule\lower\shadowsize\hbox{% \vrule \@height\ht\@tempfbox \@depth\dp\@tempfbox \@width\dimen@}}% \vskip-\dimen@ \moveright\shadowsize\vbox{% \hrule \@width\wd\@tempfbox \@height\dimen@}}} % \fancyoval \def\cornersize{\@ifstar{\@cornersize}{\@@cornersize}} \def\@cornersize#1{% \@tempdima=#1\relax \edef\the@cornersize{\number\@tempdima sp}} \def\@@cornersize#1{% \edef\the@cornersize{#1\noexpand\@tempdimb}} \cornersize{.5} % This is just a simple change to \oval, making use of the \cornersize % parameter instead of makeing the corner arcs are large as possible. \def\fancyoval(#1,#2){\@ifnextchar[{\fancy@oval(#1,#2)}{\fancy@oval(#1,#2)[]}} \def\fancy@oval(#1,#2)[#3]{% \begingroup \fancy@@oval{#1\unitlength}{#2\unitlength}{#3}% \@put{-.5\wd\@tempboxa}{-.5\ht\@tempboxa}{\ht\@tempboxa=\z@\box\@tempboxa}% \endgroup} \def\fancy@@oval#1#2#3{% \boxmaxdepth \maxdimen \@ovttrue \@ovbtrue \@ovltrue \@ovrtrue \@tfor\@tempa :=#3\do{\csname @ov\@tempa false\endcsname}% \@ovxx#1\relax \advance\@ovxx-\@wholewidth \@ovyy#2\relax \advance\@ovyy-\@wholewidth \@tempdimb \ifdim \@ovyy >\@ovxx \@ovxx\else \@ovyy \fi \advance\@tempdimb-2\p@ \ifdim\@tempdimb>\the@cornersize\relax \@tempdimb=\the@cornersize \fi \@getcirc\@tempdimb \@ovro\ht\@tempboxa \@ovri\dp\@tempboxa \@ovdx\@ovxx \advance\@ovdx-\@tempdima \divide\@ovdx \tw@ \@ovdy\@ovyy \advance\@ovdy-\@tempdima \divide\@ovdy \tw@ \@circlefnt \setbox\@tempboxa\hbox{% \if@ovr \@ovvert32\kern -\@tempdima \fi \if@ovl \kern \@ovxx \@ovvert01\kern -\@tempdima \kern -\@ovxx \fi \if@ovt \@ovhorz \kern -\@ovxx \fi \if@ovb \raise \@ovyy \@ovhorz \fi}% \advance\@ovdx\@ovro \advance\@ovdy\@ovro \advance\@ovxx\@wholewidth \wd\@tempboxa=\@ovxx \dp\@tempboxa=\z@} % \ovalbox \def\ovalbox{\@ovalbox\thinlines} \def\Ovalbox{\@ovalbox\thicklines} \long\def\@ovalbox#1#2{% \begingroup #1\relax \setbox\@tempfbox\hbox{{#2}}% \@tempdimc\fboxsep \advance\@tempdimc\@wholewidth \@tempdima\ht\@tempfbox \advance\@tempdima\dp\@tempfbox \advance\@tempdima2\@tempdimc \@tempdimb\wd\@tempfbox \advance\@tempdimb2\@tempdimc \fancy@@oval\@tempdimb\@tempdima{}% \@tempdima\dp\@tempfbox \advance\@tempdima\@tempdimc \wd\@tempboxa=\z@ \leavevmode\hbox{% \lower\@tempdima\box\@tempboxa \kern\@tempdimc\box\@tempfbox\kern\@tempdimc}% \endgroup} % \doublebox \long\def\doublebox#1{% \begingroup \setbox\@tempfbox\hbox{{#1}}% \fboxrule=.75\fboxrule \setbox\@tempfbox\hbox{\fbox{\box\@tempfbox}}% \fboxrule=2\fboxrule \fboxsep=\fboxrule \advance\fboxsep .5pt \fbox{\box\@tempfbox}% \endgroup} % \beginsbox ... \endsbox \def\beginsbox#1{\setbox#1\hbox\bgroup\ignorespaces} \def\endsbox{% \@testtrue\ifhmode\ifinner\@testfalse\fi\fi \if@test\@latexerr{Misplaced \string\endsbox! Should be in LR mode}\@ehd\fi \egroup} % \fb@outputage % Here we insert various hooks for rotating or framing the page. % Otherwise, it is the usual \@outputpage \def\fb@outputpage{% \begingroup \catcode`\ =10 \let\-\@dischyph \let\'\@acci \let\`\@accii \let\=\@acciii \if@specialpage \global\@specialpagefalse\@nameuse{ps@\@specialstyle}% \fi \if@twoside \ifodd\count\z@ \let\@thehead\@oddhead \let\@thefoot\@oddfoot \let\@themargin\oddsidemargin \else \let\@thehead\@evenhead \let\@thefoot\@evenfoot \let\@themargin\evensidemargin \fi \fi \csname reset@font\endcsname \normalsize \baselineskip\z@ \lineskip\z@ \let\par\@@par \ifx\this@fancypage\@empty\else \this@fancypage \gdef\this@fancypage{}% \fi \ifx\the@fancypage\@empty\else \setbox\@outputbox\hbox{\the@fancypage{\box\@outputbox}}% \fi \setbox\@outputbox\vbox{% \@tempdima=\wd\@outputbox \setbox\@tempboxa\hbox to\@tempdima{% \let\label\@gobble \let\index\@gobble \let\glossary\@gobble \@thehead}% \ht\@tempboxa=\headheight \dp\@tempboxa\z@ \box\@tempboxa \vskip\headsep \box\@outputbox \baselineskip\footskip \hbox to\@tempdima{% \let\label\@gobble \let\index\@gobble \let\glossary\@gobble \@thefoot}} \ifx\the@@fancypage\@empty\else \setbox\@outputbox\hbox{\the@@fancypage{\box\@outputbox}}% \fi \setbox\@outputbox\vbox{% \ifnum\fancyput@flag>-1 \do@fancyput\fi \vskip \topmargin \moveright\@themargin\box\@outputbox}% \ifx\fb@rotatepage\@empty\else \setbox\@outputbox\hbox{\lower\ht\@outputbox\box\@outputbox}% \dp\@outputbox\z@ \wd\@outputbox\z@ \setbox\@outputbox\hbox{\fb@rotatepage{\box\@outputbox}}% \expandafter\fb@setoffsets\fb@theoffsets \fi \shipout\box\@outputbox \global\@colht\textheight \endgroup \stepcounter{page}% \let\firstmark\botmark} % \fancypage \def\the@fancypage{} \def\the@@fancypage{} \def\this@fancypage{} \def\fancypage#1#2{% \def\the@fancypage{#1}% \def\the@@fancypage{#2}% \def\@outputpage{\fb@outputpage}} \def\thisfancypage#1#2{% \gdef\@outputpage{\fb@outputpage}% \gdef\this@fancypage{\def\the@fancypage{#1}\def\the@@fancypage{#2}}} % \fancyput % Token registers used to make it easier to put definitions in argument. % Boxes not processed until output so that contents can depend, e.g., on % current page or marks or whatever. This makes everything slightly more % complicated than one would expect. \newtoks\the@fancyput \newtoks\this@fancyput \def\fancyput@flag{-1}% % \fancyput@flag=-1 if no fancyput, 0 if regular fancyput, 1 if thisfancyput. \def\fancyput{% \def\@outputpage{\fb@outputpage} \@ifstar{\@testtrue\@fancyput}{\@testfalse\@fancyput}} \def\@fancyput{\@ifnextchar({\@@fancyput}{\@@fancyput(\z@,\z@)}} \def\@@fancyput(#1,#2)#3{% \if@test \expandafter\the@fancyput\expandafter{\the\the@fancyput\do{#1}{#2}{#3}}% \else \the@fancyput{\do{#1}{#2}{#3}}% \fi \gdef\fancyput@flag{\z@}} \def\thisfancyput{% \gdef\@outputpage{\fb@outputpage} \@ifstar{\@testtrue\@thisfancyput}{\@testfalse\@thisfancyput}} \def\@thisfancyput{\@ifnextchar({\@@thisfancyput}{\@@thisfancyput(\z@,\z@)}} \def\@@thisfancyput(#1,#2)#3{% \if@test \ifnum\fancyput@flag=\z@ \expandafter\global\expandafter\this@fancyput\expandafter{% \the\this@fancyput\do{#1}{#2}{#3}}% \else \expandafter\global\expandafter\this@fancyput\expandafter{% \the\the@fancyput\do{#1}{#2}{#3}}% \fi \else \global\this@fancyput{\do{#1}{#2}{#3}}% \fi \gdef\fancyput@flag{1}} \def\do@fancyput{% \def\do##1##2##3{\raise##2\hbox to\z@{\kern##1\relax##3\hss}}% \setbox\@tempboxa=\hbox to\z@{% \kern-\hoffset \raise\voffset\hbox{% \ifnum\fancyput@flag=\z@\the\the@fancyput\else\the\this@fancyput\fi}% \hss}% \ht\@tempboxa=\z@ \dp\@tempboxa=\z@ \box\@tempboxa \gdef\fancyput@flag{\z@}% \global\this@fancyput{}} % \Landscape \def\UsePageParameters{% \clearpage \global\@colht\textheight \onecolumn} \def\fb@rotatepage{} \def\Landscape{\@ifstar{\@testtrue\@Landscape}{\@testfalse\@Landscape}} \def\@Landscape#1#2#3{% \clearpage \def\fb@rotatepage{#3}% \def\@outputpage{\fb@outputpage}% \@tempdima#1\relax \@tempdimb#2\relax \if@test \edef\fb@theoffsets{{\voffset}{\hoffset}{\number\@tempdima sp}}% \else \edef\fb@theoffsets{{\hoffset}{\voffset}{\number\@tempdimb sp}}% \fi \advance\@tempdimb-\@tempdima \advance\textwidth\@tempdimb \advance\textheight-\@tempdimb \UsePageParameters} \def\endLandscape{\clearpage\aftergroup\UsePageParameters} \def\fb@setoffsets#1#2#3{% \@tempdima#1% \advance#1#2% #2#3 \advance#2-2in \advance#2-\@tempdima} \@namedef{Landscape*}{\@testtrue\@Landscape} \@namedef{endLandscape*}{\endLandscape} % \Btrivlist \def\@Blistrestore{% \let\par\relax \let\-\@dischyph \let\'\@acci \let\`\@accii \let\=\@acciii \lineskip\normallineskip \baselineskip\normalbaselineskip} \def\Btrivlist#1{\@ifnextchar[{\@Btrivlist{#1}}{\@Btrivlist{#1}[]}} \def\@Btrivlist#1[#2]{% \@Blistrestore \let\\=\@Btrivlistcr \fb@beginvbox{#2}% \halign\bgroup \if#1l\else\@empty\hfil\fi \ignorespaces##\unskip \if#1r\@empty\else\hfil\fi\cr} \def\endBtrivlist{\cr\egroup\egroup\if@pboxsw$\fi} \def\fb@beginvbox#1{% \leavevmode \@pboxswfalse \if#1b\@empty\vbox\else\if#1t\@empty\vtop\else \ifmmode\vcenter\else\@pboxswtrue$\vcenter\fi \fi\fi\bgroup} \def\@Btrivlistcr{\@ifstar {\@ifnextchar[{@@Btrivlistcr}{\cr}}{\@ifnextchar[{\@@Btrivlistcr}{\cr}}} \def\@@Btrivlistcr[#1]{\cr\noalign{\vskip #1}} \def\Bcenter{\Btrivlist{c}} \def\endBcenter{\endBtrivlist} \def\Bflushleft{\Btrivlist{l}} \def\endBflushleft{\endBtrivlist} \def\Bflushright{\Btrivlist{r}} \def\endBflushright{\endBtrivlist} % \Blist \def\Blist#1#2{\@ifnextchar[{\@Blist{#1}{#2}}{\@Blist{#1}{#2}[]}} \def\@Blist#1#2[#3]{% \ifnum\@listdepth>5 \@toodeep \else \global\advance\@listdepth\@ne \fi \itemindent\z@ \csname @list\romannumeral\the\@listdepth\endcsname \def\@itemlabel{#1}% \let\makelabel\@mklab \@nmbrlistfalse \@Blistrestore \let\\=\@Blistcr \let\item\Bitem \@Bitemswfalse #2\relax \fb@beginvbox{#3}% \halign\bgroup \ignorespaces##&\hskip\labelsep\ignorespaces##\unskip\hfil\cr} \def\endBlist{\endBtrivlist\global\advance\@listdepth\m@ne} \newif\if@Bitemsw \def\Bitem{\@ifnextchar({\@Bitemcr\Bitem@skip}{\@Bitemcr\@Bitem}} \def\@Bitemcr{% \if@Bitemsw \def\next{\cr\noalign{\vskip\itemsep}}% \else \def\next{\global\@Bitemswtrue}% \fi \next} \def\Bitem@skip(#1){\noalign{\vskip #1}\@Bitem} \def\@Bitem{\@ifnextchar[{\Bitem@label}{\Bitem@nolabel}} \def\Bitem@label[#1]{\makelabel{#1}&} \def\Bitem@nolabel{% \if@nmbrlist \expandafter\advance\csname c@\@listctr\endcsname1 \fi \makelabel{\@itemlabel}% &% \if@nmbrlist\refstepcounter{\@listctr}\fi} \def\@Blistcr{\@ifstar {\@ifnextchar[{@@Blistcr}{\cr&}}{\@ifnextchar[{\@@Blistcr}{\cr&}}} \def\@@Blistcr[#1]{\cr\noalign{\vskip #1}&} % \Bitemize \def\Bitemize{% \ifnum\@itemdepth>3 \@toodeep \else \advance\@itemdepth\@ne \fi \edef\@itemitem{labelitem\romannumeral\the\@itemdepth}% \Blist{\csname\@itemitem\endcsname}{\def\makelabel####1{\hfil####1}}} \def\endBitemize{\endBlist} % \Bdescription \def\Bdescription{\Blist{}{\def\makelabel####1{\bf####1\hfil}}} \def\endBdescription{\endBlist} % \Benumerate \def\Benumerate{% \ifnum\@enumdepth>3 \@toodeep \else \advance\@enumdepth\@ne \fi \edef\@enumctr{enum\romannumeral\the\@enumdepth}% \Blist{\csname label\@enumctr\endcsname}% {\usecounter{\@enumctr}\def\makelabel####1{\hfil####1}}} \def\endBenumerate{\endBlist} % \GenericCaption \def\GenericCaption#1{% \par \begingroup \@parboxrestore \normalsize \vskip 10\p@ \setbox\@tempboxa\hbox{#1}% \ifdim\wd\@tempboxa>\hsize #1\par \else \hbox to\hsize{\hfil\box\@tempboxa\hfil}% \fi \endgroup \par} % \landfloat \def\landfloat#1#2{% \gdef\curr@landfloat{#1}% \gdef\float@rotation{#2}% \begin{#1}[p]% \setbox\@tempboxa\vbox\bgroup \hsize\@colht \@parboxrestore} \def\endlandfloat{% \par\vskip\z@ \egroup \setbox\@tempboxa\hbox{\float@rotation{\box\@tempboxa}}% \centerline{\box\@tempboxa}% \expandafter\end\expandafter{\curr@landfloat}} % Verbatim % The main idea is to separate the reading and formatting of the % verbatim listing. It's pretty simple. \def\Verbatim@Codes{% \let\do\@makeother \dospecials \Verbatim@ObeyThings \ThisVerbCodes\relax\gdef\ThisVerbCodes{}} \def\EveryVerbatimCodes{} % \Verbatim is redefined temporarilly in \Get@Verbatim to scan the % verbatim text. \Verbatim is used so that error messages are more % enlightening. \next checks whether \Verbatim found its argument, % and attempts to recover if not. % % Heuristically, if current environment is `foo' and argument of % \Get@Verbatim is \The@Verbatim, then definition of \Verbatim is % % \def\Verbatim#1^^M#2^^M\end{foo}{% % \xdef\The@Verbatim{\noexpand\Every@VerbatimLine#2}% % \endgroup\end{foo}} % % \The@Verbatim is then equal to the verbatim text, with spaces % replaced by \Verbatim@Space, tabs replaced by \Verbatim@Tab, % and ` replaced by \@lquote. In addition, each line begins with % \Every@VerbatimLine, and each line but the last ends with % \Verbatim@Par. It is then possible to redefine these when formatting % the verbatim text. To insert each line as an argument to \foo, use % \def\Every@VerbatimLine#1\Verbatim@Par{\foo{#1}} % \The@Verbatim\Verbatim@Par % \begingroup \catcode`\|=0 \catcode`\[=1 \catcode`\]=2 \catcode`\{=12 \catcode`\}=12 \catcode`\^^M=13% \catcode`\\=12% |gdef|Get@Verbatim#1[% |begingroup% |Verbatim@Codes|EveryVerbatimCodes% |let|protect|noexpand% |VerbatimEnvironment% |edef|next[|noexpand|def|noexpand|Verbatim% ####1|noexpand^^M####2|noexpand^^M\end{|@VerbEnvir}]% |edef|endVerbatim[|noexpand|endgroup|noexpand|end[|@VerbEnvir]]% |global|let|@VerbEnvir|relax% |next[|@nil|xdef#1[|noexpand|Every@VerbatimLine##2]|endVerbatim]% |def|next[|@ifnextchar|@nil[|@gobble]% [|gdef#1[]|endVerbatim|end[document]]]% |expandafter|next|Verbatim]% |endgroup % It is enough to not use \begin or \end when defining new verbatim % environments, as the default is for \Get@Verbatim to look for the % end of the current environment, but using \VerbatimEnvironment % is easier to explain to users. \def\VerbatimEnvironment{% \ifx\@VerbEnvir\relax\xdef\@VerbEnvir{\@currenvir}\fi} \let\@VerbEnvir\relax \def\The@VerbatimErr{% \gdef\The@Verbatim{\@latexerr{Misplaced \string\end{Verbatim}}\@ehd}} \The@VerbatimErr \begingroup \catcode`\^^M=\active% \catcode`\ =\active% \catcode`\^^I=\active% \gdef\Verbatim@ObeyThings{% \catcode`\^^M=\active% \catcode`\ =\active% \catcode`\^^I=\active% \catcode``=\active% \def^^M{\noexpand\Verbatim@Par\noexpand\Every@VerbatimLine}% \def^^I{\noexpand\Verbatim@Tab}% \def {\noexpand\Verbatim@Space}% \Verbatim@NoLigs}% \gdef\Verbatim@DontObeyLines{\outer\def^^M{}}% \endgroup \def\SaveVerbatim{\@bsphack\Get@Verbatim} \def\endSaveVerbatim{\@esphack} {\catcode``13 \gdef\Verbatim@NoLigs{\def`{\noexpand\@lquote}}} \def\Verbatim@Prep{% \frenchspacing \ThisVerb\relax\gdef\ThisVerb{}% \VerbatimFont \EveryVerbatim \let\Every@VerbatimLine\EveryVerbatimLine \def\Verbatim@Space{\leavevmode\penalty\@M\VerbatimSpace}% \def\Verbatim@Tab{\leavevmode\penalty\@M\VerbatimTab}}% \def\Verb@Prep{% \frenchspacing \ThisVerb\relax\gdef\ThisVerb{}% \VerbFont \EveryVerb \let\Every@VerbatimLine\EveryVerbatimLine \def\Verbatim@Space{\leavevmode\penalty\@M\VerbSpace}% \def\Verbatim@Tab{\leavevmode\penalty\@M\VerbTab}}% \def\Verbatim@Par{\leavevmode\null\@@par\penalty\interlinepenalty} % Parameter initialization: \def\VerbatimSpace{\ } {\catcode`\ =12\gdef\ttspace{{\tt }}} \def\VerbSpace{\ } \def\VerbatimTab{\ \ \ \ \ \ \ \ } \def\VerbTab{\ } \def\EveryVerbatim{} \def\EveryVerb{} \def\ThisVerb{} \def\EveryVerbatimLine{}% \def\EveryVerbOutLine{} \def\VerbatimFont{\tt} \def\VerbFont{\tt} \def\VerbatimFuzz{2pt}% \def\EveryVerbatimCodes{} \def\EveryVerbCodes{} \def\EveryVerbOutCodes{} \def\ThisVerbCodes{} \def\Verbatim@List#1{% \if@minipage\else\vskip\parskip\fi \leftskip\@totalleftmargin \rightskip\z@ \parindent\z@ \parskip\z@ \parfillskip\@flushglue \hfuzz\VerbatimFuzz\relax \@@par \global\@inlabelfalse %Prevents vspace from being inserted when \Verbatim@Prep %first line exceeds \hsize. #1% \Verbatim@Par}% \def\UseVerbatim#1{% \begingroup\trivlist\item[]\Verbatim@List{#1}\endtrivlist\endgroup} \def\Verbatim{\Get@Verbatim\The@Verbatim} \def\endVerbatim{\UseVerbatim\The@Verbatim\The@VerbatimErr} \def\LUseVerbatim#1{% \begingroup\list{}{}\item[]\Verbatim@List{#1}\endlist\endgroup} \def\LVerbatim{\Get@Verbatim\The@Verbatim} \def\endLVerbatim{\LUseVerbatim\The@Verbatim\The@VerbatimErr} \def\BUseVerbatim{% \@ifnextchar[{\@BUseVerbatim}{\@BUseVerbatim[]}} \def\@BUseVerbatim[#1]#2{% \begingroup \Verbatim@Prep \def\Verbatim@Par{\@Btrivlistcr}% \@Btrivlist{l}[#1]% #2% \endBtrivlist \endgroup}% \def\BVerbatim{% \catcode`\^^M=13\relax \@ifnextchar[{\@BVerbatim}{\@BVerbatim[]}} \def\@BVerbatim[#1]{\def\@tempa{[#1]}\Get@Verbatim\The@Verbatim} \def\endBVerbatim{ \expandafter\@BUseVerbatim\@tempa\The@Verbatim\The@VerbatimErr} \newwrite\Verbatim@Outfile \def\VerbatimOut#1{% \@bsphack \begingroup \immediate\openout\Verbatim@Outfile #1\relax \def\EveryVerbatimCodes{\EveryVerbOutCodes}% \Get@Verbatim\The@Verbatim} \def\endVerbatimOut{% \Verbatim@ObeyThings \def\Verbatim@Par{^^J}% \def\Verbatim@Space{\space}% \def\Verbatim@Tab{\space}% \def\@lquote{\string`}% \ThisVerb\relax\gdef\ThisVerb{}% \let\Every@VerbatimLine\EveryVerbOutLine \immediate\write\Verbatim@Outfile{\The@Verbatim}% \immediate\closeout\Verbatim@Outfile \endgroup \The@VerbatimErr \@esphack} % This one is a little tricky because: % * we want to ignore the ^^M at the end of the last line, % * we want to handle files that end with newline and files that don't % * we want comment characters to work properly, % * we want to expand each line before inserting \Every@VerbatimLine and % \Verbatim@Par, % % \Verbatim is used as scratch. \newread\Verbatim@Infile \def\Verbatim@Input#1#2{% \begingroup \Verbatim@Codes\EveryVerbatimCodes \immediate\openin\Verbatim@Infile #1\relax \ifeof\Verbatim@Infile \@latexerr{No verbatim file #1}\@ehd \else \def\Verbatim{}\Verbatim@NextLine \ifeof\Verbatim@Infile \@latexerr{Verbatim file #1 is empty}\@ehd \else \let\The@Verbatim\Verbatim \def\Verbatim{}\Verbatim@NextLine #2{\Verbatim@@Input}% \fi \fi \immediate\closein\Verbatim@Infile \endgroup} \def\Verbatim@@Input{% \let\protect\noexpand \edef\The@Verbatim{% \noexpand\Every@VerbatimLine \The@Verbatim \ifeof\Verbatim@Infile\else\noexpand\Verbatim@Par\fi}% \let\protect\relax \The@Verbatim \ifeof\Verbatim@Infile\else \let\The@Verbatim\Verbatim \def\Verbatim{}\Verbatim@NextLine \expandafter\Verbatim@@Input \fi}% \begingroup\catcode`\^^M=\active% \gdef\Verbatim@NextLine{% \ifeof\Verbatim@Infile\else% \immediate\read\Verbatim@Infile to\@tempa% \expandafter\Verbatim@@NextLine\@tempa^^M\relax^^M\@nil% \fi}% % #2 is empty if line ends in ^^M, #2=\relax otherwise. \gdef\Verbatim@@NextLine#1^^M#2^^M#3\@nil{% \expandafter\def\expandafter\Verbatim\expandafter{\Verbatim#1}% \ifx#2\@empty\@empty\else\expandafter\Verbatim@NextLine\fi}% \endgroup% \def\UseVerb#1{\begingroup\Verb@Prep#1\endgroup} \def\SaveVerb{\@ifnextchar[{\Save@Verb}{\Save@Verb[]}} \long\def\Save@Verb[#1]#2{% \begingroup \Verbatim@Codes\Verbatim@DontObeyLines\EveryVerbCodes \Save@@Verb{#1}{#2}} \long\def\Save@@Verb#1#2#3{% \let\protect\noexpand \def\next{\@ifnextchar\@nil{\@gobble}{\endgroup}}% \long\def\Verb##1#3{\@nil\xdef#2{##1}\endgroup#1}% \expandafter\next\Verb} \def\Verb{\Save@Verb[\UseVerb{\The@Verbatim}]{\The@Verbatim}} \def\VerbatimInput#1{\begingroup\Verbatim@Input{#1}\UseVerbatim\endgroup} \def\LVerbatimInput#1{\begingroup\Verbatim@Input{#1}\LUseVerbatim\endgroup} \def\BVerbatimInput{\@ifnextchar[{\@BVerbatimInput}{\@BVerbatimInput[]}} \def\@BVerbatimInput[#1]#2{% \begingroup\Verbatim@Input{#2}{\@BUseVerbatim[#1]}\endgroup} \endinput %% END fancybox.sty %% BEGIN fancybox.doc %% %% Documentation for fancybox.sty. %% Run through LaTeX, with or without the NFSS. %% %% This creates two temporary files: \jobname.ex1 and \jobname.tmp \documentstyle[12pt,fancybox,pstricks]{article} \makeatletter %% DATES, VERSIONS AND TITLES: \def\expanddate#1/#2/#3/{\year=19#1 \month=#2 \day=#3} \begingroup \expandafter\expanddate\filedate/ \xdef\thefiledate{\today} \endgroup \title{Documentation for fancybox.sty:\\ Box tips and tricks for \LaTeX} \author{Timothy Van Zandt\\ tvz@Princeton.EDU} \date{Version \fileversion\\ \thefiledate} \def\@maketitle{% \begin{center} {\Large\bf \@title \par} \vskip 1.2em {\lineskip .5em \begin{tabular}[t]{c}\@author\end{tabular}\par} \vskip .8em {\@date}% \end{center} \par \vskip .5em} %% PAGE STYLE: \pagestyle{myheadings} \if@twoside \markboth{Documentation for fancybox.sty}% {Version \fileversion, \thefiledate}% \else \markright{fancybox.sty, Version \fileversion} \fi %% PAGE PARAMETERS: % Paragraphs are marked by large space rather than indentation: \parindent 0pt \parskip 7pt plus 1pt minus 1pt \setlength{\topmargin}{0pt} \setlength{\headheight}{12pt} % height of running head \setlength{\headsep}{30pt} % distance between header and text \setlength{\textheight}{8.2in} % height of text on page %% TABLE OF CONTENTS \def\tableofcontents{% \par\vfill \begin{quote} \begin{center} \Large\bf Contents \end{center} \def\numberline##1{\hbox to 0pt{\hss##1\hskip 1em}}% \@starttoc{toc}% \end{quote} \thispagestyle{empty} \vfill \clearpage} %% VERBATIM HACKS: % Short meta (works in verbatim. Can't use < for other purposes. \catcode`\<=13 \def<#1>{{\rm\it #1\/}} % (works in verbatim) % Short verbatim. " can appear in verbatim environments. \def\temp{\Verb"} \expandafter\def\expandafter\dospecials\expandafter{\dospecials\do\"} \catcode`\"=13 \let"\temp % Verbatim item: \newcommand{\vitem}{\SaveVerb[{\def\bf{}\item[\UseVerb{\MyTemp}]}]{\MyTemp}} %% EXAMPLES: \begin{VerbatimOut}{\jobname.ex1} % 1. Save example verbatim to \jobname.tmp, % 2. Input verbatim with \catcode`\"=14 (" is a comment). % 3. Input again with \catcode\`"=9 (" is ignored). \renewcommand{\EveryVerbatimLine}[2]{} \renewcommand{\EveryVerbOutLine}[2]{} \newcommand{\BeginExample}{% \VerbatimEnvironment\begin{VerbatimOut}{\jobname.tmp}} \newcommand{\EndExample}{% \end{VerbatimOut}%. \renewcommand{\EveryVerbatimLine}{}% \renewcommand{\EveryVerbatimCodes}{\catcode`\"=14}% \LVerbatimInput{\jobname.tmp}} \newenvironment{example*}{\BeginExample}{\EndExample \catcode`\"=9 \input{\jobname.tmp}} \newenvironment{example}{\BeginExample}{\EndExample \begin{center}\catcode`\"=9 \input{\jobname.tmp}% \end{center}} \end{VerbatimOut} \input{\jobname.ex1} %% END PREAMBLE: \makeatother \begin{document} \setcounter{page}{0} \maketitle \begin{quote} "fancybox.sty", together with its documentation, gives extensive answers to and solutions for many questions about how to frame or rotate this or that in \LaTeX. It also contains commands for shadow, double and oval frames. \end{quote} \tableofcontents \section{Fancy frames} "fancybox.sty" has five variants of \LaTeX's "\fbox" command: \begin{quote}\raggedright "\shadowbox", "\doublebox", "\ovalbox" (with "\thinlines") and "\Ovalbox" (with "\thicklines"). \end{quote} Here are examples: \begin{example} \shadowbox{\large\bf New Glarus Birdwatch} \end{example} \begin{example} \doublebox{\large\bf New Glarus Birdwatch} \end{example} \begin{example} \ovalbox{\large\bf New Glarus Birdwatch} \end{example} \begin{example} \Ovalbox{\large\bf New Glarus Birdwatch} \end{example} The distance between the box and the frame is "\fboxsep", as with \LaTeX's "\fbox" command. The commands use other parameters as well: \begin{description} \vitem"\shadowbox" The width of the frame is "\fboxrule" (the same as with "\fbox"). The width of the shadow is "\shadowsize" (default: "4pt"). \vitem"\doublebox" The width of the inner frame is .75"\fboxrule", and the width of the outer frame is 1.5"\fboxrule". The distance between the two frames is 1.5"\fboxrule" plus .5pt. \vitem"\ovalbox" The width of the frame is set by the "\thinlines" declaration. The diameter of the corner arcs is set with the "\cornersize" command. \begin{LVerbatim} \cornersize{} \end{LVerbatim} sets the diameter of the corners arcs to times the lessor of the width and height of the box. \begin{LVerbatim} \cornersize*{} \end{LVerbatim} sets the diameter of the corner arcs to . This is all approximate, because \LaTeX\ has a limited range of arc sizes to choose from. The default is \begin{LVerbatim} \cornersize{.5} \end{LVerbatim} \vitem"\Ovalbox" This is like "\ovalbox", except that the width of the lines is set by the "\thicklines" declaration. \end{description} There are no analogs to \LaTeX's "\framebox" command, which has various optional arguments not supported by "\fbox". You can get the exact same functionality by putting the argument of the above framing commands in a "\makebox". There is also a variant "\fancyoval" of \LaTeX's "\oval" picture object. The difference is that "\oval" always makes the diameter of the corner arcs as large as possible, and "\fancyoval" uses the "\cornersize" command to set the diameter. \section{A short course on boxes} \begingroup\sloppy The "\shadowbox", "\doublebox", "\ovalbox" and "\Ovalbox" commands described in the previous section are examples of LR-box commands, meaning that their argument is processed in LR mode. \LaTeX\ LR-box commands include "\mbox", "\makebox", "\fbox", "\framebox", "\sbox" and "\savebox". All the PSTricks commands whose argument is text are LR-box commands, including, e.g, the framing, rotating, scaling and positioning commands, and some of the node commands. Any rotation command is an LR-box command. \endgroup The purpose of the rest of this documentation is to provide answers to, and solutions for, frequently asked questions about using LR-box commands with \LaTeX. I will use "\fbox" for the leading example of a box framing command, and "\rotateleft" for the leading example of a box rotation command. ("fancybox.sty" does not contain a "\rotateleft" commands, as this must be implemented via "\special"'s, but there are numerous box-rotation style files around.) However, most of what is said here applies to any LR-box command. In each LR-box command, the text is processed in restricted horizontal mode, which is referred to as ``LR-mode'' in Lamport's {\em \LaTeX: User's Guide and Reference Manual}. In restricted horizontal mode, the input, consisting of regular characters and boxes, is made into one (long or short) line. There is no line-breaking, nor can there be vertical mode material such as an entire displayed equation. However, the fact that you can include another box means that this isn't really a restriction. For one thing, alignment environments such as \LaTeX's "tabular" are just boxes, and thus present no problem. Picture environments and the LR-box commands themselves are also just boxes. Entire paragraphs or other vertical mode material such as displayed equations can be nested in a "\parbox" or "minipage". \section{Defining LR-box environments} To frame a "minipage", you have to write \begin{LVerbatim} \fbox{% \begin{minipage}{9in} blah \end{minipage}} \end{LVerbatim} You might want to define an environment "fminipage" that frames its contents, but you can't use \begin{LVerbatim} \newenvironment{fminipage}[1]% {\fbox{\begin{minipage}{#1}}% {\end{minipage}}} \end{LVerbatim} because the braces are not balanced in the definition. "fancybox.sty" defines commands% \SaveVerb{\MyTempA}"\begin{sbox}"% \SaveVerb{\MyTempB}"\end{sbox}"% \footnote{Resist the temptation to type \UseVerb{\MyTempA} and \UseVerb{MyTempB}.} \begin{LVerbatim} \beginsbox{} ... \endsbox \end{LVerbatim} which is like \begin{LVerbatim} \sbox{}{...} \end{LVerbatim} Since the former doesn't use braces to delimit the contents of the box, we can define "fminipage" as follows: \begin{LVerbatim} \newsavebox{\mybox} \newenvironment{fminipage}[1]% {\beginsbox{\mybox}\begin{minipage}{#1}}% {\end{minipage}\endsbox\fbox{\usebox{\mybox}}} \end{LVerbatim} \section{Math} In-line math ,or pieces of a displayed equation (as opposed to a whole equation), are horizontal mode material, but most LR-box commands switch out of math mode when they occur in math mode. Thus, you have to explicitly switch back in to math mode when desired. For example: \begin{example} $x + y = \fbox{$\Omega$}$ \end{example} You also have to explicitly write \begin{quote} "\scriptstyle", "\scriptscriptstyle" or "\displaystyle" \end{quote} if you want one of these special math styles. For example, here I will frame an equation, but not the equation number: \begin{example*} \begin{equation} \fbox{$\displaystyle \int_{\Omega_0} \zeta(\omega) d\omega \geq \bar{r}$} \end{equation} \end{example*} \begin{quote} {\bf PSTricks Users:} \em The above does not apply, as PSTricks stays in math mode and guesses what math style you want. \end{quote} Entire displayed equations are vertical mode material. Thus, they have to go inside a "\parbox" or "minipage". E.g., \begin{example*} \newlength{\mylength} \[ \setlength{\fboxsep}{15pt} \setlength{\mylength}{\linewidth} \addtolength{\mylength}{-2\fboxsep}% \addtolength{\mylength}{-2\fboxrule}% \fbox{% \parbox{\mylength}{ \setlength{\abovedisplayskip}{0pt} \setlength{\belowdisplayskip}{0pt} \begin{equation} x + y = z \end{equation}}} \] \end{example*} The outer "\[" "\]" are just used to display the boxed equation, rather than actually switch into math mode. Note how I set the width of the "\parbox" so that the displayed box would exactly have width "\linewidth".\footnote{That is what {\tt\string\mylength} is for. It is better to define a single scratch length that you reuse rather than creating a new one each time.} I also set the display skips to "0pt" and increased the size of "\fboxsep" so that I would have the same distance all around between the equation and the frame. This is again a mouthful, and so I might instead define:\footnote{The reason for using {\tt\string\minipage} instead of \MyTemp, and so on, is that with AmS-\LaTeX, {\tt\string\begin} and {\tt\string\end} cannot appear in the definition of a new equation environment.} \begin{example*} "\globaldefs=1 \newsavebox{\mybox}% \newenvironment{FramedEqn}% {\setlength{\fboxsep}{15pt}% \setlength{\mylength}{\linewidth}% \addtolength{\mylength}{-2\fboxsep}% \addtolength{\mylength}{-2\fboxrule}% \beginsbox{\mybox}% \minipage{\mylength}% \setlength{\abovedisplayskip}{0pt}% \setlength{\belowdisplayskip}{0pt}% \equation}% {\endequation\endminipage\endsbox \[\fbox{\usebox{\mybox}}\]} \end{example*} "fancybox.sty" doesn't bother defining any such environments, because there are too many possible designs. But let's see if the one above works: \begin{example*} \begin{FramedEqn} \Rightarrow P\sim\xi(P_\gamma)- \frac{1}{3} \end{FramedEqn} \end{example*} \section{Floats}\label{floats} A common mistake is to put a whole "table", "figure" or other float environment inside an LR-box command. Instead, you should put everything that is {\em inside} the environment (including the "\caption", if you want that boxed too) inside a "minipage" of the desired width, and then put the "minipage" inside the LR-box command. For example: \begin{example*} \begin{table}[h] \begin{center} \fbox{% \begin{minipage}{.8\textwidth} \begin{center} \begin{tabular}{rl} foo & bar \end{tabular} \end{center} \caption{A table of foo and bar.} \end{minipage}} \end{center} \end{table} \end{example*} Note how I had to use "center" twice: once to center the framed box, and again to center the stuff inside the box. That is a mouthful, and so I might define a "FramedTable" environment like the following, which sets the size of the "minipage" so that the framed box is exactly the width of the page (no need for the first "center" environment this time): \begin{example*} "\globaldefs=1 \newenvironment{FramedTable}% {\begin{table}[h] \beginsbox{\mybox}% \setlength{\mylength}{\textwidth}% \addtolength{\mylength}{-2\fboxsep}% \addtolength{\mylength}{-2\fboxrule}% \begin{minipage}{\mylength}}% {\end{minipage}\endsbox \fbox{\usebox{\mybox}}% \end{table}} \end{example*} Now let's see if it works: \begin{example*} \begin{FramedTable} \begin{center} \begin{tabular}{rl} foo & bar \end{tabular} \end{center} \caption{A table of foo and bar.} \end{FramedTable} \end{example*} The most common reason to want to rotate an entire float, caption and all, is to put it on a page by itself in landscape mode, centered both horizontally and vertically. Compared to the table framing we did above, we just have to replace "\fbox" by our box rotation command (e.g., "\rotateleft" or whatever), set the width of the minipage to "\textheight" (if you want to use the full size of the page), and use the float position specifier "[p]". "fancybox.sty" contains an environment, \begin{LVerbatim} \begin{landfloat}{}{} ... \end{landfloat} \end{LVerbatim} that automates this. It has two arguments: the name of the floating environment, and your rotation command. For example, if "\rotateleft{foo}" rotates "foo" by 90 degrees, and you want a landscape mode "table", then try \begin{LVerbatim} \begin{landfloat}{table}{\rotateleft} ... \end{landfloat} \end{LVerbatim} If the whole document is in landscape mode, then "landfloat" gives you a portrait-mode float---good for a table that is too tall to fit in landscape mode. If you don't add a caption to a float, it doesn't matter much what floating environment you use (e.g., "table", "figure" or whatever). Thus, you can put anything in a landscape float. For example, suppose I have a very wide equation. Then I can write: \begin{LVerbatim} \begin{landfloat}{table}{\rotateleft} \begin{equation} ... \end{equation} \end{landfloat} \end{LVerbatim} "fancybox.sty" defines a generic caption, "\GenericCaption", that doesn't affect the numbering of floats, doesn't make an entry in a list of floats, and doesn't add anything to the argument you give. I could have used this if I wanted to add a caption to the previous example. \section{Center, flushleft and flushright} There are two ways to box a "center", "flushleft" or "flushright" environment. If you have long lines and you want \TeX\ to do the line breaking, then put the environment inside a "minipage".\footnote{List and other such environments work best inside a {\tt minipage} environment rather than a {\tt \string\parbox}.} If you have short lines and you want the frame to adjust itself to the size of the longest line, then use "fancybox.sty"'s \begin{quote} "Bcenter", "Bflushleft" or "Bflushright" \end{quote} environment instead. These are basically just "tabular" environments with a single column, and so each line should end with "\\", or "\\[""]" to insert extra space, and the text on each line must be balanced. Also, each line is sitting in its own group, and so, e.g., if you want to change the font for the whole environment, you should do this before the environment rather than after. Like the "tabular" environment, the box that is produced has the baseline at the center, unless you include an optional argument "[t]" to align the box with the top line or "[b]" to align the box with the bottom line. For example: \begin{example} \setlength{\fboxsep}{10pt}% \fbox{% \begin{Bcenter} Love of life\\ and other short stories\\ by Policarpa Salabarrieta \end{Bcenter}} \end{example} Compare this with: \begin{example} \setlength{\fboxsep}{10pt}% \fbox{% \begin{minipage}{6cm} \begin{center} Love of life and other short stories by Policarpa Salabarrieta \end{center} \end{minipage}} \end{example} In either case, if we want the resulting framed box centered, we have to include it inside another "center" environment. Here is another example: \begin{example} My list: \fbox{% \begin{Bflushleft}[b] Galanga root\\ Coconut\\ Tempeh \end{Bflushleft}} \end{example} \section{Lists} There are again two ways to box a list environment such as \begin{quote} "itemize", "enumerate" or "description". \end{quote} You can put it in a "minipage" of pre-determined size and let \TeX\ do the line breaking, or you can use \begin{quote} "Bitemize", "Benumerate" or "Bdescription" \end{quote} instead, and let the box adjust to the size of the longest line. For example. \begin{example} \fbox{% \begin{Bitemize} \item Groceries \item Clean hamster cages \item Pick up Peter \end{Bitemize}} \end{example} Most of the usual list parameters are irrelevant except for "\itemsep" and "\labelsep". These environments are also based on the "tabular" environment, and so each item should be balanced text. You can't write "\vspace{4pt}" either, but you can insert an extra amount of space before an item by writing "\item(4pt)" (or "\item(4pt)[label]" if you have a label). Also, you can break lines within an item using "\\" or "\\[]". For example: \begin{example} \fbox{% \begin{Bdescription} \item[David] Groceries \item[Eli] Hamster cages\\ Surreal numbers \item(3pt)[Doris] Pick up Peter \end{Bdescription}} \end{example} These environments also have an optional argument, "[t]" to align the box with the top line, and "[b]" to align the box with the bottom line. \begin{example} To do: \fbox{\setlength{\itemsep}{0pt}% \begin{Benumerate}[t] \item Groceries \item Hamster cages \item Pick up Peter \end{Benumerate}} \end{example} There is also a generic "\Blist" command that is analogous to \LaTeX's "\list". It has the same two obligatory arguments, plus a third optional "[t]" or "[b]" argument for changing the alignment. \section{Verbatim} If you try to frame some verbatim text by typing \begin{LVerbatim} \fbox{% \begin{minipage}{5cm} \begin{verbatim} \My \Program \Listing if { foo } { bar } fi \end{verbatim} \end{minipage}} \end{LVerbatim} you will get nonsense at best. This is because the argument to "\fbox" is read before the "\begin{verbatim}" is processed. But then it is too late for \TeX\ to go back and interpret the contents of the verbatim environment literally rather than as special \TeX\ commands and characters. A solution is to use "fancybox.sty"'s "\beginsbox" and "\endsbox": \begin{example} \beginsbox{\mybox} \begin{minipage}{5cm} \begin{verbatim} \My \Program \Listing if { foo } { bar } fi \end{verbatim} \end{minipage} \endsbox \setlength{\fboxsep}{8pt} \fbox{\usebox{\mybox}} \end{example} If you try to define your own framed verbatim environment with \begin{LVerbatim} \newenvironment{FramedVerb}% {\beginsbox{\mybox}\begin{minipage}{5cm} \begin{verbatim}} {\end{verbatim}\end{minipage}\endsbox \setlength{\fboxsep}{8pt}% \fbox{\usebox{\mybox}}} \end{LVerbatim} and then type \begin{LVerbatim} \begin{FramedVerb} if { foo } { bar } fi \end{FramedVerb} \end{LVerbatim} you will again run into trouble because after the "\begin{verbatim}", \LaTeX\ is searching for the literal string "\end{verbatim}" as the end of the verbatim text. It just skips right of the "\end{FramedVerb}" and may well continue to the end of the file or until it throws up. "fancybox.sty" contains some verbatim environments that get around this problem and have other advantages for LR-boxing verbatim listings, when compared to the standard \LaTeX\ "verbatim" environment. Admittedly, many of their special features have nothing to do with boxes. Here are the basic verbatim environments: \begin{description} \vitem"Verbatim" Works pretty much like \LaTeX's "verbatim". \vitem"LVerbatim" Like "Verbatim", but "list" rather than "trivlist" is used to display the listing, and so it is indented from the left margin. (This is what I am using for verbatim listings in this document.) \vitem"BVerbatim[]" Produces a box with the same width as the longest verbatim line. The baseline is in the center, unless you include the optional argument "[t]" for alignment with the top line or "[b]" for alignment with the bottom line. \vitem"VerbatimOut{}" Writes the verbatim text to . \vitem"SaveVerbatim{}" Saves the verbatim text as . is defined globally, without checking whether is already defined. Use obviously innocuous names like "\MyTemp". \end{description} For any of these verbatim environments, or new verbatim environments you define yourself (see below), nothing should come after "\begin{Verbatim}" or before "\end{Verbatim}" on the same line --- not even spaces. If you misspell "\end{foo}" or put something before it on the same line, you will get an error such as \begin{LVerbatim} ! File ended while scanning use of \Verbatim. \end{LVerbatim} and the document will end at that point. You can define new verbatim environments using "\newenvironment". All you have to do is start the definition with \begin{LVerbatim} \VerbatimEnvironment \end{LVerbatim} For example, here is the framed verbatim environment we tried earlier: \begin{example*} "\globaldefs=1 \newenvironment{FramedVerb}% {\VerbatimEnvironment \beginsbox{\mybox}\begin{minipage}{5cm}% \begin{Verbatim}}% {\end{Verbatim}\end{minipage}\endsbox \setlength{\fboxsep}{8pt}% \fbox{\usebox{\mybox}}} \end{example*} Let's give it a try: \begin{example} \begin{FramedVerb} if { foo } { bar } fi \end{FramedVerb} \end{example} Here are three commands for inputting a whole file verbatim. The file must end with a new line. \begin{description} \vitem"\VerbatimInput{}" Like "\Verbatim". \vitem"\LVerbatimInput{}" Like "\LVerbatim". \vitem"\BVerbatimInput[]{}" Like "\BVerbatim". \end{description} Here are three commands for making use of verbatim text that has been saved to a command: \begin{description} \vitem"\UseVerbatim{}" Like "\Verbatim". \vitem"\LUseVerbatim{}" Like "\LVerbatim". \vitem"\BUseVerbatim[]{}" Like "\BVerbatim". \end{description} The "SaveVerbatim" environment and the "\UseVerbatim" commands are useful for including verbatim text in the argument of "\footnote", "\fbox" or another command. For example, here is another way to define the "FramedVerb" environment, without "\beginsbox": \begin{LVerbatim} \newenvironment{FramedVerb}% {\VerbatimEnvironment \begin{SaveVerbatim}{\MyTemp}}% {\end{SaveVerbatim}% \setlength{\fboxsep}{8pt}% \fbox{\begin{minipage}{5cm}\UseVerbatim{\MyTemp} \end{minipage}}} \end{LVerbatim} Here are some verbatim commands for short-pieces of (in-line) verbatim text: \begin{description} \vitem"\Verb " \ \\ Like \LaTeX's "\verb" command, but it will complain if it encounters a new line in .\footnote{Be careful that your word processing does not insert one for you.} For example: \begin{example*} "\begin{quote} The main use for the \Verb+SaveVerbatim+ environment and the \Verb+\UseVerbatim+ commands is to include $\ldots$ "\end{quote} \end{example*} \vitem"\UseVerb{}" Like "\UseVerbatim", but without any particular formatting. It is intended for including short pieces of literal text saved with "\SaveVerb" (below).\footnote{But it can also be used for multiple lines saved with the {\tt SaveVerbatim} environment if you want to do the formatting yourself. E.g., try this in a tabbing environment with {\tt\string\VerbatimTab} appropriately defined.} \vitem"\SaveVerb[]{} "\ \\ This is like "\Verb", but it saves as , and then returns to the optional argument . Like the "SaveVerbatim" environment, it defines globally without checking whether is already defined. Without the optional argument, the most common use is for including verbatim text in a "\footnote" or other command argument. The optional argument can be used for special tricks. For example, all the listings of commands in this documentation use "\vitem" in a "description" environment, where "\vitem" is defined by:\footnote{The braces enclosing the optional argument of {\tt\string\SaveVerb} prevent the {\tt ]} inside the argument from being mistaken for the end of the argument.} \begin{LVerbatim} \newcommand{\vitem}% {\SaveVerb[{\item[\UseVerb{\MyTemp}]}]{\MyTemp}} \end{LVerbatim} Whereas \begin{LVerbatim} \item[\Verb"\foo"] \end{LVerbatim} would not work because after "\item" reads its argument it is too late to interpret "\foo" literally, \begin{LVerbatim} \vitem"foo" \end{LVerbatim} does work because it is equivalent to \begin{LVerbatim} \SaveVerb{\MyTemp}"foo"\item[\UseVerb{\MyTemp}] \end{LVerbatim} \end{description} These environments and commands use various parameters that make it easy to customize their behavior. However, until you want to find the need for such customization, you might as well ignore the rest of this section. Internally, "fancybox.sty" separates the reading and formatting of verbatim text. Most of the environments and command perform both functions, but "SaveVerbatim" and "\SaveVerb" only read the text, "UseVerbatim" (and company) and "\UseVerb" only format the text. "VerbatimOut" gets special treatment. The parameters that apply to each class of verbatim environment or command is listed in Table \ref{verbtable}. \begin{table} \begin{center} \renewcommand{\arraystretch}{0} \setlength{\tabcolsep}{7pt} \newcommand{\vs}{& \\[\tabcolsep]} \newcommand{\VS}{\\ \vs \hline \vs} \begin{tabular}{|l|l|} \hline \vs {\em Where} & {\em What} \\ \vs \hline \hline \vs \begin{Bflushleft} Environments\\ that format \end{Bflushleft} & \begin{Bflushleft} "\VerbatimSpace"\\ "\VerbatimTab"\\ "\VerbatimFont"\\ "\VerbatimFuzz"\\ "\EveryVerbatimLine"\\ "\EveryVerbatim"\\ "\ThisVerb" \end{Bflushleft} \VS \begin{Bflushleft} Environments\\ that read \end{Bflushleft} & \begin{Bflushleft} "\EveryVerbatimCodes"\\ "\ThisVerbCodes" \end{Bflushleft} \VS \begin{Bflushleft} "\Verb" and\\ "\UseVerb" \end{Bflushleft} & \begin{Bflushleft} "\VerbSpace"\\ "\VerbTab"\\ "\VerbFont"\\ "\EveryVerb"\\ "\ThisVerb" \end{Bflushleft} \VS \begin{Bflushleft} "\Verb" and\\ "\SaveVerb" \end{Bflushleft} & \begin{Bflushleft} "\EveryVerbCodes"\\ "\ThisVerbCodes" \end{Bflushleft} \VS \begin{Bflushleft} "VerbatimOut" \end{Bflushleft} & \begin{Bflushleft} "\EveryVerbOutCodes"\\ "\ThisVerbCodes"\\ "\EveryVerbOutLine"\\ "\ThisVerb" \end{Bflushleft} \\ \vs \hline \end{tabular} \caption{Parameters for the verbatim environments and commands.\label{verbtable}} \end{center} \end{table} All the parameters, including "\VerbatimFuzz", are ordinary commands, and should be changed with "\renewcommand". Here is a description of each of the parameters for environments that format the verbatim text: \begin{description} \vitem"\VerbatimSpace" The insertion text for spaces. The default is "\ ", which produces a blank space. Change it to "\ttspace" to get \ttspace. \vitem"\VerbatimTab" The insertion text for tabs. The default is \begin{LVerbatim} \ \ \ \ \ \ \ \ \end{LVerbatim} \vitem"\VerbatimFont" The font to use for verbatim text. The default is "\tt" \vitem"\VerbatimFuzz" This is the amount by which lines can be too long in a "Verbatim" or "LVerbatim" environment before you get overfull "\hbox" warnings. This threshold is usually .1pt, but the default definition of "\VerbatimFuzz" is "2pt" because verbatim lines won't break and are therefore often too long. \vitem"\EveryVerbatimLine" This is inserted at the beginning of each line of verbatim environments or verbatim files. By default it does nothing. I like to indent each line in the verbatim environment in the input file by 2 spaces, so I define \begin{LVerbatim} \renewcommand{\EveryVerbatimLine}[2]{} \end{LVerbatim} to eat those spaces. (But I have to remember to put in two spaces or space markers for blank lines too.) You might also use it to number the lines. For example: \begin{example} \newcounter{VerbLineNo} \renewcommand{\EveryVerbatimLine}% {\makebox[25pt][r]{\stepcounter{VerbLineNo}% \tiny\rm\arabic{VerbLineNo}}} \renewcommand{\EveryVerbatim}% {\setcounter{VerbLineNo}{0}} \begin{SaveVerbatim}{\MyTemp} \setlength{\fboxsep}{15pt} \setlength{\mylength}{\linewidth} \end{SaveVerbatim} \fbox{\BUseVerbatim{\MyTemp}} \end{example} \vitem"\EveryVerbatim" Whatever else you want to say before formatting the verbatim text. By default, it does nothing. \vitem"\ThisVerb" This is executed before any of the commands above, and then its value is cleared. Use this to customize a single verbatim formatting environment. \end{description} Here is a description of the parameters for environments that read the verbatim text: \begin{description} \vitem"\EveryVerbatimCodes" This command is inserted just before reading the verbatim text. Use it to play with "\catcode"'s (see the {\em \TeX book}). For example, I might type \begin{LVerbatim} \renewcommand{\EveryVerbatimCodes}{\catcode`\"=14} \end{LVerbatim} if I want to use \Verb+"+ as a comment character in verbatim text.% \begin{SaveVerbatim}{\MyTemp} \def\MyQuote{"} % \MyQuote is now the character ", \def\temp{\Verb"} % in case I need it. \catcode`\"=13 % Now " is like a command. \let"\temp % Now "foo" is like \Verb"foo" \def\do{\noexpand\do\noexpand} % Now " can be used in verbatim \edef\dospecials{\dospecials\do\"} % environments anyway. \end{SaveVerbatim}\SaveVerb{\Foo}+"+\SaveVerb{\FFoo}+\Verb"foo"+% \footnote{Here is another {\tt\string\catcode} trick. We make \UseVerb{\Foo} a short verbatim command, so that we can say \UseVerb{\Foo foo\Foo} instead of \UseVerb{\FFoo}: \LUseVerbatim{\MyTemp}} \vitem"\ThisVerbCodes" This command is executed before "\EveryVerbCodes", and then it is cleared. Use this to fool with the "\catcode"`s of a single verbatim environment. \end{description} The parameters for "\Verb", "\UseVerb" and "\SaveVerb" and the "VerbatimOut" environment are analogous to the similar commands for other environments. Here is an example of the use of "\ThisVerb" to define a variant of "\Verb" that uses \ttspace\ to mark spaces: \begin{LVerbatim} \newcommand{\SVerb}{% \renewcommand{\ThisVerb}% {\renewcommand{\VerbatimSpace}{\ttspace}}% \Verb} \end{LVerbatim} Finally, without further comment, here are the definitions of the "example" and "example*" environments that were used for the examples in this document: {\renewcommand{\EveryVerbatimLine}{}\LVerbatimInput{\jobname.ex1}} \section{Framing a whole page} The commands \begin{LVerbatim} \fancyput*(,){} \thisfancyput*(,){} \end{LVerbatim} are pretty much like "\put" commands in a \LaTeX\ picture environment whose origin is 1 inch down and to the right from the top left corner of the page.\footnote{Don't blame me for \TeX's peculiar 1 inch margins.} The only differences are that (i) that any LR-mode material is permitted (including \LaTeX\ "picture" environment, of course), (ii) the coordinate is optional "(0pt,0pt)" is substituted by default), and (iii) if the coordinate is included, you {\em must} specify the units. "\thisfancyput" affects only the current page, and is a global declaration (analogous to "\thispagestyle"). If you include the optional "*", then the command adds to, rather than replaces, other things that have been inserted with "\fancyput" or "\thisfancyput". These commands are particularly useful for framing a page, because you can get a frame that is, e.g., 1 inch from each side of the physical page without having to worry about what margins you are using for the document. Here is an example: \begin{example*} \thisfancyput(3.25in,-4.5in){% \setlength{\unitlength}{1in}\fancyoval(7,9.5)} \end{example*} You could also use "\fancyput" to add some kind of ``watermark'' or background image (e.g., a light gray ``DRAFT''). There are other commands that directly frame or in some other way box the page of text: \begin{LVerbatim} \fancypage{}{} \thisfancypage{}{} \end{LVerbatim} Each finished page, before adding the headers and footers, (and thus having width and height "\textwidth" and "\textheight", is boxed with \begin{LVerbatim} {} \end{LVerbatim} Thus, should be, or should end with, a command whose argument can be a box, such as "\fbox" or "\rotateleft". Then the headers and footers are added, using the new width of the page, and this is boxed with \begin{LVerbatim} {} \end{LVerbatim} The same rules apply to as to . Here is an example: \begin{example*} \thisfancypage{% \setlength{\fboxsep}{8pt}% \setlength{\shadowsize}{8pt}% \shadowbox}{} \end{example*} {\bf Warning:} The commands described in this section change \LaTeX's output routine, and may not work with document styles that do the same. Also, bad arguments can cause serious errors with uninformative error messages. \section{Switching to landscape mode midstream} The most common reason to switch to landscape mode midstream is to rotate a float, such as a table or figure. This was discussed in Section \ref{floats}. You should use "landfloat" whenever you want to rotate the contents of a single page, without rotating the headers (perhaps bracketed by "\clearpage" if you don't want it to float). (You could also use "\fancypage", but this would entail first resetting all the page parameters.) If you really want to switch to landscape mode, rotating headers and all, then use "\Landscape" command or the "Landscape" environment. These have three arguments: the width of the paper, the height of the paper, and the rotation command you are using. For example, if I have a portrait mode document using the US 8.5in by 11in paper, and if "\rotateleft{foo}" rotates "foo" 90 degrees counterclockwise, then I can write \begin{LVerbatim} \begin{Landscape}{8.5in}{11in}{\rotateright} ... \end{Landscape} \end{LVerbatim} Use "\Landscape" rather then the "landscape" environment if you want the rest of the document to be in landscape mode. If your document is being printed in landscape mode, then "Landscape" switches to portrait mode. There are starred versions "\Landscape*" and "Landscape*" that are for rotating the page 90 degrees clockwise. For example, suppose I have a landscape mode document, and I want to switch to portrait mode for the rest of the document, rotating the pages to the ``right'' with "\rotateright". Then I would write \begin{LVerbatim} \Landscape*{11in}{8.5in}{\rotateright} \end{LVerbatim} "\Landscape" and its variants adjust the text width and height, leaving the margins exactly as they were before. It is quite possible that you want to make other changes to the page parameters after switching to landscape mode, but as Lamport points out the \LaTeX\ {\em User's Guide and Reference Manual}, this generally doesn't work right in the middle of the document. "fancybox.sty" has a command "\UsePageParameters" which gets around this. It should be used right after you change the page parameters (and the page parameter changes should come right after "\Landscape" or "\clearpage") {\bf Warning:} The commands and environments described in this section change \LaTeX's output routine, and may not work with document styles that do the same. Also, bad arguments can cause serious errors with uninformative error messages. \section{Changes} \raggedright \paragraph*{Version 0.9, November 23, 1992} First release. \paragraph*{Version 0.91, November 25, 1992} \begin{enumerate} \item "\shadowsize" is now a length, to be set with "\setlength" or "\addtolength". \item "\fancypage" split into "\fancypage" and "\fancyput" \end{enumerate} \end{document} %% END fancybox.doc -- Timothy Van Zandt (609)258-4050 tvz@Princeton.EDU (NeXTMail)