X-Git-Url: https://git.distorted.org.uk/~mdw/mdwtools/blobdiff_plain/baa9f3563a25ec9040d59b44a86d62f4d9786258..aecccf6c3d3688b8a30953b7fddc6e72d73b9465:/slowbox.dtx diff --git a/slowbox.dtx b/slowbox.dtx index ae32bbf..eb748d4 100644 --- a/slowbox.dtx +++ b/slowbox.dtx @@ -1,13 +1,3 @@ -% \begin{meta-comment} -% -% $Id: slowbox.dtx,v 1.2 2003/09/06 13:08:16 mdw Exp $ -% -% Cop-out for slow things -% -% (c) 2003 Mark Wooding -% -% \end{meta-comment} -% % \begin{meta-comment} %% %% slowbox package -- skipping of slow boxes @@ -17,12 +7,12 @@ %% it under the terms of the GNU General Public License as published by %% the Free Software Foundation; either version 2 of the License, or %% (at your option) any later version. -%% +%% %% This program is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied warranty of %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the %% GNU General Public License for more details. -%% +%% %% You should have received a copy of the GNU General Public License %% along with this program; if not, write to the Free Software Foundation, %% Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. @@ -31,10 +21,10 @@ % \begin{meta-comment} %<+package>\NeedsTeXFormat{LaTeX2e} %<+package>\ProvidesPackage{slowbox} -%<+package> [2003/08/27 1.0 skipping of slow boxes] +%<+package> [2003/08/27 1.0 Skipping of slow boxes] % \end{meta-comment} % -% \CheckSum{222} +% \CheckSum{223} %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z @@ -56,9 +46,9 @@ % %<*driver> \input{mdwtools} +\PassOptionsToPackage{hide}{slowbox} \describespackage{slowbox} \newcommand\opt[1]{\textsf{#1}} -\expandafter\def\csname sb@box:tag\endcsname{{2cm}{1cm}{0.5cm}} \def\*{\hspace{0pt plus 0.1pt}\ignorespaces} \mdwdoc % @@ -83,7 +73,7 @@ % mode, everything happens normally; in \opt{hide} mode, slow boxes are % replaced by frames. In order for the package to know the sizes of all of % your boxes, you must first run through once in \opt{show} mode. -% Thereafter, all should be well. +% Thereafter, all should be well. % % \DescribeEnv{slowbox} % In \opt{show} mode, the \env{slowbox} environment typesets its contents in @@ -112,34 +102,57 @@ % \env{slowbox$*$} environment takes a tag name, just like \env{slowbox} % does. % +% However, if \package{slowbox} sees a slow box \ it's not noticed +% before, it always typesets the box contents, and saves the measurements for +% later. +% +% \begin{demo}{Slow boxes} +%\newcommand{\pic} +% {\parbox[t]{20mm} +% {Just pretend that there's a picture +% here that would take aaaages to draw.}} +%-- +%\begin{slowbox*}{show} +% \pic +%\end{slowbox*} +%-- +%\begin{slowbox}{hide} +% \pic +%\end{slowbox} +%-- +% \end{demo} +% % \DescribeMacro\slowboxbegin % \DescribeMacro\slowboxend % It's useful to define your own commands environments which create slow % boxes. Often, though, what happens is that you want to put some stuff % \emph{inside} the slow box, but that doesn't work properly. What you must % do instead is say something like -% \begin{verbatim} +%\begin{verbatim} % \newenvironment{splunt}[1] % {...\slowboxbegin{#1}{...\startsplunt...}} % {\slowboxend{...\finishsplunt...}...} -% \end{verbatim} -% That is, \syntax{"\\slowboxbegin{""}{{""}"} starts a slow box, -% beginning with \ if we're in \opt{show} mode. +%\end{verbatim} +% That is, \syntax{"\\slowboxbegin{""}{""}"} starts a slow box, +% beginning with \ if we're in \opt{show} mode; and +% \syntax{"\\slowboxend{""}"} finishes it, ending with \. % % The |\slowboxbegin| command has a |*|-variant, which causes the box to be % typeset regardless of the current mode setting. % % \DescribeMacro\newslowboxenv -% There's an environment for building slow box environments. Say -% \syntax{"\\newslowboxenv{""}"\* "[""]"\* +% Plumbing all of this together is rather tedious, so there's also a +% command for building slow box environments. Say +% \syntax{"\\newslowboxenv{""}"\* "[""]"\*"[""]"\* % "{""}"\* "{""}"\* "{""}"\* % "{""}"}. This creates a new environment (just like with -% |\newenvironment|). The contents are put in a slow box with \ -% on the front and \ on the end. Before the box is begun, -% \ is performed, and \ is done afterwards. The -% environments so created have \env{$*$}-variants which ignore the current -% mode, just like \env{slowbox$*$}. They also gather an additional \ -% argument, which you don't have to bother with. +% |\newenvironment|, taking \ arguments, maybe with the first one +% optional and defaulting to \). The contents are put in a slow box +% with \ on the front and \ on the end. Before the box +% is begun, \ is performed, and \ is done +% afterwards. The environments so created have \env{$*$}-variants which +% ignore the current mode, just like \env{slowbox$*$}. They also gather an +% additional \ argument, which you don't have to bother with. % % \DescribeMacro\doslowbox % Finally, for commands, there's \syntax{"\\doslowbox{""}"\* @@ -265,24 +278,25 @@ \begingroup% \def\sb@end##1{\endgroup}% \let\sb@ignore\ignore% - \expandafter\sb@hidden\csname sb@box:#1\endcsname{#1}% + \expandafter\sb@hidden\csname sb@box:#1\endcsname{#1}{#2}% } % \end{macrocode} % \end{macro} % % \begin{macro}{\sb@hidden} % We're given the control token and the tag name. If the control sequence is -% like |\relax| then |\csname| must have invented it and we just have to make -% something up. Otherwise we put the right stuff in a frame. Don't forget -% to write out the box dimensions to the new aux file! +% like |\relax| then |\csname| must have invented it and we should typeset it +% anyway in order to measure it. Otherwise we put the right stuff in a +% frame. Don't forget to write out the box dimensions to the new aux file! % \begin{macrocode} -\def\sb@hidden#1#2{% - \ifx#1\relax\fbox{Unknown slow box \texttt{#2}!}% - \else\edef\next@{\noexpand\sb@hidden@i#1{#2}}\expandafter\next@\fi% +\def\sb@hidden#1#2#3{% + \ifx#1\relax\def\next@{\endgroup\sb@begin@show{#2}{#3}}% + \else\edef\next@{\noexpand\sb@hidden@i#1{#2}}\fi% + \next@% } \def\sb@hidden@i#1#2#3#4{% \frameonly{#1}{#2}{#3}{Omitted \texttt{#4}}% - \immediate\write\@auxout{\string\sb@def{#4}{#1}{#2}{#3}}% + \immediate\write\@auxout{\string\sb@def{#4}{#1}{#2}{#3}}% } % \end{macrocode} % \end{macro} @@ -315,7 +329,7 @@ }% \dimen@#3\advance\dimen@-\dp\z@% \setbox\z@\hbox{\lower\dimen@\box\z@}% - \leavevmode\box\z@% + \leavevmode\box\z@% } % \end{macrocode} % \end{macro} @@ -372,4 +386,4 @@ % \end{macrocode} % % \Finale -\endinput \ No newline at end of file +\endinput