summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/auto-pst-pdf
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2007-11-22 19:06:39 +0000
committerKarl Berry <karl@freefriends.org>2007-11-22 19:06:39 +0000
commit284aa701318ea975cf01c9c411a2d05751ec2352 (patch)
tree077b8af4d4a8ab0508a949350b1a7ddf6b5cc1ca /Master/texmf-dist/tex/latex/auto-pst-pdf
parent424b6f42f4043d1047225e54e66dd2abad486f0b (diff)
auto-pst-pdf update (21nov07)
git-svn-id: svn://tug.org/texlive/trunk@5558 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/auto-pst-pdf')
-rw-r--r--Master/texmf-dist/tex/latex/auto-pst-pdf/auto-pst-pdf.sty263
1 files changed, 149 insertions, 114 deletions
diff --git a/Master/texmf-dist/tex/latex/auto-pst-pdf/auto-pst-pdf.sty b/Master/texmf-dist/tex/latex/auto-pst-pdf/auto-pst-pdf.sty
index b5c25c5bfe1..ab2b813761c 100644
--- a/Master/texmf-dist/tex/latex/auto-pst-pdf/auto-pst-pdf.sty
+++ b/Master/texmf-dist/tex/latex/auto-pst-pdf/auto-pst-pdf.sty
@@ -1,134 +1,169 @@
-% AUTO-PST-PDF
-% This is the auto-pst-pdf package, by Will Robertson.
-% Proper documentation forthcoming (if ever).
-%
-% This document may be distributed under the terms and conditions of
-% the LaTeX Project Public License, version 1.3c or later (your preference):
-% <http://www.latex-project.org/lppl.txt>
-%
-% The package is "maintained" by Will Robertson.
-% Contact: <wspr81 [at] gmail [dot] com>
-% Copyright 2006 by Will Robertson
-%
-% BASIC USAGE
-% This package provides a wrapper around pst-pdf to automatically
-% accomodate for typesetting either with DVI or PDF output. With
-% default package option [on], typesetting under pdfLaTeX will
-% automatically initiate a LaTeX->dvips->ps2pdf->pdfcrop run to
-% generate the required PDF figures for the document.
-%
-% After this has been done and the figures no longer need to be
-% re-generated, the package can be given the [off] option to save
-% compilation time.
-%
-% REQUIREMENTS
-% pdfTeX must be called with the --shell-escape option, and Heiko
-% Oberdiek's pdfcrop Perl script must be installed.
-%
-% Loads the following packages for convenience:
-% color,graphicx,psfrag,pst-pdf
-%
-% Requires e-TeX because I'm lazy.
-%
-% ADDITIONAL USAGE
-% Macros are provided to easily facilitate figures created by the
-% MATLAB package laprint and the Mathematica package MathPSfrag. Also,
-% a generic psfrag wrapper is provided.
-%
-% \mathfig{<filename>} - insert a Mathematica graphic
-% (without -psfrag suffix)
-% \matlabfig{<filename>} - insert a Matlab graphic
-% \psfragfig{<filename>} - insert an EPS with psfrag statements
-% in either or both of the files
-% <document>-psfrag.tex
-% <filename>-psfrag.tex
-%
-% The above commands also accept an optional argument
-% which is passed to \includegraphics.
-
-%% Declaration
-\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{auto-pst-pdf}
- [2006/11/30 v0.1 Wrapper for pst-pdf]
-
-%% Package options
-\newif\if@apstpdf@off@
-\@apstpdf@off@false
-\DeclareOption{off}{\@apstpdf@off@true}
-\DeclareOption{on}{\@apstpdf@off@false}
-\ExecuteOptions{on}
-\ProcessOptions
-
-\RequirePackage{ifpdf,etex,color,graphicx,psfrag}
-
-%%%%%%%%%%%%%%%%%%%%%%
-%% Base functionality:
-%
-% For compilation, we use the [notightpage] pst-pdf option and the
-% pdfcrop Perl script because Matlab-created EPS figures have elements
-% that extend ouside their bounding boxes, and end up with clipped
-% content after ps2pdf.
-%
-% Otherwise the script ps4pdf would be sufficient.
-
+%%
+%% This is file `auto-pst-pdf.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% auto-pst-pdf.dtx (with options: `package')
+%% __________________________________
+%% Copyright (C) 2007 Will Robertson
+%% License information appended.
+\ProvidesPackage{auto-pst-pdf}[2007/11/18 v0.4 Wrapper for pst-pdf]
+\RequirePackage{ifpdf,xkeyval,ifplatform}
+\newif\if@app@off@
+\newif\if@app@delay@
+\newif\if@app@crop@
+\def\app@suffix{autopp}
+\edef\app@jobname{\jobname-\app@suffix}
+\edef\app@pics{\jobname-pics.pdf}
+\DeclareOptionX{off}[]{\@app@off@true}
+\define@choicekey{auto-pst-pdf.sty}{crop}[\@tempa\@tempb]{on,off}{%
+ \ifcase\@tempb\relax
+ \@app@crop@true
+ \or
+ \@app@crop@false
+ \fi}
+\DeclareOptionX{on}[]{\@app@off@false}
+\DeclareOptionX{ext}{\def\app@ext{#1}}
+\DeclareOptionX{delay}{\@app@delay@true}
+\DeclareOptionX{latex}{%
+ \def\app@latex@opts{%
+ \ifwindows
+ -disable-write18
+ \else
+ -no-shell-escape
+ \fi
+ -jobname="\app@jobname"
+ -interaction=batchmode
+ #1}}
+\DeclareOptionX{dvips}{\def\app@dvips@opts{#1}}
+\DeclareOptionX{pspdf}{\def\app@pspdf@opts{#1}}
+\DeclareOptionX{pdfcrop}{\def\app@pdfcrop@opts{#1}}
+\DeclareOptionX{cleanup}{%
+ \let\app@rm@files\@empty
+ \@for\@ii:=#1\do{%
+ \edef\app@rm@files{\app@rm@files,\app@jobname.\@ii}}}
+\ExecuteOptionsX{%
+ ext=tex,
+ crop=on,
+ latex={},
+ dvips={-Ppdf},
+ pspdf={},
+ pdfcrop={},
+ cleanup={log,aux,dvi,ps,pdf}}
+\ifwindows
+ \ExecuteOptionsX{pspdf={}}
+\else
+ \ExecuteOptionsX{pspdf={-dAutoRotatePages=/None}}
+\fi
+\ProcessOptionsX
+\def\app@exe{\immediate\write18}
+\def\app@nl{^^J\space\space\space\space}
+\newcommand\app@PackageError[2]{%
+ \PackageError{auto-pst-pdf}{\app@nl #1^^J}{#2}}
+\newcommand\app@PackageWarning[1]{%
+ \PackageWarning{auto-pst-pdf}{\app@nl #1^^JThis warning occured}}
+\newcommand\app@PackageInfo[1]{\PackageInfo{auto-pst-pdf}{#1}}
+\newcommand\OnlyIfFileExists[2]{\IfFileExists{#1}{#2}{}}
+\newcommand\NotIfFileExists[2]{\IfFileExists{#1}{}{#2}}
+\def\app@convert#1#2#3{%
+ \OnlyIfFileExists{#2}{%
+ \app@exe{\csname app@cmd@#1\endcsname{#2}{#3}}%
+ \NotIfFileExists{#3}{\app@PackageError{Creation of #3 failed.}}}}
+\def\app@compile{%
+ \app@cleanup
+ \app@remove@container
+ \app@convert{latex}{\jobname.\app@ext}{\app@jobname.dvi}%
+ \app@convert{dvips}{\app@jobname.dvi}{\app@jobname.ps}%
+ \if@app@crop@
+ \app@convert{pstopdf}{\app@jobname.ps}{\app@jobname.pdf}%
+ \app@convert{pdfcrop}{\app@jobname.pdf}{\app@pics}%
+ \else
+ \app@convert{pstopdf}{\app@jobname.ps}{\app@pics}%
+ \fi
+ \IfFileExists{\app@pics}
+ {\app@cleanup}
+ {\app@PackageWarning{Could not create \app@pics.
+ Auxiliary files not deleted.}}}
+\edef\app@rm{\ifwindows del \else rm -- \fi}
+\newcommand\app@try@rm[1]{%
+ \@for\@tempa:=#1\do{%
+ \OnlyIfFileExists{\@tempa}{\app@exe{\app@rm "\@tempa"}}}}
+\def\app@remove@container{\app@try@rm{\app@pics}}
+\def\app@cleanup{\app@try@rm{\app@rm@files}}
+\def\app@cmd@latex#1#2{latex \app@latex@opts\space
+ "\let\noexpand\APPmakepictures\noexpand\empty\noexpand\input #1"}
+\def\app@cmd@dvips#1#2{dvips \app@dvips@opts\space -o "#2" "#1"}
+\def\app@cmd@pstopdf#1#2{ps2pdf \app@pspdf@opts\space "#1" "#2"}
+\def\app@cmd@pdfcrop#1#2{pdfcrop \app@pdfcrop@opts\space "#1" "#2"}
\ifpdf
-% pdfLaTeX compilation; requires supplementary processing for psfrag to work:
- \unless\if@apstpdf@off@
- \immediate\write18{latex -disable-write18 "\unexpanded{\let\APPmakepictures\empty\input}{\jobname.tex}"}
- \immediate\write18{dvips -o \jobname-pics.ps \jobname.dvi}
- \immediate\write18{ps2pdf \jobname-pics.ps \jobname-pics-nocrop.pdf}
- \immediate\write18{pdfcrop \jobname-pics-nocrop.pdf \jobname-pics.pdf}
+ \if@app@off@\else
+ \newcommand\CompilePics{%
+ \ifshellescape
+ \app@exe{echo " "}
+ \app@exe{echo "-------------------------------------------------"}
+ \app@exe{echo "auto-pst-pdf: Auxiliary LaTeX compilation"}
+ \app@exe{echo "-------------------------------------------------"}
+ \app@compile
+ \app@exe{echo "-------------------------------------------------"}
+ \app@exe{echo "auto-pst-pdf: End auxiliary LaTeX compilation"}
+ \app@exe{echo "-------------------------------------------------"}
+ \else
+ \app@PackageError{%
+ "shell escape" (or "write18") is not enabled:\app@nl
+ auto-pst-pdf will not work!}
+ {You need to run LaTeX with the equivalent of
+ "pdflatex -shell-escape"\app@nl
+ Or turn off auto-pst-pdf.}
+ \fi}
+ \if@app@delay@\else\CompilePics\fi
+ \fi
+ \if@app@crop@
+ \PassOptionsToPackage{notightpage}{pst-pdf}
\fi
- \RequirePackage[notightpage]{pst-pdf}
\else
\ifdefined\APPmakepictures
-% LaTeX compilation induced by this package:
- \RequirePackage[notightpage]{pst-pdf}
+ \if@app@crop@
+ \PassOptionsToPackage{notightpage}{pst-pdf}
+ \fi
\else
-% LaTeX compilation from scratch (as in `latex \jobname.tex`):
- \newenvironment{postscript}{}{}
+ \PassOptionsToPackage{inactive}{pst-pdf}
\fi
+ \AtBeginDocument{%
+ \gdef\ppf@other@extensions{.png,.pdf,.jpg,.jpeg,.PNG,.PDF,.JPG,.JPEG}
+ \edef\Gin@extensions{\Gin@extensions,.mps}
+ \DeclareGraphicsRule{.mps}{eps}{*}{}}
\fi
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% Extras for external packages:
-%
-% Commands are provided that mirror \includegraphics (and similarly
-% accept an optional argument) for the output of different
-% psfrag-related packages. This provides a consistent and easy way to
-% include such figures in the document.
-%
-% Please suggest wrappers for other packages that output psfrag
-% (for example: R, Maple, LabView, ... ?)
-
-%% Matlab's laprint:
-% We need to disable the scaling that laprint applies
-% to \includegraphics in here, because otherwise labels that extend
-% outside the bounding box of the generated PostScript file will
-% change the intended width of the graphic.
-\let\apstpdf@ig\includegraphics
+\RequirePackage{pst-pdf}
+\let\app@ig\includegraphics
\newcommand\matlabfig[2][]{%
\begin{postscript}
- \renewcommand\includegraphics[2][]{\apstpdf@ig[#1]{##2}}
+ \renewcommand\includegraphics[2][]{\app@ig[#1]{##2}}
\input{#2}
\end{postscript}}
-
-%% Mathematica's MathPSfrag output:
\newcommand\mathfig[2][]{%
\begin{postscript}
\input{#2-psfrag}%
\includegraphics[#1]{#2-psfrag}%
\end{postscript}}
-
-%% Regular old EPS graphics:
-% Include your psfrag commands in the files <document>-psfrag.tex
-% and/or <figname>-psfrag.tex, where <document> is the filename of the
-% main document and <figname> is the filename of the graphics
-% inserted.
\newcommand\psfragfig[2][]{%
\begin{postscript}
- \InputIfFileExists{#1-psfrag}{}{}%
+ \InputIfFileExists{#2-psfrag}{}{}%
\includegraphics[#1]{#2}%
\end{postscript}}
-
-\InputIfFileExists{\jobname-psfrag}{}{}%
+\InputIfFileExists{\jobname-psfrag}{}{}
+%% Copyright (C) 2007 by Will Robertson & Johannes Große
+%%
+%% Distributable under the LaTeX Project Public License,
+%% version 1.3c or higher (your choice). The latest version of
+%% this license is at: http://www.latex-project.org/lppl.txt
+%%
+%% This work is "maintained" (as per LPPL maintenance status)
+%% by Will Robertson.
+%%
+%% This work consists of the file auto-pst-pdf.dtx
+%% and the derived files auto-pst-pdf.pdf,
+%% auto-pst-pdf.sty, and
+%% auto-pst-pdf.ins.
+%%
+%% End of file `auto-pst-pdf.sty'.