summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/pstool
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-02-12 23:54:13 +0000
committerKarl Berry <karl@freefriends.org>2013-02-12 23:54:13 +0000
commit4abc207ecf013eb27bf9f83c29b8a82408c9cd71 (patch)
treee1a1b49730e7671d00a966b4ea9b008ac8f981b3 /Master/texmf-dist/tex/latex/pstool
parentb00ddd78e03236a73df3113f75cb0c607654d5a6 (diff)
pstool (12feb13)
git-svn-id: svn://tug.org/texlive/trunk@29091 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/pstool')
-rw-r--r--Master/texmf-dist/tex/latex/pstool/pstool.sty413
1 files changed, 284 insertions, 129 deletions
diff --git a/Master/texmf-dist/tex/latex/pstool/pstool.sty b/Master/texmf-dist/tex/latex/pstool/pstool.sty
index 9de88ff656b..37f31108ec6 100644
--- a/Master/texmf-dist/tex/latex/pstool/pstool.sty
+++ b/Master/texmf-dist/tex/latex/pstool/pstool.sty
@@ -1,23 +1,35 @@
-%% LaTeX2e file `pstool.sty'
-%% generated by the `filecontents' environment
-%% from source `pstool' on 2009/07/21.
-%%
-\ProvidesPackage{pstool}[2009/07/17 v1.3
+% TODO: convert this package into expl3 syntax (will save many lines of code).
+
+\ProvidesPackage{pstool}[2013/02/11 v1.5
Wrapper for processing PostScript/psfrag figures]
-% External packages
-\RequirePackage{%
- catchfile,color,ifpdf,ifplatform,
- graphicx,pdftexcmds,psfrag,suffix,xkeyval}
+% External packages:
+\RequirePackage{
+ catchfile,color,ifpdf,ifplatform,filemod,
+ graphicx,psfrag,suffix,trimspaces,xkeyval,expl3
+}
+
+% Add an additional command before trimspaces.sty is updated formally:
+\providecommand*{\trim@multiple@spaces@in}[1]{%
+ \let\trim@temp#1%
+ \trim@spaces@in#1%
+ \ifx\trim@temp#1%
+ \else
+ \expandafter\trim@multiple@spaces@in\expandafter#1%
+ \fi
+}
+
+% \subsection{Allocations}
+\expandafter\newif\csname if@pstool@pdfcrop@\endcsname
+\expandafter\newif\csname if@pstool@verbose@\endcsname
+\expandafter\newif\csname if@pstool@write@aux\endcsname
-% Allocations
-\newif\if@pstool@pdfcrop@
-\newif\if@pstool@verbose@
\newwrite\pstool@out
+\newread\pstool@mainfile@ior
+\newread\pstool@auxfile@ior
-% These are cute
-\providecommand\OnlyIfFileExists[2]{\IfFileExists{#1}{#2}{}}
-\providecommand\NotIfFileExists[2]{\IfFileExists{#1}{}{#2}}
+% Macro used to store the name of the graphic's macro file:
+\let\pstool@tex\@empty
% \subsection{Package options}
@@ -47,51 +59,63 @@
\ExecuteOptionsX{mode=batch}
\DeclareOptionX{cleanup}{\def\pstool@rm@files{#1}}
-\ExecuteOptionsX{cleanup={.tex,.dvi,.ps,.pdf,.log,.aux}}
+\ExecuteOptionsX{cleanup={.tex,.dvi,.ps,.pdf,.log}}
\DeclareOptionX{suffix}{\def\pstool@suffix{#1}}
\ExecuteOptionsX{suffix={-pstool}}
-% There is an implicit |\space| after the bitmap options.
+% There is an implicit \cs{space} after the bitmap options.
\define@choicekey*{pstool.sty}{bitmap}
[\@tempa\@tempb]{auto,lossless,lossy}{%
\ifcase\@tempb
\let\pstool@bitmap@opts\@empty
\or
\def\pstool@bitmap@opts{%
- "-dAutoFilterColorImages=false"
- "-dAutoFilterGrayImages=false"
- "-dColorImageFilter=/FlateEncode"
- "-dGrayImageFilter=/FlateEncode" % space
+ -dAutoFilterColorImages=false
+ -dAutoFilterGrayImages=false
+ -dColorImageFilter=/FlateEncode
+ -dGrayImageFilter=/FlateEncode % space
}
\or
\def\pstool@bitmap@opts{%
- "-dAutoFilterColorImages=false"
- "-dAutoFilterGrayImages=false"
- "-dColorImageFilter=/DCTEncode"
- "-dGrayImageFilter=/DCTEncode" % space
+ -dAutoFilterColorImages=false
+ -dAutoFilterGrayImages=false
+ -dColorImageFilter=/DCTEncode
+ -dGrayImageFilter=/DCTEncode % space
}
\fi
}
\ExecuteOptionsX{bitmap=lossless}
-% \HideAllDefining
-% \Define*{latex-options}
-% \Define*{dvips-options}
-% \Define*{ps2pdf-options}
-% \Define*{pdfcrop-options}
\DeclareOptionX{latex-options}{\def\pstool@latex@opts{#1}}
\DeclareOptionX{dvips-options}{\def\pstool@dvips@opts{#1}}
\DeclareOptionX{ps2pdf-options}{\def\pstool@pspdf@opts{#1}}
\DeclareOptionX{pdfcrop-options}{\def\pstool@pdfcrop@opts{#1}}
-% \ResumeAllDefining
+
\ExecuteOptionsX{
latex-options={},
dvips-options={},
- ps2pdf-options={"-dPDFSETTINGS=/prepress"},
+ ps2pdf-options={-dPDFSETTINGS=/prepress},
pdfcrop-options={}
}
+\DeclareOptionX{macro-file}{%
+ \IfFileExists{#1}
+ {\def\pstool@macrofile{#1}}
+ {%
+ \let\pstool@macrofile\@empty
+ \PackageError{pstool}{^^J\space\space%
+ No file `#1' found for "macro-file" package option.^^J
+ This warning occurred}
+ }
+}
+
+% Default:
+\IfFileExists{\jobname-pstool.tex}
+ {\edef\pstool@macrofile{\jobname-pstool.tex}}
+ {\let\pstool@macrofile\@empty}
+
+
\ifpdf
\ifshellescape\else
\ExecuteOptionsX{process=none}
@@ -110,10 +134,9 @@
}
% \section{Macros}
-
% Used to echo information to the console output.
-% Can't use |\typeout| because it's asynchronous with
-% any |\immediate\write18| processes (for some reason).
+% Can't use \cs{typeout} because it's asynchronous with
+% any \cs{immediate}\cs{write18} processes (for some reason).
\def\pstool@echo#1{%
\if@pstool@verbose@
\pstool@echo@verbose{#1}%
@@ -129,29 +152,32 @@
% Command line abstractions between platforms:
\edef\pstool@cmdsep{\ifwindows\string&\else\string;\fi\space}
\edef\pstool@rm@cmd{\ifwindows del \else rm -- \fi}
+\edef\pstool@cp@cmd{\ifwindows copy \else cp -- \fi}
-% Delete a file if it exists:\\
-% |#1|: path\\
-% |#2|: filename
+% Delete a file if it exists:
+% #1: path
+% #2: filename
\newcommand\pstool@rm[2]{%
- \OnlyIfFileExists{#1#2}{%
+ \IfFileExists{#1#2}{%
\immediate\write18{%
cd "#1"\pstool@cmdsep\pstool@rm@cmd "#2"
}%
- }%
+ }{}%
}
% Generic function to execute a command on the shell and pass its exit status back into \LaTeX. Any number of \cmd\pstool@exe\ statements can be made consecutively followed by \cmd\pstool@endprocess, which also takes an argument. If \emph{any} of the shell calls failed, then the execution immediately skips to the end and expands \cmd\pstool@error\ instead of the argument to \cmd\pstool@endprocess.
-%
-% |#1|: `name' of process\\
-% |#2|: relative path where to execute the command\\
-% |#3|: the command itself
+% #1: `name' of process
+% #2: relative path where to execute the command
+% #3: the command itself
\newcommand\pstool@exe[3]{%
\pstool@echo{^^J=== pstool: #1 ===}%
\pstool@shellexecute{#2}{#3}%
\pstool@retrievestatus{#2}%
\ifnum\pstool@status > \z@
- \PackageWarning{pstool}{Execution failed during process:^^J\space\space#3^^JThis warning occurred}%
+ \PackageWarning{pstool}{%
+ Execution failed during process:^^J\space\space
+ #3^^JThis warning occurred%
+ }%
\expandafter\pstool@abort
\fi
}
@@ -160,9 +186,18 @@
\def\pstool@error{%
\fbox{%
\parbox{0.8\linewidth}{%
- \color{red}\raggedright\ttfamily\scshape\small
- An error occured processing graphic
- \upshape`\pstool@path\pstool@filestub'%
+ \color{red}\centering\ttfamily\scshape\small
+ An error occured processing graphic:\\
+ \upshape`%
+ \detokenize\expandafter{\pstool@path}%
+ \detokenize\expandafter{\pstool@filestub}.eps%
+ '\\\bigskip
+ \tiny
+ Check the log file for compilation errors:\\
+ `%
+ \detokenize\expandafter{\pstool@path}%
+ \detokenize\expandafter{\pstool@filestub}-pstool.log%
+ '\\
}%
}%
}
@@ -170,7 +205,7 @@
\def\pstool@abort#1\pstool@endprocess{\pstool@error\@gobble}
\let\pstool@endprocess\@firstofone
-% It is necessary while executing commands on the shell to write the exit status to a temporary file to test for failures in processing. (If all versions of |pdflatex| supported input pipes, things might be different.)
+% It is necessary while executing commands on the shell to write the exit status to a temporary file to test for failures in processing. (If all versions of \texttt{pdflatex} supported input pipes, things might be different.)
\def\pstool@shellexecute#1#2{%
\immediate\write18{%
cd "#1" \pstool@cmdsep
@@ -190,8 +225,8 @@
}
\def\pstool@statusfile{pstool-statusfile.txt}
-% Read the exit status from the temporary file and delete it.\\
-% |#1| is the path\\
+% Read the exit status from the temporary file and delete it.
+% #1 is the path
% Status is recorded in \cmd\pstool@status.
\def\pstool@retrievestatus#1{%
\CatchFileEdef{\pstool@status}{#1\pstool@statusfile}{}%
@@ -205,17 +240,6 @@
}
\def\pstool@statusfail{\par }% what results when \TeX\ reads an empty file
-% \subsection{File age detection}
-\def\pstool@IfnewerEPS{%
- \ifnum\pdf@strcmp{\pdf@filemoddate{\pstool@path\pstool@filestub.pdf}}
- {\pdf@filemoddate{\pstool@path\pstool@filestub.eps}}
- < \z@
- \expandafter\@firstoftwo
- \else
- \expandafter\@secondoftwo
- \fi
-}
-
% Grab filename and filepath. Always need a relative path to a filename even if it's in the same directory.
\def\pstool@getpaths#1{%
\filename@parse{#1}%
@@ -227,8 +251,13 @@
\let\pstool@filestub\filename@base
}
+% The filename of the figure stripped of its path, if any:
+% (analogous to standard \cs{jobname})
+\def\pstool@jobname{\pstool@filestub\pstool@suffix}
+
+
% \section{Command parsing}
-% User input is \cmd\pstool\ (with optional |*| or |!| suffix) which turns into one of the following three macros depending on the mode.
+% User input is \cmd\pstool\ (with optional \texttt{*} or \texttt{!} suffix) which turns into one of the following three macros depending on the mode.
\newcommand\pstool@alwaysprocess[3][]{%
\pstool@getpaths{#2}%
@@ -249,23 +278,50 @@
}
\fi
-% For regular operation, which processes the figure only if
-% the command is starred, or the PDF doesn't exist.
-\newcommand\pstool@maybeprocess[3][]{%
- \pstool@getpaths{#2}%
- \IfFileExists{#2.pdf}{%
- \pstool@IfnewerEPS{% needs info from |\pstool@getpaths|
- \pstool@process{#1}{#3}%
- }{%
- \pstool@includegraphics{#2}%
- }%
- }{%
- \pstool@process{#1}{#3}%
- }%
-}
+% Process the figure when:
+% -- the PDF file doesn't exist, or
+% -- the EPS is newer than the PDF, or
+% -- the TeX file is new than the PDF.
+\ExplSyntaxOn
+\newcommand\pstool@maybeprocess[3][]
+ {
+ \pstool_if_should_process:nTF {#2}
+ { \pstool@process{#1}{#3} }
+ { \pstool@includegraphics{#2} }
+ }
+
+\prg_set_conditional:Nnn \pstool_if_should_process:n {TF}
+ {
+ \pstool@getpaths{#1}
+
+ \file_if_exist:nF { #1.pdf }
+ { \use_i_delimit_by_q_stop:nw \prg_return_true: }
+
+ \filemodCmp {\pstool@path\pstool@filestub.eps}
+ {\pstool@path\pstool@filestub.pdf}
+ { \use_i_delimit_by_q_stop:nw \prg_return_true: } {}
+
+ \exp_args:Nx \clist_map_inline:nn { \pstool@macrofile , \pstool@tex }
+ % empty entries are ignored in clist mappings, so no need to filter here
+ {
+ \filemodCmp {##1} {\pstool@path\pstool@filestub.pdf}
+ {
+ \clist_map_break:n { \use_i_delimit_by_q_stop:nw \prg_return_true: }
+ }
+ {}
+ }
+
+ \filemodCmp {\pstool@path\pstool@filestub.tex}
+ {\pstool@path\pstool@filestub.pdf}
+ { \use_i_delimit_by_q_stop:nw \prg_return_true: } {}
+
+ \use_i_delimit_by_q_stop:nw \prg_return_false:
+ \q_stop
+ }
+\ExplSyntaxOff
% \section{User commands}
-% Finally, define \cmd\pstool\ as appropriate for the mode: (|all|, |none|, |auto|, respectively)
+% Finally, define \cmd\pstool\ as appropriate for the mode: (\texttt{all}, \texttt{none}, \texttt{auto}, respectively)
\ifpdf
\newcommand\pstool{%
\ifcase\pstool@process@choice\relax
@@ -296,9 +352,6 @@
% \section{The figure processing}
-% \cmd\pstool@filestub\ is the filename of the figure stripped of its path (if any)
-\def\pstool@jobname{\pstool@filestub\pstool@suffix}
-
% And this is the main macro.
\newcommand\pstool@process[2]{%
\begingroup
@@ -315,10 +368,14 @@
-interaction=\pstool@mode\space
\pstool@latex@opts\space
"\pstool@jobname.tex"}%
-% Execute |dvips| in quiet mode if |latex| is not run in (non/error)stop mode:
+% Execute \texttt{dvips} in quiet mode if \texttt{latex} is not run in (non/error)stop mode:
\pstool@exe{dvips}{\pstool@path}{%
dvips \if@pstool@verbose@\else -q \fi -Ppdf
\pstool@dvips@opts\space "\pstool@jobname.dvi"}%
+% Pre-process \texttt{ps2pdf} options for Windows (sigh):
+ \pstool@pspdf@opts@preprocess \pstool@bitmap@opts
+ \pstool@pspdf@opts@preprocess \pstool@pspdf@opts
+% Generate the PDF:
\if@pstool@pdfcrop@
\pstool@exe{ps2pdf}{\pstool@path}{%
ps2pdf \pstool@bitmap@opts \pstool@pspdf@opts \space
@@ -331,53 +388,149 @@
ps2pdf \pstool@bitmap@opts \pstool@pspdf@opts \space
"\pstool@jobname.ps" "\pstool@filestub.pdf"}%
\fi
+% Finish up: (implies success!)
\pstool@endprocess{%
\pstool@cleanup
- \pstool@includegraphics{%
- \pstool@path\pstool@filestub}%
+ \pstool@includegraphics{\pstool@path\pstool@filestub}%
+% Emulate \cs{include} (sort of) and have the main document load the auxiliary aux file, in a manner of speaking:
+ \pstool@write@aux
}%
\pstool@echo@verbose{^^J=== pstool: end processing ===^^J}%
\endgroup
}
+\newcommand\pstool@write@aux{%
+ \endlinechar=-1
+ \@tempswatrue
+ \@pstool@write@auxfalse
+ \in@false
+ \openin \pstool@auxfile@ior "\pstool@path\pstool@jobname.aux"\relax
+ \@whilesw \if@tempswa \fi {%
+ \readline \pstool@auxfile@ior to \@tempa
+ \ifeof \pstool@auxfile@ior
+ \@tempswafalse
+ \else
+ \edef\@tempb{\detokenize\expandafter{\pstool@auxmarker@text/}}%
+ \ifx\@tempa\@tempb
+ \@tempswafalse
+ \else
+ \if@pstool@write@aux
+ \immediate\write\@mainaux{\unexpanded\expandafter{\@tempa}}%
+ \fi
+ \edef\@tempb{\detokenize\expandafter{\pstool@auxmarker@text*}}%
+ \ifx\@tempa\@tempb
+ \@pstool@write@auxtrue
+ \fi
+ \fi
+ \fi
+ }
+ \closein \pstool@auxfile@ior
+}
+
+\ExplSyntaxOn
+\cs_new:Npn \pstool@pspdf@opts@preprocess #1
+ {
+ \ifwindows
+ \exp_args:NNnx \tl_replace_all:Nnn #1 {=} { \cs_to_str:N \# }
+ \fi
+ }
+\ExplSyntaxOff
+
+% For what's coming next.
+\edef\@begindocument@str{\detokenize\expandafter{\string\begin{document}}}
+\edef\@endpreamble@str{\string\EndPreamble}
+\def\in@first#1#2{\in@{NEVEROCCUR!#1}{NEVEROCCUR!#2}}
+
+% We need to cache the aux file, so here goes.
+% This is because the aux file is cleared for writing after \cs{begin{document}}.
+\IfFileExists{\jobname.oldaux}{\immediate\write18{\pstool@rm@cmd \jobname.oldaux}}{}
+\immediate\write18{\pstool@cp@cmd \jobname.aux \jobname.oldaux}
+\AtEndDocument{\immediate\write18{\pstool@rm@cmd \jobname.oldaux}}
+
+\edef\pstool@auxmarker#1{\string\@percentchar\space <#1PSTOOLLABELS>}
+\edef\pstool@auxmarker@text#1{\@percentchar <#1PSTOOLLABELS>}
+
% The file that is written for processing is set up to read the preamble of the original document and set the graphic on an empty page (cropping to size is done either here with \pkg{preview} or later with \pkg{pdfcrop}).
\def\pstool@write@processfile#1#2#3{%
+% Put down a label so we can pass through the current page number:
+ \edef\pstool@label{pstool-\pstool@path\pstool@filestub}%
+ \protected@write\@auxout{}%
+ {\string\newlabel{\pstool@label}{{\@currentlabel}{\the\c@page}}}%
\immediate\openout\pstool@out #2\pstool@suffix.tex\relax
- \immediate\write\pstool@out{%
-% Input the main document; redefine the document environment so only the preamble is read:
- \unexpanded{%
- \pdfoutput=0^^J% force DVI mode if not already
- \let\origdocument\document^^J%
- \let\EndPreamble\endinput^^J%
- \def\document{\endgroup\endinput}^^J%
- }%
- \noexpand\input{\jobname}^^J%
+% And copy the main file's bbl file too:
+% (necessary for biblatex)
+ \IfFileExists{\jobname.bbl}{%
+ \IfFileExists{\pstool@path\pstool@jobname.bbl}{%
+ \immediate\write18{\pstool@rm@cmd \pstool@path\pstool@jobname.bbl}%
+ }{}%
+ }{}%
+\immediate\write18{\pstool@cp@cmd \jobname.bbl \pstool@path\pstool@jobname.bbl}%
+%
+% Scan the main document line by line; print preamble into auxiliary file until the document begins or \cs{EndPreamble} is found:
+ \endlinechar=-1
+ \def\@tempa{\pdfoutput=0\relax}%
+ \in@false
+ \openin\pstool@mainfile@ior "\jobname"\relax
+ \@whilesw \unless\ifin@ \fi {%
+ \immediate\write\pstool@out{\unexpanded\expandafter{\@tempa}}%
+ \readline\pstool@mainfile@ior to\@tempa
+ \let\@tempc\@tempa
+ \trim@multiple@spaces@in\@tempa
+ \expandafter\expandafter\expandafter\in@first
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@begindocument@str
+ \expandafter}%
+ \expandafter{\@tempa}%
+ \unless\ifin@
+ \expandafter\expandafter\expandafter\in@first
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@endpreamble@str
+ \expandafter}%
+ \expandafter{\@tempa}%
+ \fi
+ }
+ \closein\pstool@mainfile@ior
%
-% Now the preamble of the process file: (restoring document's original meaning; empty \cmd\pagestyle\ removes the page number)
+% Now the preamble of the process file:
+ \immediate\write\pstool@out{%
\if@pstool@pdfcrop@\else
\noexpand\usepackage[active,tightpage]{preview}^^J%
\fi
\unexpanded{%
- \let\document\origdocument^^J%
- \pagestyle{empty}^^J%
+ \pagestyle{empty}^^J^^J% remove the page number
}%
+ \noexpand\makeatletter^^J%
+% Sort out the page numbering:
+ \expandafter\ifx\csname r@\pstool@label\endcsname\relax\else
+ \def\noexpand\thepage{\unexpanded\expandafter{\thepage}}^^J%
+ \noexpand\setcounter{page}{%
+ \expandafter\expandafter\expandafter
+ \@secondoftwo\csname r@\pstool@label\endcsname
+ }^^J%
+ \fi
%
% And the document body to place the graphic on a page of its own:
+ \noexpand\@input{\jobname.oldaux}^^J^^J%
+ \noexpand\begin{document}^^J%
+ \unexpanded{\immediate\write\@mainaux}{\pstool@auxmarker*}^^J%
+ \noexpand\makeatother^^J%
\unexpanded{%
- \begin{document}^^J%
\centering\null\vfill^^J%
}%
+ ^^J%
\if@pstool@pdfcrop@\else
\noexpand\begin{preview}^^J%
\fi
- \unexpanded{#3^^J}% this is the "psfrag" material
+ \unexpanded{#3^^J}
\noexpand\includegraphics
[\unexpanded\expandafter{\XKV@rm}]
{\pstool@filestub}^^J%
\if@pstool@pdfcrop@\else
\noexpand\end{preview}^^J%
\fi
- \unexpanded{\vfill\end{document}}^^J%
+ ^^J%
+ \unexpanded{\vfill^^J^^J\makeatletter^^J\immediate\write\@mainaux}{\pstool@auxmarker/}^^J%
+ \unexpanded{\makeatother^^J\end{document}}^^J%
}%
\immediate\closeout\pstool@out
}
@@ -391,10 +544,9 @@
\providecommand\EndPreamble{}
% \section{User commands}
-%
-% These all support the suffixes |*| and |!|, so each user command is defined as a wrapper to \cmd\pstool.
+% These all support the suffixes \texttt{*} and \texttt{!}, so each user command is defined as a wrapper to \cmd\pstool.
-% for EPS figures with psfrag:
+% For EPS figures with psfrag:
\newcommand\psfragfig[2][]{\pstool@psfragfig{#1}{#2}{}}
\WithSuffix\newcommand\psfragfig*[2][]{%
\pstool@psfragfig{#1}{#2}{*}%
@@ -403,7 +555,7 @@
\pstool@psfragfig{#1}{#2}{!}%
}
-% Parse optional \<input definitions>
+% Parse optional input definitions:
\newcommand\pstool@psfragfig[3]{%
\@ifnextchar\bgroup{%
\pstool@@psfragfig{#1}{#2}{#3}%
@@ -412,19 +564,21 @@
}%
}
-% Search for both \<filename> and \<filename>|-psfrag| inputs.
+% Search for both `filename' and `filename'-psfrag inputs.
%
-% |#1|: possible graphicx options\\
-% |#2|: graphic name (possibly with path)\\
-% |#3|: |\pstool| suffix (i.e., |!| or |*| or \<empty>)\\
-% |#4|: possible \pkg{psfrag} (or other) macros
+% #1: possible graphicx options
+% #2: graphic name (possibly with path)
+% #3: \cs{pstool} suffix (i.e., \texttt{!} or \texttt{*} or `empty')
+% #4: possible \pkg{psfrag} (or other) macros
\newcommand\pstool@@psfragfig[4]{%
% Find the .eps file to use.
\IfFileExists{#2-psfrag.eps}{%
\edef\pstool@eps{#2-psfrag}%
- \OnlyIfFileExists{#2.eps}{%
- \PackageWarning{pstool}{Graphic "#2.eps" exists but "#2-psfrag.eps" is being used}%
- }%
+ \IfFileExists{#2.eps}{%
+ \PackageWarning{pstool}{%
+ Graphic "#2.eps" exists but "#2-psfrag.eps" is being used%
+ }%
+ }{}%
}{%
\IfFileExists{#2.eps}{%
\edef\pstool@eps{#2}%
@@ -439,38 +593,39 @@
% Find the .tex file to use.
\IfFileExists{#2-psfrag.tex}{%
\edef\pstool@tex{#2-psfrag.tex}%
- \OnlyIfFileExists{#2.tex}{%
+ \IfFileExists{#2.tex}{%
\PackageWarning{pstool}{%
File "#2.tex" exists that may contain macros
for "\pstool@eps.eps"^^J%
But file "#2-psfrag.tex" is being used instead.%
}%
- }%
+ }{}%
}{%
\IfFileExists{#2.tex}{%
\edef\pstool@tex{#2.tex}%
}{%
- \let\pstool@tex\@empty
\PackageWarning{pstool}{%
No file "#2.tex" or "#2-psfrag.tex" can be found
that may contain macros for "\pstool@eps.eps"%
}%
}%
}%
- \ifx\pstool@tex\@empty
- \pstool#3[#1]{\pstool@eps}{#4}%
- \else
- \expandafter\pstool@@@psfragfig
- \expandafter{\pstool@tex}{#3[#1]}{#4}%
+ % Perform the actual processing step, skipping it entirely if an EPS file hasn't been found.
+ % (In which case an error would have been called above; this is to clean up nicely in scrollmode, for example.)
+ \ifx\pstool@eps\@undefined\else
+ \edef\@tempa{%
+ \unexpanded{\pstool#3[#1]}{\pstool@eps}{%
+ \ifx\pstool@macrofile\@empty\else
+ \@percentchar Input main macro file:^^J
+ \unexpanded{\csname @input\endcsname}{\pstool@macrofile}%
+ \fi
+ \ifx\pstool@tex\@empty\else
+ \@percentchar Input macro file for this graphic:^^J
+ \unexpanded{\csname @input\endcsname}{\pstool@tex}%
+ \fi
+ \unexpanded{#4}%
+ }%
+ }\@tempa
\fi
}
-
-% Break out the separate function in order to expand |\pstool@tex| before writing it.
-\newcommand\pstool@@@psfragfig[3]{%
- \pstool#2{\pstool@eps}{%
- \csname @input\endcsname{#1}%
- #3%
- }%
-}
-
-% That's it.
+% \centerline{\itshape ---The End---}