summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/standalone/standalone.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/standalone/standalone.sty')
-rw-r--r--Master/texmf-dist/tex/latex/standalone/standalone.sty173
1 files changed, 139 insertions, 34 deletions
diff --git a/Master/texmf-dist/tex/latex/standalone/standalone.sty b/Master/texmf-dist/tex/latex/standalone/standalone.sty
index 8333ee65eec..4c83a7d2bd3 100644
--- a/Master/texmf-dist/tex/latex/standalone/standalone.sty
+++ b/Master/texmf-dist/tex/latex/standalone/standalone.sty
@@ -25,9 +25,9 @@
%% This work consists of the files standalone.dtx, standalone.ins
%% and the derived file standalone.sty.
%%
-% $Id: standalone.dtx 1772 2010-03-27 13:50:59Z martin $
+% $Id: standalone.dtx 2194 2011-02-28 19:26:29Z martin $
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{standalone} [2010/03/27 v0.3a Package to include TeX sub-files with preambles]
+\ProvidesPackage{standalone} [2010/02/28 v0.4 Package to include TeX sub-files with preambles]
\expandafter\newif\csname ifstandalone\endcsname
\standalonefalse
\@ifundefined{ifstandalonebeamer}{%
@@ -57,6 +57,24 @@
\DeclareOption{nocomments}{%
\def\sa@percent{}%
}
+\DeclareOption{mode=none}{%
+ \let\sa@mode\relax
+}
+\DeclareOption{mode=pdf|tex}{%
+ \def\sa@mode{0}%
+}
+\DeclareOption{mode=tex}{%
+ \def\sa@mode{1}%
+}
+\DeclareOption{mode=pdf}{%
+ \def\sa@mode{2}%
+}
+\DeclareOption{mode=build}{%
+ \def\sa@mode{3}%
+}
+\DeclareOption{mode=buildnew}{%
+ \def\sa@mode{4}%
+}
\ProcessOptions*\relax
\ifsa@printsubpreambles
\ifsa@sortsubpreambles\else
@@ -220,38 +238,16 @@
\@ifundefined{sa@pkgdate@\pkg}%
{\global\@namedef{sa@pkgdate@\pkg}{#3}}%
{%
- \begingroup
- \edef\@tempa{{\csname sa@pkgdate@\pkg\endcsname}{#3}}%
- \expandafter\sa@getlargerdate\@tempa
- \expandafter\xdef\csname sa@pkgdate@\pkg\endcsname{\sa@thedate}%
- \endgroup
+ \ifnum\expandafter\expandafter
+ \expandafter\sa@@getdate\csname sa@pkgdate@\pkg\endcsname//00\relax<\sa@@getdate#3//00\relax
+ \global\@namedef{sa@pkgdate@\pkg}{#3}%
+ \fi
}%
\fi
}%
\sa@gobbleeol\sa@removepackages^^J%
}
-\def\sa@getlargerdate#1#2{%
- \sa@@getdate#1\relax\relax0/0/0\relax\empty\relax
- \let\sa@datea\sa@date
- \sa@@getdate#2\relax\relax0/0/0\relax\empty\relax
- \ifdim\sa@datea pt>\sa@date pt
- \def\sa@thedate{#1}%
- \else
- \def\sa@thedate{#2}%
- \fi
-}
-\def\sa@@getdate#1/#2/#3\relax{%
- \@ifnextchar\relax
- {%
- \def\sa@date{#1.#2#3}%
- \sa@@rmdate
- }%
- {%
- \def\sa@date{0}%
- \sa@@rmdate
- }%
-}
-\def\sa@@rmdate#1\empty\relax{}
+\def\sa@@getdate#1/#2/#3#4#5\relax{#1#2#3#4}
\def\sa@collpgflibs{}%
\def\sa@sortpgflibs#1{%
\@for\lib:=#1\do {%
@@ -389,6 +385,7 @@
\@ifnextchar^^J%
{\sa@gobbleeol{#1}}{#1}%
}
+\def\sa@gobbleline#1^^J{}%
\long\def\standaloneignore#1\documentclass{%
\sa@documentclass
}
@@ -452,9 +449,10 @@
\def\next{%
\endgroup
\PackageWarning{standalone}{Running 'standalone' package in sub-preamble print mode. All body content of file `\sa@filepath' is ignored!}{}{}%
- \null
+ \hbox to 1pt{\vbox to 1pt{}}%
\endinput
- }
+ %\sa@gobbleline
+ }%
\else
\expandafter
\ifx
@@ -469,10 +467,11 @@
\PackageWarning{standalone}{Sub-preamble of file '\sa@filepath' has changed. Content will be ignored. Please rerun LaTeX!}{}{}%
\immediate\write\@mainaux{%
\@percentchar\space standalone package info: Rerun LaTeX!
- }
- \null
+ }%
+ \hbox to 1pt{\vbox to 1pt{}}%
\endinput
- }
+ %\sa@gobbleline
+ }%
\fi
\fi
\else
@@ -540,6 +539,112 @@
\def\sa@atenddocument{%
\unskip
}%
+\expandafter\ifx\csname sa@mode\endcsname\relax\else
+\RequirePackage{gincltex}
+\RequirePackage{ifpdf}
+\ifpdf
+ \def\sa@graphicext{.pdf}
+\else
+ \def\sa@graphicext{.eps}
+\fi
+
+\def\sa@comparegranpic#1{%
+ \begingroup
+ \let\next\empty
+ \expandafter\sa@comparegranpic@\pdffilemoddate{#1\sa@graphicext}\relax
+ \let\sa@picdate\sa@date
+ \let\sa@pictime\sa@time
+ \expandafter\sa@comparegranpic@\pdffilemoddate{#1.tex}\relax
+ \ifnum\sa@date>\sa@picdate\relax
+ \def\next{\sa@buildgraphic{#1}}%
+ \else
+ \ifnum\sa@date=\sa@picdate\relax
+ \ifnum\sa@time>\sa@pictime\relax
+ \def\next{\sa@buildgraphic{#1}}%
+ \fi
+ \fi
+ \fi
+ \expandafter
+ \endgroup
+ \next
+}
+
+\begingroup
+\@makeother\D
+\@makeother:
+\global\@namedef{sa@comparegranpic@}D:#1#2#3#4#5#6#7#8#9\relax{%
+ \def\sa@date{#1#2#3#4#5#6#7#8}%
+ \sa@comparegranpic@@#9\relax
+}
+\endgroup
+
+\def\sa@comparegranpic@@#1#2#3#4#5#6#7\relax{%
+ \def\sa@time{#1#2#3#4#5#6}%
+ \def\sa@tz{#7}%
+}
+
+\def\sa@compilecmd{\ifpdf pdf\fi latex --interaction=batchmode \image}%
+
+\def\sa@buildgraphic#1{%
+ \ifeof18
+ \PackageError{standalone}{Shell escape needed to create graphic!}{}%
+ \else
+ \begingroup
+ \def\image{#1}%
+ \immediate\write18{\sa@compilecmd}%
+ \endgroup
+ \fi
+}
+
+\newcommand*\includestandalone[2][]{%
+ \begingroup
+ \edef\@tempa{{#2\sa@graphicext}}%
+ \expandafter\includestandalone@\@tempa{#2}{#1}%
+ \endgroup
+}
+
+%% 0 = PDF if exists, TEX otherwise
+%% 1 = force TEX
+%% 2 = force PDF
+%% 3 = build PDF if not exists
+%% 4 = build PDF if older than TEX
+\def\includestandalone@#1#2#3{%
+ \ifcase\sa@mode
+ \relax% 0
+ \IfFileExists{#1}%
+ {\includegraphics[#3]{#1}}%
+ {\includegraphics[#3]{#2.tex}}%
+ \or% 1
+ \includegraphics[#3]{#2.tex}%
+ \or% 2
+ \includegraphics[#3]{#1}%
+ \or% 3
+ \IfFileExists{#1}%
+ {\includegraphics[#3]{#1}}%
+ {\sa@buildgraphic{#2}%
+ \IfFileExists{#1}%
+ {\includegraphics[#3]{#1}}%
+ {\PackageWarning{standalone}%
+ {Graphic '#1' could not be build.^^J%
+ Shell escape activated?}%
+ \includegraphics[#3]{#2.tex}%
+ }%
+ }%
+ \else% 4
+ \IfFileExists{#1}%
+ {\sa@comparegranpic{#2}}%
+ {\sa@buildgraphic{#2}%
+ \IfFileExists{#1}%
+ {\includegraphics[#3]{#1}}%
+ {\PackageWarning{standalone}%
+ {Graphic '#1' could not be build.^^J%
+ Shell escape activated?}%
+ \includegraphics[#3]{#2.tex}%
+ }%
+ }%
+ \fi
+}
+\fi
\endinput
%%
%% End of file `standalone.sty'.