1%% mpmulti.sty 09 Sep 2002 2%%------------------------------------------------------------ 3%% History: 4%% Initial version 14 Apr 2000 5%% Introduced keyword parameters 12 Jun 2000 6%% Introduced new parameters (start,format), changed the 7%% global code to take several file counting strings (eg 8%% bla-*.mps, foo-*.jpg, etc.), added compatibility with 9%% \graphicspath (Jean-Christophe Dubacq) 06 Dec 2001 10%% Generalized the format option, added the end 11%% handling and documented extended features in here 12%% 09 Sep 2002 13%% 14%% Purpose: 15%% include multiple metapost pictures and overlay them, 16%% inserting a transition effect between them 17%% 18%% Synopsis: 19%% 20%% \multiinclude[pause=transitioncommand, 21%% graphics={option for includegraphics}, 22%% format=filenameformat, 23%% start=number, 24%% end=number]{basefilename} 25%% 26%% Include all metapost generated graphics found in 27%% files with the basename "filename", which 28%% have a number attached or in the extension. 29%% Insert the transitioncommand between the files (defaults 30%% to \pause). 31%% Further options allow to specify additional specifications 32%% for includegraphics, can change the number to start with 33%% (default 0) or the number to end with (default 1000000). 34%% By default the filenames are as created by mpost in the format 35%% "filename.n", where "n" represents the number. 36%% The option format with the values like "mps", "png" or "jpg" this 37%% can be changed to "filename-n.format", e.g. "example-0.mps" 38%% instead of "example.0". 39%% Complaints are only written, if the first file is not found. 40%% Otherwise including will silently stop. 41%% 42%% Requires: 43%% pause.sty for definitions of transition commands. 44%% The keyval package for options processing. 45%% 46%% 47\RequirePackage{pause} 48\RequirePackage{keyval} 49%% 50%% The command should process the optional arguments. 51%% 52\def\multiinclude{% 53 \@ifnextchar [\@mpmulti{\@mpmulti[]}} 54%% 55\newif\if@mpm@groptions\@mpm@groptionsfalse 56%% We describe the keys and their default values 57\define@key{mpm}{format}[\@mpm@defaultformat]{% 58 \global\def\@mpm@format##1{##1-\the\@mpm@count.#1}} 59\define@key{mpm}{start}[0]{\global\def\@mpm@start{#1}\relax} 60\define@key{mpm}{end}[1000000]{\global\def\@mpm@end{#1}\relax} 61\define@key{mpm}{pause}[\pause]{\global\def\@mpm@pause{#1}\relax} 62\define@key{mpm}{graphics}{\@mpm@groptionstrue 63 \global\def\@mpm@graphics{\string#1}} 64\def\@mpm@defaultformat#1{#1.\the\@mpm@count} 65\let\@mpm@format=\@mpm@defaultformat 66%% 67%% We need a local counter 68%% 69\newcount\@mpm@count 70%% 71%% Implement the basic functionality. 72%% Try to include the first file unconditionally. 73%% This will produce an error message, if no such file can be found. 74%% Afterwards we are going to check for more files and stop, when we 75%% do not find another file. As long as we find files, these are 76%% overlapped to the previous parts. 77%% 78\def\@mpmulti[#1]#2{% 79 %% reset the options 80 \def\@mpm@pause{\pause}% 81 \global\def\@mpm@graphics{}% 82 \global\def\@mpm@start{0}% 83 \global\def\@mpm@end{1000000}% 84 %% get the arguments 85 \setkeys{mpm}{#1}% 86 %% Insert the first part of the figure 87 %% and make sure we look also in other places according to path. 88 \let\@mpm@oldinp@th\input@path\let\input@path\Ginput@path 89 \@mpm@count=\@mpm@start 90 \if@mpm@groptions 91 \edef\@mpm@do@include{\noexpand\includegraphics[\@mpm@graphics]{\@mpm@format{#2}}}% 92 \@mpm@do@include 93 \else 94 \includegraphics{\@mpm@format{#2}}% 95 \fi 96 \def\@mpmdoit{% Do it by conditional tail recursion. 97 %% Select the next filename and advance counter 98 \edef\@mpmfilename{\@mpm@format{#2}}% 99 %% If the file exists, 100 \IfFileExists{\@mpmfilename}{% 101 %% insert the user defined transition (or the default), 102 \@mpm@pause 103 %% then process the next part and set up to try again. 104 \llap{\if@mpm@groptions 105 \edef\@mpm@do@include{\noexpand 106 \includegraphics[\@mpm@graphics]{\@mpmfilename}}% 107 \@mpm@do@include 108 \else 109 \includegraphics{\@mpmfilename}% 110 \fi}% 111 \ifnum\@mpm@count<\@mpm@end\relax 112 \advance\@mpm@count by 1\relax 113 \let\@mpmnext\@mpmdoit 114 \else 115 \let\@mpmnext\relax 116 \fi 117 }{% 118 %% If no more files exist, set up to stop. 119 \let\@mpmnext\relax 120 }% 121 %% Whatever we had to do (without nesting all the IfFileExists) 122 \@mpmnext 123 }% 124 %% Finally we must start it once, if there is more than one file 125 %% supposed to be available. 126 \ifnum\@mpm@count<\@mpm@end\relax 127 \advance\@mpm@count by 1\relax % start counting 128 \@mpmdoit % and run the show 129 \fi 130 %% and reset the input path after all 131 \let\input@path\@mpm@oldinp@th 132}% 133