| 1 |
% Copyright 2000 by Klaus Guntermann |
| 2 |
% Copyright 2004 by Till Tantau <[email protected]>. |
| 3 |
% Copyright 2015 by Vedran Mileti\'c, Joseph Wright |
| 4 |
% |
| 5 |
% This program can be redistributed and/or modified under the terms |
| 6 |
% of the GNU Public License, version 2. |
| 7 |
|
| 8 |
% |
| 9 |
% Copyright notices: Large parts of this file are identical to the |
| 10 |
% file mpmulti.sty from the ppower4 distribution. Unfortunately, no |
| 11 |
% clear copyright notice is given in the original file nor is even the |
| 12 |
% author indicated. The author appears to be Klaus Guntermann and the |
| 13 |
% license appears to be GPL, at least the whole package is distributed |
| 14 |
% under GPL, so I assume that also applies to the individual |
| 15 |
% files. |
| 16 |
% |
| 17 |
|
| 18 |
% |
| 19 |
% This file does the same as the original mpmulti.sty. The only |
| 20 |
% differences are that a) the package pause is not loaded (it's |
| 21 |
% provided automatically by beamer and it should be loaded ``by hand'' |
| 22 |
% when using ppower4) and b) a default overlay specification can be |
| 23 |
% given (as in \multiinclude[<+->][...]{...}), which will be the |
| 24 |
% argument to an actionenv that is put around each image. |
| 25 |
% |
| 26 |
|
| 27 |
|
| 28 |
%% mpmulti.sty 09 Sep 2002 |
| 29 |
%%------------------------------------------------------------ |
| 30 |
%% History: |
| 31 |
%% Initial version 14 Apr 2000 |
| 32 |
%% Introduced keyword parameters 12 Jun 2000 |
| 33 |
%% Introduced new parameters (start,format), changed the |
| 34 |
%% global code to take several file counting strings (eg |
| 35 |
%% bla-*.mps, foo-*.jpg, etc.), added compatibility with |
| 36 |
%% \graphicspath (Jean-Christophe Dubacq) 06 Dec 2001 |
| 37 |
%% Generalized the format option, added the end |
| 38 |
%% handling and documented extended features in here |
| 39 |
%% 09 Sep 2002 |
| 40 |
%% |
| 41 |
%% Purpose: |
| 42 |
%% include multiple metapost pictures and overlay them, |
| 43 |
%% inserting a transition effect between them |
| 44 |
%% |
| 45 |
%% Synopsis: |
| 46 |
%% |
| 47 |
%% \multiinclude[defaultoverlayspecification]% |
| 48 |
%% [pause=transitioncommand, |
| 49 |
%% graphics={option for includegraphics}, |
| 50 |
%% format=filenameformat, |
| 51 |
%% start=number, |
| 52 |
%% end=number]{basefilename} |
| 53 |
%% |
| 54 |
%% Include all metapost generated graphics found in |
| 55 |
%% files with the basename "filename", which |
| 56 |
%% have a number attached or in the extension. |
| 57 |
%% Insert the transitioncommand between the files (defaults |
| 58 |
%% to \pause). |
| 59 |
%% Further options allow to specify additional specifications |
| 60 |
%% for includegraphics, can change the number to start with |
| 61 |
%% (default 0) or the number to end with (default 1000000). |
| 62 |
%% By default the filenames are as created by mpost in the format |
| 63 |
%% "filename.n", where "n" represents the number. |
| 64 |
%% The option format with the values like "mps", "png" or "jpg" this |
| 65 |
%% can be changed to "filename-n.format", e.g. "example-0.mps" |
| 66 |
%% instead of "example.0". |
| 67 |
%% Complaints are only written, if the first file is not found. |
| 68 |
%% Otherwise including will silently stop. |
| 69 |
%% |
| 70 |
%% If a defaultoverlayspecification is given, each image is |
| 71 |
%% surrounded by an actionenv environment (defined by the beamer |
| 72 |
%% class) with this option as argument. An example usage might be |
| 73 |
%% |
| 74 |
%% \multiinclude[<alert@+| +->][graphics={height=4cm}]{myimage} |
| 75 |
%% |
| 76 |
%% Requires: |
| 77 |
%% The keyval package for options processing. |
| 78 |
%% |
| 79 |
%% |
| 80 |
%\RequirePackage{pause} |
| 81 |
\RequirePackage{keyval} |
| 82 |
%% |
| 83 |
%% The command should process the optional arguments. |
| 84 |
%% |
| 85 |
\def\multiinclude{% |
| 86 |
\def\@mpm@pause{\pause}\def\@mpm@ospec{}\def\@mpm@endospec{}% |
| 87 |
\@ifnextchar [\@mpmulti{\@@@mpmulti[]}} |
| 88 |
%% |
| 89 |
\newif\if@mpm@groptions\@mpm@groptionsfalse |
| 90 |
%% We describe the keys and their default values |
| 91 |
\define@key{mpm}{format}[\@mpm@defaultformat]{% |
| 92 |
\global\def\@mpm@format##1{##1-\the\@mpm@count.#1}} |
| 93 |
\define@key{mpm}{start}[0]{\global\def\@mpm@start{#1}\relax} |
| 94 |
\define@key{mpm}{end}[1000000]{\global\def\@mpm@end{#1}\relax} |
| 95 |
\define@key{mpm}{pause}[\pause]{\global\def\@mpm@pause{#1}\relax} |
| 96 |
\define@key{mpm}{graphics}{\@mpm@groptionstrue |
| 97 |
\global\def\@mpm@graphics{\string#1}} |
| 98 |
\def\@mpm@defaultformat#1{#1.\the\@mpm@count} |
| 99 |
\let\@mpm@format=\@mpm@defaultformat |
| 100 |
%% |
| 101 |
%% We need a local counter |
| 102 |
%% |
| 103 |
\newcount\@mpm@count |
| 104 |
%% |
| 105 |
%% Implement the basic functionality. |
| 106 |
%% Try to include the first file unconditionally. |
| 107 |
%% This will produce an error message, if no such file can be found. |
| 108 |
%% Afterwards we are going to check for more files and stop, when we |
| 109 |
%% do not find another file. As long as we find files, these are |
| 110 |
%% overlapped to the previous parts. |
| 111 |
%% |
| 112 |
\def\@mpmulti[{\@ifnextchar<{\@@mpmulti[}{\@@@mpmulti[}} |
| 113 |
\def\@@mpmulti[#1]{% |
| 114 |
\def\@mpm@pause{\relax}% |
| 115 |
\def\@mpm@ospec{\begin{actionenv}#1}% |
| 116 |
\def\@mpm@endospec{\end{actionenv}}% |
| 117 |
\@ifnextchar[{\@@@mpmulti}{\@@@mpmulti[]}} |
| 118 |
\def\@@@mpmulti[#1]#2{% |
| 119 |
%% reset the options |
| 120 |
\global\def\@mpm@graphics{}% |
| 121 |
\global\def\@mpm@start{0}% |
| 122 |
\global\def\@mpm@end{1000000}% |
| 123 |
%% get the arguments |
| 124 |
\setkeys{mpm}{#1}% |
| 125 |
%% Insert the first part of the figure |
| 126 |
%% and make sure we look also in other places according to path. |
| 127 |
\let\@mpm@oldinp@th\input@path\let\input@path\Ginput@path |
| 128 |
\@mpm@count=\@mpm@start |
| 129 |
\@mpm@ospec% |
| 130 |
\if@mpm@groptions% |
| 131 |
\edef\@mpm@do@include{\noexpand\includegraphics[\@mpm@graphics]{\@mpm@format{#2}}}% |
| 132 |
\@mpm@do@include% |
| 133 |
\else% |
| 134 |
\includegraphics{\@mpm@format{#2}}% |
| 135 |
\fi% |
| 136 |
\@mpm@endospec% |
| 137 |
\def\@mpmdoit{% Do it by conditional tail recursion. |
| 138 |
%% Select the next filename and advance counter |
| 139 |
\edef\@mpmfilename{\@mpm@format{#2}}% |
| 140 |
%% If the file exists, |
| 141 |
\IfFileExists{\@mpmfilename}{% |
| 142 |
%% insert the user defined transition (or the default), |
| 143 |
\@mpm@pause |
| 144 |
%% then process the next part and set up to try again. |
| 145 |
\llap{% |
| 146 |
\@mpm@ospec% |
| 147 |
\if@mpm@groptions |
| 148 |
\edef\@mpm@do@include{\noexpand |
| 149 |
\includegraphics[\@mpm@graphics]{\@mpmfilename}}% |
| 150 |
\@mpm@do@include |
| 151 |
\else |
| 152 |
\includegraphics{\@mpmfilename}% |
| 153 |
\fi% |
| 154 |
\@mpm@endospec% |
| 155 |
}% |
| 156 |
\ifnum\@mpm@count<\@mpm@end\relax |
| 157 |
\advance\@mpm@count by 1\relax |
| 158 |
\let\@mpmnext\@mpmdoit |
| 159 |
\else |
| 160 |
\let\@mpmnext\relax |
| 161 |
\fi |
| 162 |
}{% |
| 163 |
%% If no more files exist, set up to stop. |
| 164 |
\let\@mpmnext\relax |
| 165 |
}% |
| 166 |
%% Whatever we had to do (without nesting all the IfFileExists) |
| 167 |
\@mpmnext |
| 168 |
}% |
| 169 |
%% Finally we must start it once, if there is more than one file |
| 170 |
%% supposed to be available. |
| 171 |
\ifnum\@mpm@count<\@mpm@end\relax |
| 172 |
\advance\@mpm@count by 1\relax % start counting |
| 173 |
\@mpmdoit % and run the show |
| 174 |
\fi |
| 175 |
%% and reset the input path after all |
| 176 |
\let\input@path\@mpm@oldinp@th |
| 177 |
}% |