summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2018-01-21 00:44:09 +0000
committerKarl Berry <karl@freefriends.org>2018-01-21 00:44:09 +0000
commitbae071d030d13f63f51e6d6d302f99e5e80a9551 (patch)
treecd631b8872f1ad4fa26163253b7a85b6a7994516 /Master/texmf-dist/tex
parentd45eeb3d3b93472277ffe2d7029a60fe360188b2 (diff)
pstool (20jan18)
git-svn-id: svn://tug.org/texlive/trunk@46393 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/latex/pstool/pstool.sty110
1 files changed, 75 insertions, 35 deletions
diff --git a/Master/texmf-dist/tex/latex/pstool/pstool.sty b/Master/texmf-dist/tex/latex/pstool/pstool.sty
index 19a1f996df1..e171cdaa6dd 100644
--- a/Master/texmf-dist/tex/latex/pstool/pstool.sty
+++ b/Master/texmf-dist/tex/latex/pstool/pstool.sty
@@ -1,7 +1,18 @@
-% TODO: convert this package into expl3 syntax (will save many lines of code).
+%% PSTOOL.STY
+%
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either
+% version 1.3c or (at your option) any later version.
+% The latest version of this license is in:
+% <http://www.latex-project.org/lppl.txt>
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is Will Robertson.
+
+\ProvidesPackage{pstool}[2018/01/20 v1.5e Wrapper for processing PostScript/psfrag figures]
-\ProvidesPackage{pstool}[2017/10/13 v1.5d
- Wrapper for processing PostScript/psfrag figures]
+% TODO: convert this package into expl3 syntax (will save many lines of code).
% External packages:
\RequirePackage{
@@ -10,19 +21,20 @@
}
% 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
+\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
+\expandafter\newif\csname if@pstool@crossref@\endcsname
+\expandafter\newif\csname if@pstool@has@written@aux\endcsname
\newwrite\pstool@out
\newread\pstool@mainfile@ior
@@ -60,6 +72,7 @@
\DeclareOptionX{cleanup}{%
\edef\pstool@rm@files{\zap@space #1 \@empty}%
+ \if@pstool@crossref@
\@for\@ii:=\pstool@rm@files\do{%
\edef\@tempa{\@ii}%
\def\@tempb{.aux}%
@@ -69,10 +82,23 @@
Cross-referencing within pstool graphics therefore disabled.^^J%
This warning occurred}
\fi
- }
+ }%
+ \fi
}
\ExecuteOptionsX{cleanup={.tex,.dvi,.ps,.pdf,.log}}
+\define@choicekey*{pstool.sty}{crossref}[\@tempa\@tempb]{false,true}{%
+ \ifcase\@tempb\relax
+ \@pstool@crossref@false
+ \or
+ \@pstool@crossref@true
+ \or
+ \fi
+}
+\@onlypreamble\@pstool@crossref@true
+\@onlypreamble\@pstool@crossref@false
+\ExecuteOptionsX{crossref=true}
+
\DeclareOptionX{suffix}{\def\pstool@suffix{#1}}
\ExecuteOptionsX{suffix={-pstool}}
@@ -324,7 +350,7 @@
\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
{
@@ -334,7 +360,7 @@
}
{}
}
-
+
\filemodCmp {\pstool@path\pstool@filestub.tex}
{\pstool@path\pstool@filestub.pdf}
{ \use_i_delimit_by_q_stop:nw \prg_return_true: } {}
@@ -394,7 +420,7 @@
"\pstool@jobname.tex"}%
% 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
+ 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
@@ -416,7 +442,9 @@
\pstool@endprocess{%
\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
+ \if@pstool@crossref@
+ \pstool@write@aux
+ \fi
\pstool@cleanup
}%
\pstool@echo@verbose{^^J=== pstool: end processing ===^^J}%
@@ -425,12 +453,12 @@
\newcommand\pstool@write@aux{%
\endlinechar=-1\relax
- \@tempswatrue
- \@pstool@write@auxfalse
+ \@tempswatrue
+ \@pstool@has@written@auxfalse
\in@false
- \openin \pstool@auxfile@ior "\pstool@path\pstool@jobname.aux"\relax
+ \openin \pstool@auxfile@ior "\pstool@path\pstool@jobname.aux"\relax
\@whilesw \if@tempswa \fi {%
- \readline \pstool@auxfile@ior to \@tempa
+ \readline \pstool@auxfile@ior to \@tempa
\ifeof \pstool@auxfile@ior
\@tempswafalse
\else
@@ -438,17 +466,17 @@
\ifx\@tempa\@tempb
\@tempswafalse
\else
- \if@pstool@write@aux
+ \if@pstool@has@written@aux
\immediate\write\@mainaux{\unexpanded\expandafter{\@tempa}}%
\fi
\edef\@tempb{\detokenize\expandafter{\pstool@auxmarker@text*}}%
\ifx\@tempa\@tempb
- \@pstool@write@auxtrue
+ \@pstool@has@written@auxtrue
\fi
\fi
\fi
}%
- \closein \pstool@auxfile@ior
+ \closein \pstool@auxfile@ior
}
\ExplSyntaxOn
@@ -465,8 +493,7 @@
\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}}.
+% We need to cache the aux file, since it is cleared for writing after \cs{begin{document}}.
\ifpdf
\pstool@rm{}{\jobname.oldaux}
\pstool@cp{}{\jobname.aux}{\jobname.oldaux}
@@ -480,20 +507,22 @@
\def\pstool@write@processfile#1#2#3{%
\immediate\openout\pstool@out #2\pstool@suffix.tex\relax
% 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}}}%
+ \if@pstool@crossref@
+ \edef\pstool@label{pstool-\pstool@path\pstool@filestub}%
+ \protected@write\@auxout{}%
+ {\string\newlabel{\pstool@label}{{\@currentlabel}{\the\c@page}}}%
% And copy the main file's bbl file too: (necessary only for biblatex but do it always)
- \pstool@rm{\pstool@path}{\pstool@jobname.bbl}%
- \pstool@cp{}{\jobname.bbl}{\pstool@path\pstool@jobname.bbl}%
+ \pstool@rm{\pstool@path}{\pstool@jobname.bbl}%
+ \pstool@cp{}{\jobname.bbl}{\pstool@path\pstool@jobname.bbl}%
+ \fi
% Scan the main document line by line; print preamble into auxiliary file until the document begins or \cs{EndPreamble} is found:
\endlinechar=-1\relax
- \def\@tempa{\pdfoutput=0\relax}%
+ \def\@tempa{\pdfoutput=0\relax}%
\in@false
- \openin\pstool@mainfile@ior "\jobname"\relax
+ \openin\pstool@mainfile@ior "\jobname"\relax
\@whilesw \unless\ifin@ \fi {%
\immediate\write\pstool@out{\unexpanded\expandafter{\@tempa}}%
- \readline\pstool@mainfile@ior to\@tempa
+ \readline\pstool@mainfile@ior to\@tempa
\let\@tempc\@tempa
\trim@multiple@spaces@in\@tempa
\expandafter\expandafter\expandafter\in@first
@@ -508,7 +537,7 @@
\expandafter}%
\expandafter{\@tempa}%
\fi
- }
+ }%
\closein\pstool@mainfile@ior
% Now the preamble of the process file:
\immediate\write\pstool@out{%
@@ -521,6 +550,7 @@
\noexpand\makeatletter^^J%
% Sort out the page numbering here.
% Force the pagestyle locally to output an integer so it can be written to the external file inside a \cs{setcounter} command.
+ \if@pstool@crossref@
\expandafter\ifx\csname r@\pstool@label\endcsname\relax\else
\def\noexpand\thepage{\unexpanded\expandafter{\thepage}}^^J%
\noexpand\setcounter{page}{%
@@ -528,13 +558,18 @@
\@secondoftwo\csname r@\pstool@label\endcsname
}^^J%
\fi
+ \fi
% And the document body to place the graphic on a page of its own:
+ \if@pstool@crossref@
\noexpand\@input{\jobname.oldaux}^^J%
+ \fi
\noexpand\makeatother^^J^^J%
\noexpand\begin{document}^^J%
+ \if@pstool@crossref@
\noexpand\makeatletter^^J%
\unexpanded{\immediate\write\@mainaux}{\pstool@auxmarker*}^^J%
\noexpand\makeatother^^J^^J%
+ \fi
\unexpanded{%
\centering\null\vfill^^J%
}%
@@ -550,8 +585,11 @@
\noexpand\end{preview}^^J%
\fi
^^J%
+ \if@pstool@crossref@
\unexpanded{\vfill^^J^^J\makeatletter^^J\immediate\write\@mainaux}{\pstool@auxmarker/}^^J%
- \unexpanded{\makeatother^^J\end{document}}^^J%
+ \unexpanded{\makeatother^^J}^^J%
+ \fi
+ \unexpanded{\end{document}}^^J%
}%
\immediate\closeout\pstool@out
}
@@ -647,3 +685,5 @@
\fi
}
% \centerline{\itshape ---The End---}
+
+%%%%%%%%%1%%%%%%%%%2%%%%%%%%%3%%%%%%%%%4%%%%%%%%%5